ES 6.0: Rules engine for notifications

Discussion topics related to mobile applications for ZoneMinder
Magic919
Posts: 142
Joined: Wed Sep 18, 2013 6:56 am

Re: ES 6.0: Rules engine for notifications

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

This looks good -

Code: Select all

CONSOLE DBG-1:2020-09-14,13:50:31 |----> FORK:Shed2 (12), eid:223366 rules: (eid: 223366) -- Processing rule: 1 --
CONSOLE DBG-2:2020-09-14,13:50:31 |----> FORK:Shed2 (12), eid:223366 rules: parsing rule 10:30/22:00 using format:%H:%M
CONSOLE DBG-2:2020-09-14,13:50:31 |----> FORK:Shed2 (12), eid:223366 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,13:50:31 |----> FORK:Shed2 (12), eid:223366 rules:(eid: 223366)  seeing if now:13:50 is between:10:30 and 22:00
CONSOLE DBG-2:2020-09-14,13:50:31 |----> FORK:Shed2 (12), eid:223366 rules:(eid: 223366)  seeing if now:Mon is part of:Mon,Tue,Wed,Fri
CONSOLE DBG-1:2020-09-14,13:50:31 |----> FORK:Shed2 (12), eid:223366 rules: (eid: 223366) mute rule matched, not allowing
CONSOLE DBG-2:2020-09-14,13:50:31 |----> FORK:Shed2 (12), eid:223366 rules: Not processing start notifications as rules checks failed
CONSOLE DBG-1:2020-09-14,13:50:35 |----> FORK:Shed2 (12), eid:223366 rules: (eid: 223366) -- Processing rule: 1 --
CONSOLE DBG-2:2020-09-14,13:50:35 |----> FORK:Shed2 (12), eid:223366 rules:(eid: 223366)  seeing if now:13:50 is between:10:30 and 22:00
CONSOLE DBG-2:2020-09-14,13:50:35 |----> FORK:Shed2 (12), eid:223366 rules:(eid: 223366)  seeing if now:Mon is part of:Mon,Tue,Wed,Fri
CONSOLE DBG-1:2020-09-14,13:50:35 |----> FORK:Shed2 (12), eid:223366 rules: (eid: 223366) mute rule matched, not allowing
CONSOLE DBG-2:2020-09-14,13:50:35 |----> FORK:Shed2 (12), eid:223366 rules: Not processing end notifications as rules checks failed for start notification
It 'knows' now is Monday!

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

Re: ES 6.0: Rules engine for notifications

Post by asker » Mon Sep 14, 2020 2:26 pm

sounds good!
--
My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

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

Re: ES 6.0: Rules engine for notifications

Post by Magic919 » Mon Sep 14, 2020 5:40 pm

We are getting there.

Can I ask about 'cause_has'? Is that ready to test? I presume the strict order of these is unimportant.

My first test suggested it was just a mute and no reference to alarm cause. I wanted it to mute if there was a cause 'car'.

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

Re: ES 6.0: Rules engine for notifications

Post by asker » Mon Sep 14, 2020 7:05 pm

"cause_has" is a string or a regular expression that needs to be matched for the rule to kick in.

Code: Select all

For example:
{
   from: "9am",
   to:"6pm",
   cause_has: "cat",
   action:"mute"

}
This means "If the alarm has the word 'cat' inside its cause field and is between 9am - 6pm, don't notify"

It also supports regular expressions, so:

Code: Select all

For example:
{
   from: "9pm",
   to:"4am",
   cause_has: "^(?!.*(person)).*$",
   action:"mute"

}
This means "If the alarm DOES NOT have the word person in it, don't notify between 9pm - 4am".
--
My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

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

Re: ES 6.0: Rules engine for notifications

Post by Magic919 » Mon Sep 14, 2020 8:01 pm

I’ll try that tomorrow and see how I get on. Thanks

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

Re: ES 6.0: Rules engine for notifications

Post by Magic919 » Tue Sep 15, 2020 8:25 am

Firstly, it's worth saying that there are no references to 'cause' in this log output, so I'm running blind.

Code: Select all

CONSOLE DBG-1:2020-09-15,09:17:14 |----> FORK:Shed2 (12), eid:223455 rules: (eid: 223455) -- Processing rule: 1 --
CONSOLE DBG-2:2020-09-15,09:17:14 |----> FORK:Shed2 (12), eid:223455 rules: parsing rule 09:15/22:00 using format:%H:%M
CONSOLE DBG-2:2020-09-15,09:17:14 |----> FORK:Shed2 (12), eid:223455 rules: parsed time from: Thu Jan  1 09:15:00 1970 and to:Thu Jan  1 22:00:00 1970
CONSOLE DBG-2:2020-09-15,09:17:14 |----> FORK:Shed2 (12), eid:223455 rules:(eid: 223455)  seeing if now:09:17 is between:09:15 and 22:00
CONSOLE DBG-2:2020-09-15,09:17:14 |----> FORK:Shed2 (12), eid:223455 rules:(eid: 223455)  seeing if now:Tue is part of:
CONSOLE DBG-1:2020-09-15,09:17:14 |----> FORK:Shed2 (12), eid:223455 rules: (eid: 223455) mute rule matched, not allowing
CONSOLE DBG-2:2020-09-15,09:17:14 |----> FORK:Shed2 (12), eid:223455 rules: Not processing start notifications as rules checks failed
CONSOLE DBG-1:2020-09-15,09:17:18 |----> FORK:Shed2 (12), eid:223455 rules: (eid: 223455) -- Processing rule: 1 --
CONSOLE DBG-2:2020-09-15,09:17:18 |----> FORK:Shed2 (12), eid:223455 rules:(eid: 223455)  seeing if now:09:17 is between:09:15 and 22:00
CONSOLE DBG-2:2020-09-15,09:17:18 |----> FORK:Shed2 (12), eid:223455 rules:(eid: 223455)  seeing if now:Tue is part of:
CONSOLE DBG-1:2020-09-15,09:17:18 |----> FORK:Shed2 (12), eid:223455 rules: (eid: 223455) mute rule matched, not allowing
CONSOLE DBG-2:2020-09-15,09:17:18 |----> FORK:Shed2 (12), eid:223455 rules: Not processing end notifications as rules checks failed for start notification
I put 'car' in there and this one was a truck. I only see the time/date part of the rules being assessed.

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

