From f32a7f5a0632cb99a6352ad50f43f030e9df2415 Mon Sep 17 00:00:00 2001 From: mattsaxon Date: Tue, 15 Feb 2022 12:23:15 +0000 Subject: [PATCH 1/3] Add extra codes for exit of elevated --- custom_components/jablotron80/jablotron.py | 33 ++++++++++++++++------ 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/custom_components/jablotron80/jablotron.py b/custom_components/jablotron80/jablotron.py index a43bc1f..074e88e 100644 --- a/custom_components/jablotron80/jablotron.py +++ b/custom_components/jablotron80/jablotron.py @@ -958,13 +958,15 @@ class JablotronState(): ENROLLMENT = 0x01 SERVICE = 0x00 SERVICE_LOADING_SETTINGS = 0x05 + SERVICE_EXITING= 0x08 STATES_SERVICE = [ENROLLMENT, - SERVICE, SERVICE_LOADING_SETTINGS] + SERVICE, SERVICE_LOADING_SETTINGS, SERVICE_EXITING] MAINTENANCE = 0x20 BYPASS = 0x21 MAINTENANCE_LOADING_SETTINGS = 0x25 + MAINTENANCE_EXITING= 0x28 STATES_MAINTENANCE = [MAINTENANCE, - MAINTENANCE_LOADING_SETTINGS, BYPASS] + MAINTENANCE_LOADING_SETTINGS, BYPASS, MAINTENANCE_EXITING] #partial ALARM_A = 0x45 @@ -983,10 +985,12 @@ class JablotronState(): STATES_ALARM = [ALARM_A,ALARM_B,ALARM_C,ALARM_WITHOUT_ARMING, ALARM_A_SPLIT,ALARM_B_SPLIT,ALARM_C_SPLIT,ALARM_WITHOUT_ARMING_SPLIT] - - ARMED_ENTRY_DELAY = 0x4b - STATES_ENTERING_DELAY = [ARMED_ENTRY_DELAY] - STATES_ELEVATED = [SERVICE,MAINTENANCE] + ARMED_ENTRY_DELAY_A = 0x49 + ARMED_ENTRY_DELAY_B = 0x4a + ARMED_ENTRY_DELAY_C = 0x4b + + STATES_ENTERING_DELAY = [ARMED_ENTRY_DELAY_A, ARMED_ENTRY_DELAY_B, ARMED_ENTRY_DELAY_C] + #STATES_ELEVATED = [SERVICE,MAINTENANCE] @staticmethod def is_armed_state(status): @@ -997,7 +1001,8 @@ def is_disarmed_state(status): return status in JablotronState.STATES_DISARMED @staticmethod def is_elevated_state(status): - return status in JablotronState.STATES_ELEVATED + return JablotronState.is_service_state(status) or JablotronState.is_maintenance_state(status) + #return status in JablotronState.STATES_ELEVATED @staticmethod def is_exit_delay_state(status): @@ -1577,13 +1582,14 @@ def _process_state(self, data: bytearray, packet_data: str) -> None: self._call_zone(2,by = detail,function_name="armed") elif status == JablotronState.ARMED_SPLIT_C: self._call_zone(3,by = detail,function_name="armed") - elif status == JablotronState.ARMED_ENTRY_DELAY: + elif status == JablotronState.ARMED_ENTRY_DELAY_C: # is detail 2 device id? #if not detail_2 == 0x00: # device = self.get_device(detail_2) # self._get_zone_via_object(device).entering(device) # self._activate_source(detail_2) pass + elif status == JablotronState.EXIT_DELAY_ABC: self._call_zones(function_name="arming") elif status == JablotronState.EXIT_DELAY_A: @@ -1709,6 +1715,13 @@ def _process_state(self, data: bytearray, packet_data: str) -> None: elif JablotronState.is_entering_delay_state(status): # device activation? pass + elif JablotronState.is_disarmed_state(status): + pass + else: + LOGGER.error( + f'Unknown status message status={status} received data={packet_data}') + + #if activity != 0x00: # log = f'Status: {activity_name}, {detail}:{self.get_device(detail).name}' @@ -1718,7 +1731,9 @@ def _process_state(self, data: bytearray, packet_data: str) -> None: # #LOGGER.info(log) # pass - # LOGGER.info(f'{self}') + #LOGGER.info(f'Status: {hex(status)}, {format(status, "008b")}') + #LOGGER.info(f'{self}') + def _get_timestamp(self, data: bytearray) -> None: day = f'{data[0]:02x}' month = f'{data[1]:02x}' From a5905d74e5e4e30f7fd8573e4ca361f8ee446c3d Mon Sep 17 00:00:00 2001 From: mattsaxon Date: Tue, 15 Feb 2022 12:33:59 +0000 Subject: [PATCH 2/3] Sinmplify process_state --- custom_components/jablotron80/jablotron.py | 24 +++------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/custom_components/jablotron80/jablotron.py b/custom_components/jablotron80/jablotron.py index 074e88e..65443bb 100644 --- a/custom_components/jablotron80/jablotron.py +++ b/custom_components/jablotron80/jablotron.py @@ -1603,25 +1603,6 @@ def _process_state(self, data: bytearray, packet_data: str) -> None: self._call_zone(2,by = detail,function_name="arming") elif status == JablotronState.EXIT_DELAY_SPLIT_C: self._call_zone(3,by = detail,function_name="arming") - elif status == JablotronState.ENROLLMENT: - # detail = device id - self.notify_service() - elif status == JablotronState.BYPASS: - # detail = device id - self.notify_service() - elif status == JablotronState.SERVICE_LOADING_SETTINGS: - self.notify_service() - elif status == JablotronState.MAINTENANCE_LOADING_SETTINGS: - self.notify_service() - elif status == JablotronState.MAINTENANCE: - # at least activity 02 - self.notify_service() - elif status == JablotronState.SERVICE: - self.notify_service() - else: - LOGGER.error( - f'Unknown status message status={status} received data={packet_data}') - if JablotronState.is_armed_state(status): if activity == 0x00: @@ -1675,8 +1656,10 @@ def _process_state(self, data: bytearray, packet_data: str) -> None: LOGGER.error(f'Unknown activity received data={packet_data}') elif JablotronState.is_service_state(status): self.status = JA80CentralUnit.STATUS_SERVICE + self.notify_service() elif JablotronState.is_maintenance_state(status): self.status = JA80CentralUnit.STATUS_MAINTENANCE + self.notify_service() elif JablotronState.is_exit_delay_state(status): if activity == 0x0c: # normal state? @@ -1720,8 +1703,7 @@ def _process_state(self, data: bytearray, packet_data: str) -> None: else: LOGGER.error( f'Unknown status message status={status} received data={packet_data}') - - + #if activity != 0x00: # log = f'Status: {activity_name}, {detail}:{self.get_device(detail).name}' From 9592d32faac99491e32e9f880146ba5f44f14a08 Mon Sep 17 00:00:00 2001 From: mattsaxon Date: Fri, 18 Feb 2022 10:12:24 +0000 Subject: [PATCH 3/3] Simplify service/maint recognition --- custom_components/jablotron80/jablotron.py | 36 +++++++++++++++------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/custom_components/jablotron80/jablotron.py b/custom_components/jablotron80/jablotron.py index 65443bb..259d78d 100644 --- a/custom_components/jablotron80/jablotron.py +++ b/custom_components/jablotron80/jablotron.py @@ -957,16 +957,16 @@ class JablotronState(): STATES_ARMED = [ ARMED_SPLIT_A, ARMED_SPLIT_B, ARMED_SPLIT_C,ARMED_A, ARMED_AB, ARMED_ABC] ENROLLMENT = 0x01 SERVICE = 0x00 - SERVICE_LOADING_SETTINGS = 0x05 - SERVICE_EXITING= 0x08 - STATES_SERVICE = [ENROLLMENT, - SERVICE, SERVICE_LOADING_SETTINGS, SERVICE_EXITING] + #SERVICE_LOADING_SETTINGS = 0x05 + #SERVICE_EXITING= 0x08 + #STATES_SERVICE = [ENROLLMENT, + # SERVICE, SERVICE_LOADING_SETTINGS, SERVICE_EXITING] MAINTENANCE = 0x20 - BYPASS = 0x21 - MAINTENANCE_LOADING_SETTINGS = 0x25 - MAINTENANCE_EXITING= 0x28 - STATES_MAINTENANCE = [MAINTENANCE, - MAINTENANCE_LOADING_SETTINGS, BYPASS, MAINTENANCE_EXITING] + #BYPASS = 0x21 + #MAINTENANCE_LOADING_SETTINGS = 0x25 + #MAINTENANCE_EXITING= 0x28 + #STATES_MAINTENANCE = [MAINTENANCE, + # MAINTENANCE_LOADING_SETTINGS, BYPASS, MAINTENANCE_EXITING] #partial ALARM_A = 0x45 @@ -1014,11 +1014,13 @@ def is_entering_delay_state(status): @staticmethod def is_service_state(status): - return status in JablotronState.STATES_SERVICE + return not status & JablotronState.MAINTENANCE and not status & JablotronState.DISARMED + #return status in JablotronState.STATES_SERVICE @staticmethod def is_maintenance_state(status): - return status in JablotronState.STATES_MAINTENANCE + return status & JablotronState.MAINTENANCE and not status & JablotronState.DISARMED + #return status in JablotronState.STATES_MAINTENANCE @staticmethod def is_alarm_state(status): @@ -1324,6 +1326,13 @@ def notify_service(self) -> None: for zone in self._zones.values(): zone.status = JablotronZone.STATUS_SERVICE + def is_elevated(self) -> bool: + for zone in self._zones.values(): + if zone.status == JablotronZone.STATUS_SERVICE: + return True + + return False + def _call_zones(self,source_id:bytes = None, function_name: str = None) -> None: for zone in self._zones.values(): if zone is not None: @@ -1894,6 +1903,11 @@ def _process_settings(self, data: bytearray, packet_data: str) -> None: pass def _process_state_detail(self, data: bytearray, packet_data: str) -> None: + + # if we are in elevated mode, don't process the detail + if self.is_elevated(): + return + detail = data[1] #crc = data[2] if detail == 0x00: