kk7ds / pynx584

Python library and server for talking to NX584/NX8E interfaces
GNU General Public License v3.0
29 stars 26 forks source link

Log event feature is not reporting the correct zone number #26

Closed philwild closed 2 years ago

philwild commented 6 years ago

I'm using the email alerting feature and have noticed that there is a discrepancy in zone number between what the alarm system knows and what is being reported. See logs below.

Aug 20 08:35:47 raspberrypi nx584-event[21388]: {'type': 'zone_status', 'timestamp': '2018-08-20T08:35:47.429511', 'zone': 7, 'zone_state': False, 'zone_flags': ['Inhibit']}

Followed by

Aug 20 08:36:52 raspberrypi nx584-event[21388]: {'type': 'log', 'event': 'Zone 6 Bypass', 'timestamp': '2018-08-20T08:36:00'}

Notice that zone 7 is placed in bypass mode, yet the log message is reporting zone 6. The same issue occurs with notification of alarms. The email logged event for an alarm event is reported on the actual zone - 1. (i.e. zone-1 is reported as zone-0, zone-2 as zone-1, etc)

Aug 20 08:35:46 raspberrypi nx584-event[21388]: {'type': 'partition', 'timestamp': '2018-08-20T08:35:46.586849', 'partition': 1, 'partition_flags_asserted': ['Ready to arm'], 'partition_flags': ['reserved', 'Sensor low battery', 'Ready to arm', 'Open period', 'Delay trip in progress (common zone)'], 'partition_was_armed': False, 'partition_is_armed': False}
--
Aug 20 08:35:47 raspberrypi nx584-event[21388]: {'type': 'zone_status', 'timestamp': '2018-08-20T08:35:47.019027', 'zone': 7, 'zone_state': True, 'zone_flags': ['Faulted', 'Inhibit']}
Aug 20 08:35:47 raspberrypi nx584-event[21388]: {'type': 'zone_status', 'timestamp': '2018-08-20T08:35:47.429511', 'zone': 7, 'zone_state': False, 'zone_flags': ['Inhibit']}
Aug 20 08:35:47 raspberrypi nx584-event[21388]: {'type': 'partition', 'timestamp': '2018-08-20T08:35:47.816456', 'partition': 1, 'partition_flags_asserted': ['Cancel report is in the stack'], 'partition_flags': ['reserved', 'Sensor low battery', 'Ready to arm', 'Open period', 'Cancel report is in the stack', 'Delay trip in progress (common zone)'], 'partition_was_armed': False, 'partition_is_armed': False}
Aug 20 08:35:50 raspberrypi nx584-event[21388]: {'type': 'partition', 'timestamp': '2018-08-20T08:35:50.073721', 'partition': 1, 'partition_flags_asserted': ['Exit 2', 'Exit 1', 'Armed'], 'partition_flags': ['reserved', 'Armed', 'Exit 1', 'Exit 2', 'Sensor low battery', 'Ready to arm', 'Open period', 'Cancel report is in the stack', 'Delay trip in progress (common zone)'], 'partition_was_armed': False, 'partition_is_armed': True}
Aug 20 08:35:53 raspberrypi nx584-event[21388]: {'type': 'partition', 'timestamp': '2018-08-20T08:35:53.657292', 'partition': 1, 'partition_flags_asserted': [], 'partition_flags': ['reserved', 'Armed', 'Exit 1', 'Exit 2', 'Sensor low battery', 'Open period', 'Cancel report is in the stack', 'Delay trip in progress (common zone)'], 'partition_was_armed': True, 'partition_is_armed': True}
Aug 20 08:35:54 raspberrypi nx584-event[21388]: {'type': 'zone_status', 'timestamp': '2018-08-20T08:35:54.027926', 'zone': 8, 'zone_state': True, 'zone_flags': ['Faulted']}
Aug 20 08:36:08 raspberrypi nx584-event[21388]: {'type': 'zone_status', 'timestamp': '2018-08-20T08:36:08.178169', 'zone': 8, 'zone_state': False, 'zone_flags': []}
Aug 20 08:36:08 raspberrypi nx584-event[21388]: {'type': 'partition', 'timestamp': '2018-08-20T08:36:08.566532', 'partition': 1, 'partition_flags_asserted': ['Ready to arm'], 'partition_flags': ['reserved', 'Armed', 'Exit 1', 'Exit 2', 'Sensor low battery', 'Ready to arm', 'Open period', 'Cancel report is in the stack', 'Delay trip in progress (common zone)'], 'partition_was_armed': True, 'partition_is_armed': True}
Aug 20 08:36:38 raspberrypi nx584-event[21388]: {'type': 'partition', 'timestamp': '2018-08-20T08:36:38.068252', 'partition': 1, 'partition_flags_asserted': ['Delay expiration warning'], 'partition_flags': ['reserved', 'Armed', 'Delay expiration warning', 'Exit 1', 'Exit 2', 'Sensor low battery', 'Ready to arm', 'Open period', 'Cancel report is in the stack', 'Delay trip in progress (common zone)'], 'partition_was_armed': True, 'partition_is_armed': True}
Aug 20 08:36:50 raspberrypi nx584-event[21388]: {'type': 'partition', 'timestamp': '2018-08-20T08:36:49.890927', 'partition': 1, 'partition_flags_asserted': ['Recent closing being timed', 'Tone on (activation tone)'], 'partition_flags': ['reserved', 'Armed', 'Recent closing being timed', 'Sensor low battery', 'Ready to arm', 'Tone on (activation tone)', 'Open period', 'Cancel report is in the stack', 'Delay trip in progress (common zone)'], 'partition_was_armed': True, 'partition_is_armed': True}
Aug 20 08:36:50 raspberrypi nx584-event[21388]: {'type': 'log', 'event': 'User 97 Last to close', 'timestamp': '2018-08-20T08:36:00'}
Aug 20 08:36:51 raspberrypi nx584-event[21388]: {'type': 'partition', 'timestamp': '2018-08-20T08:36:51.378517', 'partition': 1, 'partition_flags_asserted': [], 'partition_flags': ['reserved', 'Armed', 'Recent closing being timed', 'Sensor low battery', 'Ready to arm', 'Open period', 'Cancel report is in the stack', 'Delay trip in progress (common zone)'], 'partition_was_armed': True, 'partition_is_armed': True}
Aug 20 08:36:52 raspberrypi nx584-event[21388]: {'type': 'log', 'event': 'User 97 Closing', 'timestamp': '2018-08-20T08:36:00'}
Aug 20 08:36:52 raspberrypi nx584-event[21388]: {'type': 'log', 'event': 'Zone 6 Bypass', 'timestamp': '2018-08-20T08:36:00'}
kk7ds commented 2 years ago

Okay I think this is because this line:

https://github.com/kk7ds/pynx584/blob/master/nx584/controller.py#L726

Should be +1'd, like we do here:

https://github.com/kk7ds/pynx584/blob/master/nx584/controller.py#L543

If I push a PR are you able to test this years-later before I push a release?

philwild commented 2 years ago

I can try and do this later this week. However, you've closed this so I assume you've probably tested yourself? Cheers

kk7ds commented 2 years ago

Yeah, sorry I should have commented. I was able to see locally that my events were out of sync as well and had never noticed it. So, fix is merged and I released 0.8.1 with it.

Thanks!