Closed philwild closed 6 years ago
I am going to attempt to use your code to interface with my alarm system. About to purchase the module. Can you tell me as I have not been able to figure this out looking through the code. Is it possible for the server module to log alarm events to a file. I'm very keen on tracking motion sensor activity and want to log the time a sensor detects movement when the alarm is either on or off. Is that possible with what you have built?
Yep, it’s possible. There’s nothing currently in place to provide a very human-readable log file, but it would be easy to add. However, there is at least the “events” command on the client, which dumps JSON in realtime, which could be saved to a log and run continuously. The output for a zone looks like this:
{'timestamp': '2017-10-30T06:02:30.174649', 'zone': 9, 'zone_flags': ['Faulted', 'Inhibit'], 'zone_state': True, 'type': 'zone_status'} {'timestamp': '2017-10-30T06:02:30.778415', 'zone': 9, 'zone_flags': ['Inhibit'], 'zone_state': False, 'type': 'zone_status'} {'timestamp': '2017-10-30T06:02:47.958422', 'zone': 9, 'zone_flags': ['Faulted', 'Inhibit'], 'zone_state': True, 'type': 'zone_status’} {'timestamp': '2017-10-30T06:02:49.169845', 'zone': 9, 'zone_flags': ['Inhibit'], 'zone_state': False, 'type': 'zone_status'}
That is zone 9 being faulted due to a motion sensor twice about 17 seconds apart.
To tell if the alarm is on or off you’d need to capture those events and store your own state. They look like:
{'type': 'partition', 'timestamp': '2017-10-30T06:17:00.506059', 'partition_flags_asserted': ['Keyswitch armed', 'Valid PIN accepted'], 'partition': 1, 'partition_flags': ['Sensor low battery', 'Ready to arm', 'Valid PIN accepted', 'Cancel report is in the stack', 'Keyswitch armed', 'Delay trip in progress (common zone)'], 'partition_is_armed': False, 'partition_was_armed': True}
The last two keys there show that partition 1 “was armed” and is now “not armed”.
Are you just looking for a human-readable audit log, or something consumable by a script? If so, the event stream that the client can generate continuously is what you want (unless you’re writing python), as it just provides JSON events one per line as they happen.
—Dan
Thanks Dan! Excellent. That will work nicely. I want to get the data into splunk so I can start setting up some rules (e.g. garage door open/close, then no activity in house for 30 minutes plus a phone no longer visible on the wifi network = high probability that someone left the house and forgot to turn the alarm on = send message. If I can set it up to log to a file, then I'll just get splunk to monitor that file and index the events as they are written. I'm already getting (dis)arm state changes through a comnav IP interface board on the panel but it does not report on zone activity when in an unarmed state.
Thanks heaps!
Hi Dan, I am going to attempt to use your code to interface with my alarm system. About to purchase the module. Can you tell me as I have not been able to figure this out looking through the code. Is it possible for the server module to log alarm events to a file. I'm very keen on tracking motion sensor activity and want to log the time a sensor detects movement when the alarm is either on or off. Is that possible with what you have built? Many thanks Phil