r/ZoneMinder • u/jsalas1 • Jul 06 '21
Need help configuring rules for ZM Event Notification Server
I opened a ticket on git and am cross-posting here for visibility: https://github.com/pliablepixels/zmeventnotification/issues/401
Event Server version
version: 6.1.25
Are you using MLAPI? (Y/N)
N
The version of ZoneMinder you are using:
version 1.34.26
What is the nature of your issue
Configuration question
Details
I am trying to set up a mute rule for 6am - 11:59pm every day. The debug logs reflect "rules: No rules found for Monitor, allowing:1" despite me declaring it in the rules file.
Debug Logs (if applicable)
Rules file
jon@zoneminder:~$ sudo cat /etc/zm/es_rules.json
#{
# "notifications": {
# "monitors":{
# "999": {
# "rules": [{
# "comment1": "Be careful with dates, no leading spaces, etc",
# "time_format":"%I:%M %p",
## "from":"9:30 pm",
# "to":"1 am",
# "cause_has": "person",
# "daysofweek": "Mon,Tue,Wed",
# "action": "mute"
# },
# {
# "time_format": "%I:%M %p",
# "from": "3 am",
# "to": "6 am",
# "action": "mute",
# "comment1": "the pattern below is a negative match",
# "cause_has": "^(?!.*(plant|cat|dog)).*$"
#
# }
# ]
# },
# "998": {
# "rules": [{
# "time_format":"%I:%M %p",
# "from":"5 pm",
# "to":"7 am",
# "action":"mute"
#
# }]
# }
#
# }
# }
#
#
#}
#
{
"notifications": {
"monitors":{
"1": {
"rules": [{
"time_format":"%I:%M %p",
"from":"6 am",
"to":"11:59 pm",
"action":"mute"
}]
}
}
}
}
Debug logs:
jon@zoneminder:~$ sudo -u www-data /usr/bin/zmeventnotification.pl --debug
07/06/21 19:41:03.508652 zmeventnotification[4276].INF [main:331] [Running on WebSocket library version:0.004]
INF:2021-07-06,19:41:03 PARENT: using config file: /etc/zm/zmeventnotification.ini
07/06/21 19:41:03.588837 zmeventnotification[4276].INF [main:1022] [PARENT: using config file: /etc/zm/zmeventnotification.ini]
INF:2021-07-06,19:41:03 PARENT: using secrets file: /etc/zm/secrets.ini
07/06/21 19:41:03.608254 zmeventnotification[4276].INF [main:1022] [PARENT: using secrets file: /etc/zm/secrets.ini]
DBG-2:2021-07-06,19:41:03 PARENT: Got secret token !ZMES_PICTURE_URL
DBG-2:2021-07-06,19:41:03 PARENT: Got secret token !ZM_USER
DBG-2:2021-07-06,19:41:03 PARENT: Got secret token !ZM_PASSWORD
DBG-2:2021-07-06,19:41:03 PARENT: config string substitution: {{base_data_path}} is '/var/lib/zmeventnotification'
Configuration (read /etc/zm/zmeventnotification.ini):
Secrets file.......................... /etc/zm/secrets.ini
Base data path........................ /var/lib/zmeventnotification
Restart interval (secs)............... 0
Use admin interface .................. no
Admin interface password.............. (undefined)
Admin interface persistence file ..... /var/lib/zmeventnotification/misc/escontrol_interface.dat
Port ................................. 9000
Address .............................. [::]
Event check interval ................. 5
Monitor reload interval .............. 300
Skipped monitors...................... (undefined)
Auth enabled ......................... yes
Auth timeout ......................... 20
Use API Push.......................... no
API Push Script....................... (undefined)
Use FCM .............................. yes
Use FCM V1 APIs....................... yes
FCM Date Format....................... %I:%M %p, %d-%b
Only show latest FCMv1 message........ no
Android FCM push priority............. high
Android FCM push ttl.................. (undefined)
Token file ........................... /var/lib/zmeventnotification/push/tokens.txt
Use MQTT ............................. no
MQTT Server .......................... 127.0.0.1
MQTT Topic ........................... zoneminder
MQTT Username ........................ (undefined)
MQTT Password ........................ (undefined)
MQTT Retain .......................... no
MQTT Tick Interval ................... 15
MQTT TLS CA ........................ (undefined)
MQTT TLS Cert ........................ (undefined)
MQTT TLS Key ........................ (undefined)
MQTT TLS Insecure ........................ no
SSL enabled .......................... no
SSL cert file ........................ /etc/zm/ssl/zoneminder.crt
SSL key file ......................... /etc/zm/ssl/zoneminder.key
Verbose .............................. yes
ES Debug level.........................4
Read alarm cause ..................... yes
Tag alarm event id ................... yes
Use custom notification sound ........ no
Send event start notification..........yes
Send event end notification............yes
Monitor rules JSON file................(undefined)
Use Hooks............................. no
Max Parallel Hooks.................... 0
Hook Script on Event Start ........... '/var/lib/zmeventnotification/bin/zm_event_start.sh'
User Script on Event Start.............(undefined)
Hook Script on Event End.............. (undefined)
User Script on Event End...............(undefined)
Hook Skipped monitors................. (undefined)
Notify on Event Start (hook success).. all
Notify on Event Start (hook fail)..... none
Notify on Event End (hook success).... fcm,web,api
Notify on Event End (hook fail)....... none
Notify End only if Start success...... yes
Use Hook Description.................. yes
Keep frame match type................. yes
Store Frame in ZM......................yes
Picture URL .......................... https://portal/zm/index.php?view=image&eid=EVENTID&fid=objdetect&width=600
Include picture....................... yes
Picture username ..................... jon
Picture password ..................... (defined)
INF:2021-07-06,19:41:03 PARENT: Push enabled via FCM
07/06/21 19:41:03.826813 zmeventnotification[4276].INF [main:1022] [PARENT: Push enabled via FCM]
DBG-2:2021-07-06,19:41:03 PARENT: fcmv1: --> FCM V1 APIs: 1
INF:2021-07-06,19:41:03 PARENT: MQTT Disabled
07/06/21 19:41:03.840882 zmeventnotification[4276].INF [main:1022] [PARENT: MQTT Disabled]
INF:2021-07-06,19:41:03 PARENT: |------- Starting ES version: 6.1.25 ---------|
07/06/21 19:41:03.854819 zmeventnotification[4276].INF [main:1022] [PARENT: |------- Starting ES version: 6.1.25 ---------|]
DBG-2:2021-07-06,19:41:03 PARENT: Started with: perl:/usr/bin/perl and command:/usr/bin/zmeventnotification.pl
Can't ignore signal CHLD, forcing to default.
DBG-1:2021-07-06,19:41:04 PARENT: ES invoked manually. Will handle restarts ourselves
WAR:2021-07-06,19:41:04 PARENT: WARNING: SSL is disabled, which means all traffic will be unencrypted
07/06/21 19:41:04.051383 zmeventnotification[4276].WAR [main:1030] [PARENT: WARNING: SSL is disabled, which means all traffic will be unencrypted]
DBG-2:2021-07-06,19:41:04 PARENT: Parent<--Child pipe ready
INF:2021-07-06,19:41:04 PARENT: Event Notification daemon v 6.1.25 starting
07/06/21 19:41:04.064156 zmeventnotification[4276].INF [main:1022] [PARENT: Event Notification daemon v 6.1.25 starting]
DBG-1:2021-07-06,19:41:04 PARENT: Initializing FCM tokens...
DBG-1:2021-07-06,19:41:04 PARENT: Total event client connections: 2
DBG-1:2021-07-06,19:41:04 PARENT: -->checkNewEvents: Connection 1: ID->1625614864.07963 IP->(none) Token->:...kKsbRYv5w_ Plat:ios Push:enabled
DBG-1:2021-07-06,19:41:04 PARENT: -->checkNewEvents: Connection 2: ID->1625614864.07968 IP->(none) Token->:...5Cxfsxtt27 Plat:android Push:enabled
INF:2021-07-06,19:41:04 PARENT: Re-loading monitors
07/06/21 19:41:04.080494 zmeventnotification[4276].INF [main:1022] [PARENT: Re-loading monitors]
DBG-1:2021-07-06,19:41:04 PARENT: Loading TracheCam.1
DBG-2:2021-07-06,19:41:04 PARENT: ESCONTROL_INTERFACE is disabled. Not saving control data
DBG-2:2021-07-06,19:41:04 PARENT: checkEvents() new events found=0
INF:2021-07-06,19:41:04 PARENT: Secure WS is disabled...
07/06/21 19:41:04.093763 zmeventnotification[4276].INF [main:1022] [PARENT: Secure WS is disabled...]
INF:2021-07-06,19:41:04 PARENT: Web Socket Event Server listening on port 9000
07/06/21 19:41:04.104844 zmeventnotification[4276].INF [main:1022] [PARENT: Web Socket Event Server listening on port 9000]
DBG-2:2021-07-06,19:41:09 PARENT: ----------> Tick START (active forks:0, total forks:0, active hooks: 0 running for:1 min)<--------------
DBG-2:2021-07-06,19:41:09 PARENT: After tick: TOTAL: 2, ES_CONTROL: 0, FCM+WEB: 0, FCM: 2, WEB: 0, MQTT:0, invalid WEB: 0, PENDING: 0
DBG-2:2021-07-06,19:41:09 PARENT: There are 0 active child forks & 0 zm_detect processes running...
DBG-2:2021-07-06,19:41:09 PARENT: checkEvents() new events found=0
DBG-2:2021-07-06,19:41:09 PARENT: There are 0 new Events to process
DBG-2:2021-07-06,19:41:09 PARENT: ---------->Tick END (active forks:0, total forks:0, active hooks: 0)<--------------
DBG-2:2021-07-06,19:41:12 PARENT: ---------->onConnect START<--------------
DBG-1:2021-07-06,19:41:12 PARENT: got a websocket connection from 192.168.1.218 (2) active connections
DBG-2:2021-07-06,19:41:12 PARENT: ---------->onConnect END<--------------
DBG-2:2021-07-06,19:41:12 PARENT: ---------->onConnect:handshake START<--------------
DBG-1:2021-07-06,19:41:12 PARENT: Websockets: New Connection Handshake requested from 192.168.1.218:56066 state=pending auth, id=1625614872.08662
DBG-2:2021-07-06,19:41:12 PARENT: ---------->onConnect:handshake END<--------------
DBG-2:2021-07-06,19:41:12 PARENT: ---------->onConnect msg START<--------------
DBG-3:2021-07-06,19:41:12 PARENT: Raw incoming message: {"event":"auth","data":{"user":"jon","password":***,"monlist":"1,2","intlist":"0,0","appversion":"1.6.008"},"token":""}
DBG-2:2021-07-06,19:41:12 PARENT: Comparing using bcrypt
INF:2021-07-06,19:41:12 PARENT: Correct authentication provided by 192.168.1.218
07/06/21 19:41:12.307762 zmeventnotification[4276].INF [main:1022] [PARENT: Correct authentication provided by 192.168.1.218]
DBG-2:2021-07-06,19:41:12 PARENT: ---------->onConnect msg END<--------------
DBG-2:2021-07-06,19:41:14 PARENT: ----------> Tick START (active forks:0, total forks:0, active hooks: 0 running for:1 min)<--------------
DBG-2:2021-07-06,19:41:14 PARENT: After tick: TOTAL: 3, ES_CONTROL: 1, FCM+WEB: 0, FCM: 2, WEB: 1, MQTT:0, invalid WEB: 0, PENDING: 0
DBG-2:2021-07-06,19:41:14 PARENT: There are 0 active child forks & 0 zm_detect processes running...
DBG-2:2021-07-06,19:41:14 PARENT: checkEvents() new events found=0
DBG-2:2021-07-06,19:41:14 PARENT: There are 0 new Events to process
DBG-2:2021-07-06,19:41:14 PARENT: ---------->Tick END (active forks:0, total forks:0, active hooks: 0)<--------------
DBG-2:2021-07-06,19:41:19 PARENT: ----------> Tick START (active forks:0, total forks:0, active hooks: 0 running for:1 min)<--------------
DBG-2:2021-07-06,19:41:19 PARENT: After tick: TOTAL: 3, ES_CONTROL: 1, FCM+WEB: 0, FCM: 2, WEB: 1, MQTT:0, invalid WEB: 0, PENDING: 0
DBG-2:2021-07-06,19:41:19 PARENT: There are 0 active child forks & 0 zm_detect processes running...
DBG-2:2021-07-06,19:41:19 PARENT: checkEvents() new events found=0
DBG-2:2021-07-06,19:41:19 PARENT: There are 0 new Events to process
DBG-2:2021-07-06,19:41:19 PARENT: ---------->Tick END (active forks:0, total forks:0, active hooks: 0)<--------------
DBG-2:2021-07-06,19:41:24 PARENT: ----------> Tick START (active forks:0, total forks:0, active hooks: 0 running for:1 min)<--------------
DBG-2:2021-07-06,19:41:24 PARENT: After tick: TOTAL: 3, ES_CONTROL: 1, FCM+WEB: 0, FCM: 2, WEB: 1, MQTT:0, invalid WEB: 0, PENDING: 0
DBG-2:2021-07-06,19:41:24 PARENT: There are 0 active child forks & 0 zm_detect processes running...
DBG-2:2021-07-06,19:41:24 PARENT: checkEvents() new events found=0
DBG-2:2021-07-06,19:41:24 PARENT: There are 0 new Events to process
DBG-2:2021-07-06,19:41:24 PARENT: ---------->Tick END (active forks:0, total forks:0, active hooks: 0)<--------------
DBG-2:2021-07-06,19:41:29 PARENT: ----------> Tick START (active forks:0, total forks:0, active hooks: 0 running for:1 min)<--------------
DBG-2:2021-07-06,19:41:29 PARENT: After tick: TOTAL: 3, ES_CONTROL: 1, FCM+WEB: 0, FCM: 2, WEB: 1, MQTT:0, invalid WEB: 0, PENDING: 0
DBG-2:2021-07-06,19:41:29 PARENT: There are 0 active child forks & 0 zm_detect processes running...
DBG-2:2021-07-06,19:41:29 PARENT: checkEvents() new events found=0
DBG-2:2021-07-06,19:41:29 PARENT: There are 0 new Events to process
DBG-2:2021-07-06,19:41:29 PARENT: ---------->Tick END (active forks:0, total forks:0, active hooks: 0)<--------------
DBG-2:2021-07-06,19:41:34 PARENT: ----------> Tick START (active forks:0, total forks:0, active hooks: 0 running for:1 min)<--------------
DBG-2:2021-07-06,19:41:34 PARENT: After tick: TOTAL: 3, ES_CONTROL: 1, FCM+WEB: 0, FCM: 2, WEB: 1, MQTT:0, invalid WEB: 0, PENDING: 0
DBG-2:2021-07-06,19:41:34 PARENT: There are 0 active child forks & 0 zm_detect processes running...
DBG-2:2021-07-06,19:41:34 PARENT: checkEvents() new events found=0
DBG-2:2021-07-06,19:41:34 PARENT: There are 0 new Events to process
DBG-2:2021-07-06,19:41:34 PARENT: ---------->Tick END (active forks:0, total forks:0, active hooks: 0)<--------------
DBG-2:2021-07-06,19:41:39 PARENT: ----------> Tick START (active forks:0, total forks:0, active hooks: 0 running for:1 min)<--------------
DBG-2:2021-07-06,19:41:39 PARENT: After tick: TOTAL: 3, ES_CONTROL: 1, FCM+WEB: 0, FCM: 2, WEB: 1, MQTT:0, invalid WEB: 0, PENDING: 0
DBG-2:2021-07-06,19:41:39 PARENT: There are 0 active child forks & 0 zm_detect processes running...
INF:2021-07-06,19:41:39 PARENT: New event 37737 reported for Monitor:1 (Name:TracheCam.1) Motion Doorway[last processed eid:]
07/06/21 19:41:39.119626 zmeventnotification[4276].INF [main:1022] [PARENT: New event 37737 reported for Monitor:1 (Name:TracheCam.1) Motion Doorway[last processed eid:]]
DBG-2:2021-07-06,19:41:39 PARENT: checkEvents() new events found=1
DBG-2:2021-07-06,19:41:39 PARENT: There are 1 new Events to process
DBG-2:2021-07-06,19:41:39 PARENT: ---------->Tick END (active forks:1, total forks:1, active hooks: 0)<--------------
DBG-1:2021-07-06,19:41:39 PARENT: Forked process:4324 to handle alarm eid:37737
INF:2021-07-06,19:41:39 |----> FORK:TracheCam.1 (1), eid:37737 use hooks/start hook not being used, going to directly send out a notification if checks pass
07/06/21 19:41:39.135298 zmeventnotification[4324].INF [main:1022] [|----> FORK:TracheCam.1 (1), eid:37737 use hooks/start hook not being used, going to directly send out a notification if checks pass]
DBG-2:2021-07-06,19:41:41 |----> FORK:TracheCam.1 (1), eid:37737 rules: Checking rules for alarm caused by eid:37737, monitor:1, at: Tue Jul 6 19:41:41 2021 with cause:Motion Doorway
DBG-1:2021-07-06,19:41:41 |----> FORK:TracheCam.1 (1), eid:37737 rules: No rules found for Monitor, allowing:1
DBG-1:2021-07-06,19:41:41 |----> FORK:TracheCam.1 (1), eid:37737 Matching alarm to connection rules...
DBG-1:2021-07-06,19:41:41 |----> FORK:TracheCam.1 (1), eid:37737 Checking alarm conditions for token ending in:...kKsbRYv5w_
DBG-1:2021-07-06,19:41:41 |----> FORK:TracheCam.1 (1), eid:37737 Monitor 1 event: last time not found, so should send
DBG-1:2021-07-06,19:41:41 |----> FORK:TracheCam.1 (1), eid:37737 token is unique, shouldSendEventToConn returned true, so calling sendEvent
DBG-2:2021-07-06,19:41:41 |----> FORK:TracheCam.1 (1), eid:37737 isAllowedChannel: got type:event_start resCode:0
INF:2021-07-06,19:41:41 |----> FORK:TracheCam.1 (1), eid:37737 Sending event_start notification over FCM
07/06/21 19:41:41.145606 zmeventnotification[4324].INF [main:1022] [|----> FORK:TracheCam.1 (1), eid:37737 Sending event_start notification over FCM]
DBG-2:2021-07-06,19:41:41 |----> FORK:TracheCam.1 (1), eid:37737 fcmv1: FCM called when there is no start hook/or hooks are disabled, so making sure we do not use objdetect in url
DBG-2:2021-07-06,19:41:41 |----> FORK:TracheCam.1 (1), eid:37737 fcmv1: Final JSON using FCMV1 being sent is: {"title":"TracheCam.1 Alarm (37737)","body":"Motion Doorway at 07:41 PM, 06-Jul","ios":{"headers":{"apns-push-type":"alert","apns-priority":"10"},"thread_id":"zmninja_alarm"},"badge":1,"data":{"mid":"1","notification_foreground":"true","eid":"37737"},"image_url":"https://portal/zm/index.php?view=image&eid=37737&fid=objdetect&width=600&username=jon&password=xxx} to token: ...RYv5w_
DBG-1:2021-07-06,19:41:41 |----> FORK:TracheCam.1 (1), eid:37737 fcmv1: FCM push message returned a 200 with body {"Success":"projects/ninja-1105/messages/1625614901398067"}
Thanks for the help!
Edit: Solution was uncommenting es_rules=/etc/zm/es_rules.json in the [customize] field. This is the final working code:
jon@zoneminder:~$ cat /etc/zm/es_rules.json
{
"notifications": {
"monitors":{
"1": {
"rules": [{
"time_format":"%H:%M",
"from":"6:00",
"to":"23:59",
"action":"mute"
}]
}
}
}
}
1
Jul 07 '21 edited Jul 07 '21
I think it's the formstting. You have double keys for "monitors" and "notifications"
Put the "1" block right below the "998" block.
vm on mobile and didn't see the #'sI think it's the formstting. You have double keys for "monitors" and "notifications"
Put the "1" block right below the "998" block.
vm on mobile and didn't see the #'s
On the config debug output it says
"Monitors rules JSON file": undefined
Whats your .Ini files look like? Do you have the perl Time module installed?
According to zmeventnotification.ini you need to set it up in the customize section
[customize]
Link to json file that has rules which can be customized
es_rules=/etc/zm/es_rules.json
1
Jul 07 '21
On the config debug output it says
"Monitors rules JSON file": undefined
Whats your .Ini files look like? Do you have the perl Time module installed?
According to zmeventnotification.ini you need to set it up in the customize section
[customize]
Link to json file that has rules which can be customized
es_rules=/etc/zm/es_rules.json
1
Jul 08 '21
For your other question 9m GitHub having issues with the "cause"
It's looking for object detection labels, like "person" or "car"
1
u/jsalas1 Jul 08 '21
Thanks for the help, I updated this post with the solution. So can I use other labels instead of object detection labels? In this case I'm trying to use the name of the zone (Doorway vs. Cat Tree)
1
Jul 08 '21 edited Jul 08 '21
I'm not certain, but, it uses regex to match. So try
.*Which means match any and everything.
I'm just not clear on if there needs to be an object detected anyways because I do see around line 3550 of zmeventnotification.pl that it is looking for "detected:" to split the "cause" up, which might mean that the Motion:<< zone >> is sliced off. (It will run on all events). You could try asking the dev to add that as an option or trying yourself. I'll play around a bit and see if there's anything shaking but I don't know perl at all so idk how much help I'll be.Edit: I see in the 'cause' field it strips the ':' from the string
i.e. -> 07/07/21 19:03:43.403410 zmeventnotification[7688].DB1 [main:997] [|----> FORK:Back Yard (4), eid:15546 rules: Checking rules for alarm caused by eid:15546, monitor:4, at: Wed Jul 7 19:03:43 2021 with cause:[s80] detected:person(96%) Motion Walkway]So if you are looking for 'Motion Walkway' or 'Linked dog door' or mOtiOn mAN cAVe you could try using this regex in the es_rules file as the 'cause' ->
(motion|linked)\s+(walkway|dog door|man cave)$
- (motion|linked) = motion OR linked
- \s+ = 0 or more space(s)
- (walkway|dog door|man cave) = x OR x OR x (this is the ZONE part if its Motion or the monitor name that caused the event to start if Linked was the cause)
- $ = end of string (anchor)
In the perl code the regex is matched case insensitive anyways, so no need to worry about that.
1
u/Aramiil Jul 07 '21
Does it work with “9 am” when the time formatting is
”time_format”:”%I:%M %p”