ES 6.0: Rules engine for notifications

Discussion topics related to mobile applications and ZoneMinder Event Server (including machine learning)
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: ES 6.0: Rules engine for notifications

Post by asker »

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.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: ES 6.0: Rules engine for notifications

Post by Magic919 »

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: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: ES 6.0: Rules engine for notifications

Post by asker »

Ok great. Thanks for testing!
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: ES 6.0: Rules engine for notifications

Post by Magic919 »

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: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: ES 6.0: Rules engine for notifications

Post by asker »

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)
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: ES 6.0: Rules engine for notifications

Post by Magic919 »

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: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: ES 6.0: Rules engine for notifications

Post by asker »

Uh oh, that's right. It's a bug. Will fix it.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: ES 6.0: Rules engine for notifications

Post by asker »

Please update and try (you'll still see 1970 but day of week should work as expected)
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: ES 6.0: Rules engine for notifications

Post by Magic919 »

Ok, have updated and will see what happens.

Thanks.
-
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: ES 6.0: Rules engine for notifications

Post by Magic919 »

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: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: ES 6.0: Rules engine for notifications

Post by Magic919 »

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: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: ES 6.0: Rules engine for notifications

Post by asker »

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?
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: ES 6.0: Rules engine for notifications

Post by asker »

Also ,there was a logging error in ES - please update.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: ES 6.0: Rules engine for notifications

Post by Magic919 »

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: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: ES 6.0: Rules engine for notifications

Post by Magic919 »

Have updated ES.
-
Post Reply