From 41953c5f361152733cf2ef390ef755b869ba272d Mon Sep 17 00:00:00 2001 From: mattsaxon Date: Fri, 11 Mar 2022 08:50:29 +0000 Subject: [PATCH 1/6] More message tidies --- custom_components/jablotron80/jablotron.py | 40 +++++++++++----------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/custom_components/jablotron80/jablotron.py b/custom_components/jablotron80/jablotron.py index 76f546a..c9315f4 100644 --- a/custom_components/jablotron80/jablotron.py +++ b/custom_components/jablotron80/jablotron.py @@ -1575,19 +1575,24 @@ def _process_event(self, data: bytearray, packet_data: str) -> None: warn = False # by defalt we will log an info message, but for important items we will install warn source = data[6] # codes 40 master code, 41 - 50 codes 1-10 + + # alarm or doorm open?, source = device id + # 0x01 motion? + # 0x02 door/natural + # 0x03 fire alarm + # can source be also code? Now assuming it is device. + # logic for codes and devices? devices in range hex 01 - ??, codes in 40 - if event_type == 0x01: - event_name = "PIR Activated" - # can source be also code? Now assuming it is device. - # logic for codes and devices? devices in range hex 01 - ??, codes in 40 - + event_name = "Sensor (1) Activated" self._activate_source(source) elif event_type == 0x02: - event_name = "Door Activated" + event_name = "Sensor (2) Activated" self._activate_source(source) elif event_type == 0x03: - event_name = "Fire Alarm Activated" + event_name = "Sensor (3) Activated" self._activate_source(source) elif event_type == 0x04: - event_name = "Sensor Activated" + event_name = "Sensor (4) Activated" self._activate_source(source) elif event_type == 0x05: event_name = "Tampering alarm" @@ -1724,8 +1729,6 @@ def _process_event(self, data: bytearray, packet_data: str) -> None: if warn: LOGGER.warn(log) - else: - LOGGER.info(log) self.central_device.last_event = log @@ -1934,6 +1937,7 @@ def _process_state(self, data: bytearray, packet_data: str) -> None: self._confirm_device_query() else: + warn = True activity_name = f'Unknown Activity:{hex(activity)}' @@ -1947,7 +1951,7 @@ def _process_state(self, data: bytearray, packet_data: str) -> None: # build the "non alert" message text out of the state and the activity text # if they are different, concatenate them so we don't lose any info # note that this is more verbose that the real Jablotron keypad messages and we may remove at some point - if not warn: + if not warn: # self.alert.value == "OK": if activity_name == state_text: state_text = message @@ -1957,21 +1961,17 @@ def _process_state(self, data: bytearray, packet_data: str) -> None: else: state_text = message - if state_text != self.statustext.message: - LOGGER.info('status: ' + state_text) - self.statustext.message = state_text - else: - LOGGER.debug('status: ' + state_text) - # log the message as an alert/alarm since the warning triangle is lit else: - if message != self.alert.message: - LOGGER.info('alert: ' + message) + if message != self.alert.message and message != '': + LOGGER.warn(message) self.alert.message = message - else: - LOGGER.debug('alert: ' + message) + + if state_text != self.statustext.message: + self.statustext.message = state_text + else: - LOGGER.debug(message) + LOGGER.debug('message: ' + message) #LOGGER.info(f'Status: {hex(status)}, {format(status, "008b")}') #LOGGER.info(f'{self}') From f4321619d2a7efa08915bc82ba9d820b7aebd67c Mon Sep 17 00:00:00 2001 From: mattsaxon Date: Sun, 13 Mar 2022 16:56:34 +0000 Subject: [PATCH 2/6] Message text updates for different alarms --- custom_components/jablotron80/jablotron.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/custom_components/jablotron80/jablotron.py b/custom_components/jablotron80/jablotron.py index c9315f4..8621958 100644 --- a/custom_components/jablotron80/jablotron.py +++ b/custom_components/jablotron80/jablotron.py @@ -1575,24 +1575,19 @@ def _process_event(self, data: bytearray, packet_data: str) -> None: warn = False # by defalt we will log an info message, but for important items we will install warn source = data[6] # codes 40 master code, 41 - 50 codes 1-10 - - # alarm or doorm open?, source = device id - # 0x01 motion? - # 0x02 door/natural - # 0x03 fire alarm # can source be also code? Now assuming it is device. # logic for codes and devices? devices in range hex 01 - ??, codes in 40 - if event_type == 0x01: - event_name = "Sensor (1) Activated" + event_name = "Instant zone Alarm" self._activate_source(source) elif event_type == 0x02: - event_name = "Sensor (2) Activated" + event_name = "Delay zone Alarm" self._activate_source(source) elif event_type == 0x03: - event_name = "Sensor (3) Activated" + event_name = "Fire zone Alarm" self._activate_source(source) elif event_type == 0x04: - event_name = "Sensor (4) Activated" + event_name = "Panic Alarm" self._activate_source(source) elif event_type == 0x05: event_name = "Tampering alarm" From 3acb6a8b9daad0d91a17ea9fb73c7c603e246264 Mon Sep 17 00:00:00 2001 From: mattsaxon Date: Sun, 13 Mar 2022 17:11:08 +0000 Subject: [PATCH 3/6] Fix "missing" alerts --- custom_components/jablotron80/jablotron.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/custom_components/jablotron80/jablotron.py b/custom_components/jablotron80/jablotron.py index 8621958..20c56d5 100644 --- a/custom_components/jablotron80/jablotron.py +++ b/custom_components/jablotron80/jablotron.py @@ -1943,11 +1943,14 @@ def _process_state(self, data: bytearray, packet_data: str) -> None: if log: - # build the "non alert" message text out of the state and the activity text - # if they are different, concatenate them so we don't lose any info - # note that this is more verbose that the real Jablotron keypad messages and we may remove at some point - if not warn: # self.alert.value == "OK": - + # This condition is complex for a couple of reasons + # Sometime a normal message needs displaying even if there is a Fault in the system, in this case the triangle is solid + # Also for some status' they can be alarms or normal, e.g. testing a system in maint mode isn't an alert + if not warn or (warn and self.alert.value == "OK"): + + # build the "non alert" message text out of the state and the activity text + # if they are different, concatenate them so we don't lose any info + # note that this is more verbose that the real Jablotron keypad messages and we may remove at some point if activity_name == state_text: state_text = message else: From 473852e893a8296e32389b7910d437dd949aa0e5 Mon Sep 17 00:00:00 2001 From: mattsaxon Date: Wed, 16 Mar 2022 07:55:51 +0000 Subject: [PATCH 4/6] Fix format error when message =='' --- custom_components/jablotron80/jablotron.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/jablotron80/jablotron.py b/custom_components/jablotron80/jablotron.py index 20c56d5..5b69dcb 100644 --- a/custom_components/jablotron80/jablotron.py +++ b/custom_components/jablotron80/jablotron.py @@ -1954,9 +1954,9 @@ def _process_state(self, data: bytearray, packet_data: str) -> None: if activity_name == state_text: state_text = message else: - if state_text != '': + if state_text != '' and message != '': state_text = state_text + ", " + message - else: + elif message != '': state_text = message # log the message as an alert/alarm since the warning triangle is lit From f5df63fc602515e4013b0c5ace34f1c15ed89d89 Mon Sep 17 00:00:00 2001 From: mattsaxon Date: Wed, 16 Mar 2022 19:34:47 +0000 Subject: [PATCH 5/6] Fault sources and clearing --- custom_components/jablotron80/jablotron.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/custom_components/jablotron80/jablotron.py b/custom_components/jablotron80/jablotron.py index 5b69dcb..0b77f84 100644 --- a/custom_components/jablotron80/jablotron.py +++ b/custom_components/jablotron80/jablotron.py @@ -1508,6 +1508,10 @@ def _clear_triggers(self) -> None: code.active = False self._active_codes.clear() + def _clear_source(self, source_id:bytes) -> None: + source = self._get_source(source_id) + source.active = False + def _clear_tampers(self) -> None: for device in self.devices: if device.tampered: @@ -1605,7 +1609,7 @@ def _process_event(self, data: bytearray, packet_data: str) -> None: elif event_type == 0x07: event_name = "Fault" warn = True - self._activate_source(source) + self._fault_source(source) elif event_type == 0x08: event_name = "Setting" code = self._get_source(source) @@ -1630,13 +1634,14 @@ def _process_event(self, data: bytearray, packet_data: str) -> None: elif event_type == 0x0e: event_name = "Lost communication" warn = True - self._activate_source(source) + self._fault_source(source) elif event_type == 0x0f: event_name = "Power fault of control panel" warn = True self._activate_source(source) elif event_type == 0x10: event_name = "Control panel power O.K." + self._clear_source(source) elif event_type == 0x11: event_name = "Discharged battery" warn = True @@ -1645,11 +1650,12 @@ def _process_event(self, data: bytearray, packet_data: str) -> None: event_name = "Backup battery fault" warn = True self._device_battery_low(source) + self._activate_source(source) elif event_type == 0x17: event_name = "24 hours" # for example panic alarm # 24 hours code=source - code = self._get_source(source) - code.active = True + source = self._get_source(source) + self._activate_source(source) elif event_type == 0x1a: event_name = "Setting Zone A" code = self._get_source(source) @@ -1702,8 +1708,9 @@ def _process_event(self, data: bytearray, packet_data: str) -> None: # the second detector is triggered. But the aim of this software is to replicate the alerts of the alarm system. # TODO: Check the alarm logs to see what is registered. event_name = event_name + ", Control panel" + else: + self._activate_source(source) warn = True - self._activate_source(source) elif event_type == 0x5c: event_name = "PGX On" elif event_type == 0x5d: From a8fb941aee3df052bb9a820d77c9d8c3108c3694 Mon Sep 17 00:00:00 2001 From: mattsaxon Date: Sat, 19 Mar 2022 12:36:51 +0000 Subject: [PATCH 6/6] Correct device 63 default name --- custom_components/jablotron80/jablotron.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/jablotron80/jablotron.py b/custom_components/jablotron80/jablotron.py index 0b77f84..a0c2d29 100644 --- a/custom_components/jablotron80/jablotron.py +++ b/custom_components/jablotron80/jablotron.py @@ -382,7 +382,7 @@ def name(self) -> str: # device 63 is when home assisant sets the alarm (with no code) elif self.device_id == 63: - return 'Computer Interface' + return 'Device on line' return f'device_{self.device_id}' return self._name