Re: ES 6.0: Rules engine for notifications

Post by asker » Tue Sep 15, 2020 12:36 pm

The chances are the event that is being checked does not have the cause you are expecting (sometimes they are written later, if you are using machine learning)

I've added a log so we can see what the cause is. Please update and lets look at the logs.
--
My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

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

Re: ES 6.0: Rules engine for notifications

Post by Magic919 » Tue Sep 15, 2020 12:53 pm

Thanks for your reply. That makes sense.

I'll update and we can see what occurs.

At some point I need to tackle the question of why ES doesn't 'catch' some ZM alerts. I've made sure they are all at least 15 seconds long and have the polling at 5 seconds. Maybe you have additional things I could check my end.

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

Re: ES 6.0: Rules engine for notifications

Post by Magic919 » Tue Sep 15, 2020 12:59 pm

Code: Select all

 seeing if cause_has:car is part of :
Seems like it doesn't have my cause. Here's a bit of my json.

Code: Select all

                                "rules": [{
                                                "comment": "Be careful with dates, no leading spaces, etc",
                                                "time_format": "%H:%M",
                                                "from": "09:15",
                                                "to": "22:00",
                                                "action": "mute",
                                                "cause_has": "car"
                                        }

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

Re: ES 6.0: Rules engine for notifications

Post by asker » Tue Sep 15, 2020 1:51 pm

So that means the alarm that is coming through in ZM does not have a "detected: car" in it. Do you see "detected: car" in the event when you go to ZM?
--
My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

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

Re: ES 6.0: Rules engine for notifications

Post by Magic919 » Tue Sep 15, 2020 2:02 pm

Without it detecting as a car it shouldn't mute then.

It does mute. ZM for the last 4 alerts says

Code: Select all

[a] detected:car:99%  Motion: All

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

Re: ES 6.0: Rules engine for notifications

Post by Magic919 » Tue Sep 15, 2020 2:13 pm

In terms of the log, the logic (to me) is different on cause based on your last message.

Code: Select all

seeing if now:15:04 is between:09:15 and 22:00
seeing if now:Tue is part of:
seeing if cause_has:car is part of :
mute rule matched, not allowing
LHS is the found or derived data (actual time, day), RHS is the defined data from the JSON.

Shouldn't the cause_has be ZM on LHS and JSON defined on RHS to match this. Not the other way around.

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

Re: ES 6.0: Rules engine for notifications

Post by asker » Tue Sep 15, 2020 3:33 pm

As it turns out there was a typo in the matching logic. Could you try again after updating?
--
My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

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

Re: ES 6.0: Rules engine for notifications

Post by Magic919 » Tue Sep 15, 2020 4:03 pm

Will do. Will let you know how it goes. Thanks.

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

Re: ES 6.0: Rules engine for notifications

Post by Magic919 » Tue Sep 15, 2020 4:37 pm

I changed it to mute on truck, as it sees more cars here. That gave an alert.

Logs says -

Code: Select all

CONSOLE DBG-1:2020-09-15,17:32:32 |----> FORK:Shed2 (12), eid:223516 rules: (eid: 223516) -- Processing rule: 1 --
CONSOLE DBG-2:2020-09-15,17:32:32 |----> FORK:Shed2 (12), eid:223516 rules:(eid: 223516)  seeing if now:17:32 is between:09:15 and 22:00
CONSOLE DBG-2:2020-09-15,17:32:32 |----> FORK:Shed2 (12), eid:223516 rules:(eid: 223516)  seeing if now:Tue is part of:
CONSOLE DBG-2:2020-09-15,17:32:32 |----> FORK:Shed2 (12), eid:223516 rules:(eid: 223516)  seeing if cause_has:truck is part of :
CONSOLE DBG-1:2020-09-15,17:32:32 |----> FORK:Shed2 (12), eid:223516 rules: (eid: 223516) Skipping this rule as truck does not pattern match 
CONSOLE DBG-1:2020-09-15,17:32:32 |----> FORK:Shed2 (12), eid:223516 rules: (eid: 223516) Found rule for  (12) but no conflicts. Allowing.
CONSOLE DBG-1:2020-09-15,17:32:32 |----> FORK:Shed2 (12), eid:223516 Matching alarm to connection rules...

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests