ES 6.0: Rules engine for notifications

Discussion topics related to mobile applications for ZoneMinder
User avatar
asker
Posts: 1419
Joined: Sun Mar 01, 2015 12:12 pm

Re: ES 6.0: Rules engine for notifications

Post by asker » Thu Sep 10, 2020 11:18 pm

Magic919 wrote:
Thu Sep 10, 2020 7:58 am
This alert got muted, but it shouldn't have.

I presume this is the second part of the json that mutes 3-6 am. I'll have a go at removing that, but I'm not a json expert.

Would prefer 24 hour clock if that's an option :-)
It is an option. Just change the time format specification. Google for "strftime format" and use any format you want. For 24 hrs, it would be "%H:%M" and change the from and to fields to 24 hr format. As far as the other rule is concerned, just delete it.
Please don't ask me questions via PM. Feel free to post in the forums or Github

My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

Magic919
Posts: 206
Joined: Wed Sep 18, 2013 6:56 am

Re: ES 6.0: Rules engine for notifications

Post by Magic919 » Fri Sep 11, 2020 10:39 am

Thanks for the reply.

I've amended the time format and converted my times to 24 hour clock.

I managed to delete the second mute. It's simple with JSON expertise (which I don't have) but knowing where to stop, which brace, do I still need the comma, these are the challenges. I used a chop and JSON validate method and that worked out.

It's working for the ZMNinja notifications too.

User avatar
asker
Posts: 1419
Joined: Sun Mar 01, 2015 12:12 pm

Re: ES 6.0: Rules engine for notifications

Post by asker » Fri Sep 11, 2020 6:04 pm

Ok great. Thanks for testing!
Please don't ask me questions via PM. Feel free to post in the forums or Github

My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

Magic919
Posts: 206
Joined: Wed Sep 18, 2013 6:56 am

Re: ES 6.0: Rules engine for notifications

Post by Magic919 » Sun Sep 13, 2020 11:14 am

It doesn't care about the daysofweek and is still muting today (Sunday).

CONSOLE INF:2020-09-13,12:10:26 |----> FORK:Shed2 (12), eid:223247 Event 223247 for Monitor 12 has finished
CONSOLE DBG-1:2020-09-13,12:10:28 |----> FORK:Shed2 (12), eid:223247 rules: (eid: 223247) -- Processing rule: 1 --
CONSOLE DBG-2:2020-09-13,12:10:28 |----> FORK:Shed2 (12), eid:223247 rules: parsing rule 06:30/22:00 using format:%H:%M
CONSOLE DBG-2:2020-09-13,12:10:28 |----> FORK:Shed2 (12), eid:223247 rules: parsed time from: Thu Jan 1 06:30:00 1970 and to:Thu Jan 1 22:00:00 1970
CONSOLE DBG-2:2020-09-13,12:10:28 |----> FORK:Shed2 (12), eid:223247 rules:(eid: 223247) seeing if now:12:10 is between:06:30 and 22:00
CONSOLE DBG-1:2020-09-13,12:10:28 |----> FORK:Shed2 (12), eid:223247 rules: (eid: 223247) mute rule matched, not allowing
CONSOLE DBG-2:2020-09-13,12:10:28 |----> FORK:Shed2 (12), eid:223247 rules: Not processing start notifications as rules checks failed

User avatar
asker
Posts: 1419
Joined: Sun Mar 01, 2015 12:12 pm

Re: ES 6.0: Rules engine for notifications

Post by asker » Sun Sep 13, 2020 11:55 am

1. Could you please update ES
2. Please make sure you are using the key "daysofweek" to specify days (In the past, I was using "dow" somewhere in error)
Please don't ask me questions via PM. Feel free to post in the forums or Github

My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

Magic919
Posts: 206
Joined: Wed Sep 18, 2013 6:56 am

Re: ES 6.0: Rules engine for notifications

Post by Magic919 » Sun Sep 13, 2020 1:16 pm

Thanks for the quick response.

I've updated and it's still behaving a bit strangely. It seems to think it is Thursday today if I understand correctly. First day of the Epoch too.

Code: Select all

CONSOLE DBG-1:2020-09-13,13:58:36 |----> FORK:Shed2 (12), eid:223265 rules: (eid: 223265) -- Processing rule: 1 --
CONSOLE DBG-2:2020-09-13,13:58:36 |----> FORK:Shed2 (12), eid:223265 rules: parsing rule 06:30/22:00 using format:%H:%M
CONSOLE DBG-2:2020-09-13,13:58:36 |----> FORK:Shed2 (12), eid:223265 rules: parsed time from: Thu Jan  1 06:30:00 1970 and to:Thu Jan  1 22:00:00 1970
CONSOLE DBG-2:2020-09-13,13:58:36 |----> FORK:Shed2 (12), eid:223265 rules:(eid: 223265)  seeing if now:13:58 is between:06:30 and 22:00
CONSOLE DBG-2:2020-09-13,13:58:36 |----> FORK:Shed2 (12), eid:223265 rules:(eid: 223265)  seeing if now:Thu matches:Mon,Tue,Wed,Thu,Fri
CONSOLE DBG-1:2020-09-13,13:58:36 |----> FORK:Shed2 (12), eid:223265 rules: (eid: 223265) mute rule matched, not allowing
CONSOLE DBG-2:2020-09-13,13:58:36 |----> FORK:Shed2 (12), eid:223265 rules: Not processing start notifications as rules checks failed


