Closed Jsalas424 closed 3 years ago
Cross-posted to Reddit: https://www.reddit.com/r/ZoneMinder/comments/of7al4/need_help_configuring_rules_for_zm_event/
Your config output says:
Monitor rules JSON file................(undefined)
You need to make sure your zmeventnotification.ini points to the right rules file
It is pointing to the correct rules file
jon@zoneminder:~$ cat /etc/zm/zmeventnotification.ini | grep -i rules
# Link to json file that has rules which can be customized
es_rules=/etc/zm/es_rules.json
jon@zoneminder:~$ 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 log:
jon@zoneminder:~$ sudo -u www-data /usr/bin/zmeventnotification.pl --debug
07/07/21 18:23:58.241991 zmeventnotification[9550].INF [main:331] [Running on WebSocket library version:0.004]
INF:2021-07-07,18:23:58 PARENT: using config file: /etc/zm/zmeventnotification.ini
07/07/21 18:23:58.378781 zmeventnotification[9550].INF [main:1022] [PARENT: using config file: /etc/zm/zmeventnotification.ini]
INF:2021-07-07,18:23:58 PARENT: using secrets file: /etc/zm/secrets.ini
07/07/21 18:23:58.408279 zmeventnotification[9550].INF [main:1022] [PARENT: using secrets file: /etc/zm/secrets.ini]
DBG-2:2021-07-07,18:23:58 PARENT: Got secret token !ZMES_PICTURE_URL
DBG-2:2021-07-07,18:23:58 PARENT: Got secret token !ZM_USER
DBG-2:2021-07-07,18:23:58 PARENT: Got secret token !ZM_PASSWORD
DBG-2:2021-07-07,18:23:58 PARENT: rules: Loading es rules json: /etc/zm/es_rules.json
ERR:2021-07-07,18:23:58 PARENT: rules: Failed decoding es rules: malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "#{\n# "notificati...") at /usr/bin/zmeventnotification.pl line 654, <$fh> line 1.
07/07/21 18:23:58.426380 zmeventnotification[9550].ERR [main:1038] [PARENT: rules: Failed decoding es rules: malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "#{\n# "notificati...") at /usr/bin/zmeventnotification.pl line 654, <$fh> line 1.]
DBG-2:2021-07-07,18:23:58 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................/etc/zm/es_rules.json
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-07,18:23:58 PARENT: Push enabled via FCM
07/07/21 18:23:58.822234 zmeventnotification[9550].INF [main:1022] [PARENT: Push enabled via FCM]
DBG-2:2021-07-07,18:23:58 PARENT: fcmv1: --> FCM V1 APIs: 1
INF:2021-07-07,18:23:58 PARENT: MQTT Disabled
07/07/21 18:23:58.834024 zmeventnotification[9550].INF [main:1022] [PARENT: MQTT Disabled]
INF:2021-07-07,18:23:58 PARENT: |------- Starting ES version: 6.1.25 ---------|
07/07/21 18:23:58.843571 zmeventnotification[9550].INF [main:1022] [PARENT: |------- Starting ES version: 6.1.25 ---------|]
DBG-2:2021-07-07,18:23:58 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-07,18:23:59 PARENT: ES invoked manually. Will handle restarts ourselves
WAR:2021-07-07,18:23:59 PARENT: WARNING: SSL is disabled, which means all traffic will be unencrypted
07/07/21 18:23:59.177864 zmeventnotification[9550].WAR [main:1030] [PARENT: WARNING: SSL is disabled, which means all traffic will be unencrypted]
DBG-2:2021-07-07,18:23:59 PARENT: Parent<--Child pipe ready
INF:2021-07-07,18:23:59 PARENT: Event Notification daemon v 6.1.25 starting
07/07/21 18:23:59.189049 zmeventnotification[9550].INF [main:1022] [PARENT: Event Notification daemon v 6.1.25 starting]
DBG-1:2021-07-07,18:23:59 PARENT: Initializing FCM tokens...
DBG-1:2021-07-07,18:23:59 PARENT: Total event client connections: 2
DBG-1:2021-07-07,18:23:59 PARENT: -->checkNewEvents: Connection 1: ID->1625696639.20137 IP->(none) Token->:...5Cxfsxtt27 Plat:android Push:enabled
DBG-1:2021-07-07,18:23:59 PARENT: -->checkNewEvents: Connection 2: ID->1625696639.20146 IP->(none) Token->:...kKsbRYv5w_ Plat:ios Push:enabled
INF:2021-07-07,18:23:59 PARENT: Re-loading monitors
07/07/21 18:23:59.202778 zmeventnotification[9550].INF [main:1022] [PARENT: Re-loading monitors]
DBG-1:2021-07-07,18:23:59 PARENT: Loading TracheCam.1
DBG-2:2021-07-07,18:23:59 PARENT: ESCONTROL_INTERFACE is disabled. Not saving control data
DBG-2:2021-07-07,18:23:59 PARENT: checkEvents() new events found=0
INF:2021-07-07,18:23:59 PARENT: Secure WS is disabled...
07/07/21 18:23:59.216329 zmeventnotification[9550].INF [main:1022] [PARENT: Secure WS is disabled...]
INF:2021-07-07,18:23:59 PARENT: Web Socket Event Server listening on port 9000
07/07/21 18:23:59.225602 zmeventnotification[9550].INF [main:1022] [PARENT: Web Socket Event Server listening on port 9000]
DBG-2:2021-07-07,18:24:04 PARENT: ----------> Tick START (active forks:0, total forks:0, active hooks: 0 running for:1 min)<--------------
DBG-2:2021-07-07,18:24:04 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-07,18:24:04 PARENT: There are 0 active child forks & 0 zm_detect processes running...
DBG-2:2021-07-07,18:24:04 PARENT: checkEvents() new events found=0
DBG-2:2021-07-07,18:24:04 PARENT: There are 0 new Events to process
DBG-2:2021-07-07,18:24:04 PARENT: ---------->Tick END (active forks:0, total forks:0, active hooks: 0)<--------------
DBG-2:2021-07-07,18:24:09 PARENT: ----------> Tick START (active forks:0, total forks:0, active hooks: 0 running for:1 min)<--------------
DBG-2:2021-07-07,18:24: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-07,18:24:09 PARENT: There are 0 active child forks & 0 zm_detect processes running...
DBG-2:2021-07-07,18:24:09 PARENT: checkEvents() new events found=0
DBG-2:2021-07-07,18:24:09 PARENT: There are 0 new Events to process
DBG-2:2021-07-07,18:24:09 PARENT: ---------->Tick END (active forks:0, total forks:0, active hooks: 0)<--------------
DBG-2:2021-07-07,18:24:14 PARENT: ----------> Tick START (active forks:0, total forks:0, active hooks: 0 running for:1 min)<--------------
DBG-2:2021-07-07,18:24:14 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-07,18:24:14 PARENT: There are 0 active child forks & 0 zm_detect processes running...
DBG-2:2021-07-07,18:24:14 PARENT: checkEvents() new events found=0
DBG-2:2021-07-07,18:24:14 PARENT: There are 0 new Events to process
DBG-2:2021-07-07,18:24:14 PARENT: ---------->Tick END (active forks:0, total forks:0, active hooks: 0)<--------------
DBG-2:2021-07-07,18:24:19 PARENT: ----------> Tick START (active forks:0, total forks:0, active hooks: 0 running for:1 min)<--------------
DBG-2:2021-07-07,18:24:19 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-07,18:24:19 PARENT: There are 0 active child forks & 0 zm_detect processes running...
INF:2021-07-07,18:24:19 PARENT: New event 37878 reported for Monitor:1 (Name:TracheCam.1) Motion Cat Tree[last processed eid:]
07/07/21 18:24:19.240828 zmeventnotification[9550].INF [main:1022] [PARENT: New event 37878 reported for Monitor:1 (Name:TracheCam.1) Motion Cat Tree[last processed eid:]]
DBG-2:2021-07-07,18:24:19 PARENT: checkEvents() new events found=1
DBG-2:2021-07-07,18:24:19 PARENT: There are 1 new Events to process
DBG-2:2021-07-07,18:24:19 PARENT: ---------->Tick END (active forks:1, total forks:1, active hooks: 0)<--------------
DBG-1:2021-07-07,18:24:19 PARENT: Forked process:9555 to handle alarm eid:37878
INF:2021-07-07,18:24:19 |----> FORK:TracheCam.1 (1), eid:37878 use hooks/start hook not being used, going to directly send out a notification if checks pass
07/07/21 18:24:19.286043 zmeventnotification[9555].INF [main:1022] [|----> FORK:TracheCam.1 (1), eid:37878 use hooks/start hook not being used, going to directly send out a notification if checks pass]
^CDBG-1:2021-07-07,18:24:19 |----> FORK:TracheCam.1 (1), eid:37878
DBG-2:2021-07-07,18:24:19 |----> FORK:TracheCam.1 (1), eid:37878 rules: Checking rules for alarm caused by eid:37878, monitor:1, at: Wed Jul 7 18:24:19 2021 with cause:Motion Cat Tree
DBG-1:2021-07-07,18:24:19 |----> FORK:TracheCam.1 (1), eid:37878 rules: No rules found for Monitor, allowing:1
DBG-1:2021-07-07,18:24:19 |----> FORK:TracheCam.1 (1), eid:37878 Matching alarm to connection rules...
DBG-1:2021-07-07,18:24:19 |----> FORK:TracheCam.1 (1), eid:37878 Checking alarm conditions for token ending in:...5Cxfsxtt27
Well, it wasn't before and now it is. Your error is different now
ERR:2021-07-07,18:23:58 PARENT: rules: Failed decoding es rules: malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "#{\n# "notificati...") at /usr/bin/zmeventnotification.pl line 654, <$fh> line 1.
07/07/21 18:23:58.426380 zmeventnotification[9550].ERR [main:1038] [PARENT: rules: Failed decoding es rules: malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "#{\n# "notificati...") at /usr/bin/zmeventnotification.pl line 654, <$fh> line 1.]
DBG-2:2021-07-07,18:23:58 PARENT: config string substitution: {{base_data_path}} is '/var/lib/zmeventnotification'
Configuration (read /etc/zm/zmeventnotification.ini):
Seems like a format error in your rules, which is probably because you've added #s to the json file. # is not a valid JSON character. you need to remove them.
Well, it wasn't before and now it is. Your error is different now
ERR:2021-07-07,18:23:58 PARENT: rules: Failed decoding es rules: malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "#{\n# "notificati...") at /usr/bin/zmeventnotification.pl line 654, <$fh> line 1. 07/07/21 18:23:58.426380 zmeventnotification[9550].ERR [main:1038] [PARENT: rules: Failed decoding es rules: malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "#{\n# "notificati...") at /usr/bin/zmeventnotification.pl line 654, <$fh> line 1.] DBG-2:2021-07-07,18:23:58 PARENT: config string substitution: {{base_data_path}} is '/var/lib/zmeventnotification' Configuration (read /etc/zm/zmeventnotification.ini):
Seems like a format error in your rules, which is probably because you've added #s to the json file. # is not a valid JSON character. you need to remove them.
Thank you so much for the help! I'm posting my final working config. I'm struggling with the the "cause_has" field but I'll open a seperate issue.
jon@zoneminder:~$ cat /etc/zm/es_rules.json
{
"notifications": {
"monitors":{
"1": {
"rules": [{
"time_format":"%H:%M",
"from":"6:00",
"to":"23:59",
"action":"mute"
}]
}
}
}
}
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
Debug logs:
Thanks!