From 9382d409e75f3c91171a0bfe45c0b2ca093d9870 Mon Sep 17 00:00:00 2001 From: Patrick Pichon Date: Thu, 6 Jun 2024 15:21:57 +0200 Subject: [PATCH 1/4] better decoding of the heiman door bel --- Z4D_decoders/z4d_decoder_IAS.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/Z4D_decoders/z4d_decoder_IAS.py b/Z4D_decoders/z4d_decoder_IAS.py index 88c462e25..1a22dc269 100644 --- a/Z4D_decoders/z4d_decoder_IAS.py +++ b/Z4D_decoders/z4d_decoder_IAS.py @@ -115,8 +115,7 @@ def Decode8401(self, Devices, MsgData, MsgLQI): if heiman_door_bell_button: self.log.logging('Input', 'Debug',f"Decode8401 HeimanDoorBellButton: {MsgSrcAddr} {MsgZoneStatus}", MsgSrcAddr) - if tamper: - MajDomoDevice(self, Devices, MsgSrcAddr, MsgEp, '0006', '01') + _heiman_door_bell_ef_3(self,Devices, MsgSrcAddr, MsgEp, MsgZoneStatus) return motion_via_IAS_alarm = get_device_config_param(self, MsgSrcAddr, 'MotionViaIASAlarm1') @@ -157,10 +156,32 @@ def Decode8401(self, Devices, MsgData, MsgLQI): if 'IAS' in self.ListOfDevices[MsgSrcAddr] and 'ZoneStatus' in self.ListOfDevices[MsgSrcAddr]['IAS']: if not isinstance(self.ListOfDevices[MsgSrcAddr]['IAS']['ZoneStatus'], dict): self.ListOfDevices[MsgSrcAddr]['IAS']['ZoneStatus'] = {} - _update_ias_zone_status(self, MsgSrcAddr, MsgEp, MsgZoneStatus) +def _heiman_door_bell_ef_3(self, Devices, MsgSrcAddr, MsgEp, MsgZoneStatus): + + zone_status_mapping = { + "4": ('0009', '00'), # Mounted + "0": ('0009', '01'), # Unmounted + } + + ring_status_mapping = { + "8": ('0006', '01'), # Ring + "0": ('0006', '01'), # Not ring + } + self.log.logging('Input', 'Debug', '_heiman_door_bell_ef_3 %s/%s %s' % (MsgSrcAddr, MsgEp, MsgZoneStatus)) + + # Check and update zone status + if MsgZoneStatus[3] in zone_status_mapping: + MajDomoDevice(self, Devices, MsgSrcAddr, MsgEp, *zone_status_mapping[MsgZoneStatus[3]]) + + # Check and update ring status + if MsgZoneStatus[0] in ring_status_mapping: + MajDomoDevice(self, Devices, MsgSrcAddr, MsgEp, *ring_status_mapping[MsgZoneStatus[0]]) + + + def _extract_zone_status_info(self, msg_data): MsgSQN = msg_data[:2] MsgEp = msg_data[2:4] From 649485d10193c74573a3030364666e20b074eaf8 Mon Sep 17 00:00:00 2001 From: Patrick Pichon Date: Thu, 6 Jun 2024 17:13:02 +0200 Subject: [PATCH 2/4] fix copy/paste issue for Ring/Not Ring value --- Z4D_decoders/z4d_decoder_IAS.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Z4D_decoders/z4d_decoder_IAS.py b/Z4D_decoders/z4d_decoder_IAS.py index 1a22dc269..71d472afd 100644 --- a/Z4D_decoders/z4d_decoder_IAS.py +++ b/Z4D_decoders/z4d_decoder_IAS.py @@ -161,20 +161,20 @@ def Decode8401(self, Devices, MsgData, MsgLQI): def _heiman_door_bell_ef_3(self, Devices, MsgSrcAddr, MsgEp, MsgZoneStatus): - zone_status_mapping = { + tamper_status_mapping = { "4": ('0009', '00'), # Mounted "0": ('0009', '01'), # Unmounted } ring_status_mapping = { "8": ('0006', '01'), # Ring - "0": ('0006', '01'), # Not ring + "0": ('0006', '00'), # Not ring } self.log.logging('Input', 'Debug', '_heiman_door_bell_ef_3 %s/%s %s' % (MsgSrcAddr, MsgEp, MsgZoneStatus)) # Check and update zone status - if MsgZoneStatus[3] in zone_status_mapping: - MajDomoDevice(self, Devices, MsgSrcAddr, MsgEp, *zone_status_mapping[MsgZoneStatus[3]]) + if MsgZoneStatus[3] in tamper_status_mapping: + MajDomoDevice(self, Devices, MsgSrcAddr, MsgEp, *tamper_status_mapping[MsgZoneStatus[3]]) # Check and update ring status if MsgZoneStatus[0] in ring_status_mapping: From e50777d285ef73e2d1a8020089806b46cdce2ece Mon Sep 17 00:00:00 2001 From: Pipiche <8291674+pipiche38@users.noreply.github.com> Date: Fri, 14 Jun 2024 10:27:18 +0200 Subject: [PATCH 3/4] Tamper on 0x4 and do not handle 0x00 --- Z4D_decoders/z4d_decoder_IAS.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Z4D_decoders/z4d_decoder_IAS.py b/Z4D_decoders/z4d_decoder_IAS.py index 71d472afd..c8d2a8865 100644 --- a/Z4D_decoders/z4d_decoder_IAS.py +++ b/Z4D_decoders/z4d_decoder_IAS.py @@ -162,13 +162,12 @@ def Decode8401(self, Devices, MsgData, MsgLQI): def _heiman_door_bell_ef_3(self, Devices, MsgSrcAddr, MsgEp, MsgZoneStatus): tamper_status_mapping = { - "4": ('0009', '00'), # Mounted - "0": ('0009', '01'), # Unmounted + "0": ('0009', '00'), # Mounted + "4": ('0009', '01'), # Unmounted } ring_status_mapping = { "8": ('0006', '01'), # Ring - "0": ('0006', '00'), # Not ring } self.log.logging('Input', 'Debug', '_heiman_door_bell_ef_3 %s/%s %s' % (MsgSrcAddr, MsgEp, MsgZoneStatus)) From 3613647993c8828b08450bfece3a043800415069 Mon Sep 17 00:00:00 2001 From: Patrick Pichon Date: Sun, 16 Jun 2024 19:07:58 +0200 Subject: [PATCH 4/4] Looks like the Door Bell button send twice the Ring, prevent to update Domoticz widget if 2 Ring messages in less than 3 seconds) --- Z4D_decoders/z4d_decoder_IAS.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Z4D_decoders/z4d_decoder_IAS.py b/Z4D_decoders/z4d_decoder_IAS.py index c8d2a8865..71bdab565 100644 --- a/Z4D_decoders/z4d_decoder_IAS.py +++ b/Z4D_decoders/z4d_decoder_IAS.py @@ -160,7 +160,7 @@ def Decode8401(self, Devices, MsgData, MsgLQI): def _heiman_door_bell_ef_3(self, Devices, MsgSrcAddr, MsgEp, MsgZoneStatus): - + # https://github.com/zigbeefordomoticz/z4d-certified-devices/issues/55 tamper_status_mapping = { "0": ('0009', '00'), # Mounted "4": ('0009', '01'), # Unmounted @@ -173,12 +173,22 @@ def _heiman_door_bell_ef_3(self, Devices, MsgSrcAddr, MsgEp, MsgZoneStatus): # Check and update zone status if MsgZoneStatus[3] in tamper_status_mapping: + # Tamper (Mount , umount) MajDomoDevice(self, Devices, MsgSrcAddr, MsgEp, *tamper_status_mapping[MsgZoneStatus[3]]) - # Check and update ring status + # Check and update ring status. Allow 3s between 2 rings if MsgZoneStatus[0] in ring_status_mapping: - MajDomoDevice(self, Devices, MsgSrcAddr, MsgEp, *ring_status_mapping[MsgZoneStatus[0]]) - + # Ring + device = self.ListOfDevices.setdefault(MsgSrcAddr, {}) + ep = device.setdefault('Ep', {}) + ep_details = ep.setdefault(MsgEp, {}) + heiman_door_bell = ep_details.setdefault('HeimanDoorBell', {}) + ring_time_stamp = heiman_door_bell.get('RingTimeStamp') + current_time = time.time() + + if ring_time_stamp is None or current_time > (ring_time_stamp + 3): + MajDomoDevice(self, Devices, MsgSrcAddr, MsgEp, *ring_status_mapping[MsgZoneStatus[0]]) + heiman_door_bell['RingTimeStamp'] = current_time def _extract_zone_status_info(self, msg_data):