User avatar
asker
Posts: 1419
Joined: Sun Mar 01, 2015 12:12 pm

Re: ES 6.0: Rules engine for notifications

Post by asker » Sun Sep 13, 2020 2:05 pm

Uh oh, that's right. It's a bug. Will fix it.
Please don't ask me questions via PM. Feel free to post in the forums or Github

My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

User avatar
asker
Posts: 1419
Joined: Sun Mar 01, 2015 12:12 pm

Re: ES 6.0: Rules engine for notifications

Post by asker » Sun Sep 13, 2020 6:23 pm

Please update and try (you'll still see 1970 but day of week should work as expected)
Please don't ask me questions via PM. Feel free to post in the forums or Github

My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

Magic919
Posts: 206
Joined: Wed Sep 18, 2013 6:56 am

Re: ES 6.0: Rules engine for notifications

Post by Magic919 » Sun Sep 13, 2020 6:48 pm

Ok, have updated and will see what happens.

Thanks.

Magic919
Posts: 206
Joined: Wed Sep 18, 2013 6:56 am

Re: ES 6.0: Rules engine for notifications

Post by Magic919 » Mon Sep 14, 2020 6:34 am

Hmmm. Seems to believe today is Thursday if I understand correctly. It's already muted based on time, however. I can drop Thur out of the json and see what occurs next.

Code: Select all

CONSOLE DBG-2:2020-09-14,06:57:42 |----> FORK:Shed2 (12), eid:223320 rules:(eid: 223320)  seeing if now:06:57 is between:06:30 and 22:00
CONSOLE DBG-2:2020-09-14,06:57:42 |----> FORK:Shed2 (12), eid:223320 rules:(eid: 223320)  seeing if now:Thu matches:Mon,Tue,Wed,Thu,Fri
CONSOLE DBG-1:2020-09-14,06:57:42 |----> FORK:Shed2 (12), eid:223320 rules: (eid: 223320) mute rule matched, not allowing

Magic919
Posts: 206
Joined: Wed Sep 18, 2013 6:56 am

Re: ES 6.0: Rules engine for notifications

Post by Magic919 » Mon Sep 14, 2020 10:22 am

Dropping out Thu just leaves it the time and it's happy to match on that and mute (incorrectly). Feels like it matches OR instead of AND.

Code: Select all

CONSOLE DBG-2:2020-09-14,10:59:06 |----> FORK:Shed2 (12), eid:223349 rules: parsing rule 10:30/22:00 using format:%H:%M
CONSOLE DBG-2:2020-09-14,10:59:06 |----> FORK:Shed2 (12), eid:223349 rules: parsed time from: Thu Jan  1 10:30:00 1970 and to:Thu Jan  1 22:00:00 1970
CONSOLE DBG-2:2020-09-14,10:59:06 |----> FORK:Shed2 (12), eid:223349 rules:(eid: 223349)  seeing if now:10:59 is between:10:30 and 22:00
CONSOLE DBG-2:2020-09-14,10:59:06 |----> FORK:Shed2 (12), eid:223349 rules:(eid: 223349)  seeing if now:Thu matches:Mon,Tue,Wed,Fri
CONSOLE DBG-1:2020-09-14,10:59:06 |----> FORK:Shed2 (12), eid:223349 rules: (eid: 223349) mute rule matched, not allowing
CONSOLE DBG-2:2020-09-14,10:59:06 |----> FORK:Shed2 (12), eid:223349 rules: Not processing start notifications as rules checks failed

User avatar
asker
Posts: 1419
Joined: Sun Mar 01, 2015 12:12 pm

Re: ES 6.0: Rules engine for notifications

Post by asker » Mon Sep 14, 2020 10:33 am

What is the output of this sample program?

Code: Select all

use Time::Piece;
my $now = Time::Piece->new;
print ("Date is $now\n");
print ("Weekday is ".$now->wdayname."\n");
Assuming you save it as foo.pl, you can run it by doing

Code: Select all

 perl ./foo.pl
Is the output correct?
Please don't ask me questions via PM. Feel free to post in the forums or Github

My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

User avatar
asker
Posts: 1419
Joined: Sun Mar 01, 2015 12:12 pm

Re: ES 6.0: Rules engine for notifications

Post by asker » Mon Sep 14, 2020 10:37 am

Also ,there was a logging error in ES - please update.
Please don't ask me questions via PM. Feel free to post in the forums or Github

My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

Magic919
Posts: 206
Joined: Wed Sep 18, 2013 6:56 am

Re: ES 6.0: Rules engine for notifications

Post by Magic919 » Mon Sep 14, 2020 11:35 am

Here's the Perl bit -

Code: Select all

perl ./foo.pl
Date is Mon Sep 14 12:34:47 2020
Weekday is Mon
Correct fror my TZ.

I'll update ES once I've eaten.

Magic919
Posts: 206
Joined: Wed Sep 18, 2013 6:56 am

Re: ES 6.0: Rules engine for notifications

Post by Magic919 » Mon Sep 14, 2020 12:23 pm

Have updated ES.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests