diff --git a/custom_components/xiaomi_gateway3/core/converters/zigbee.py b/custom_components/xiaomi_gateway3/core/converters/zigbee.py index 9a54d416..03112a11 100644 --- a/custom_components/xiaomi_gateway3/core/converters/zigbee.py +++ b/custom_components/xiaomi_gateway3/core/converters/zigbee.py @@ -456,6 +456,26 @@ def decode(self, device: "XDevice", payload: dict, data: dict): payload[self.attr] = bool(value[100]) +# Gateway doesn't unpack gas status, don't know why. +class ZLumiGasHeartbeat(ZConverter): + """Decode gas status from Lumi Basic cluster.""" + + cluster_id = Basic.cluster_id + + def decode(self, device: "XDevice", payload: dict, data: dict): + if value := data.get(0xFF01): + if value[150] == 0: + payload[self.attr] = False + elif value[150] == 0x42000000: + payload[self.attr] = True + elif value[150] == 0x43000000: + payload[self.attr] = True + payload["action"] = BUTTON_SINGLE + elif value[150] == 0x08000000: + payload[self.attr] = False + payload["action"] = BUTTON_SINGLE + + class ZLumiSensConv(ZConverter): cluster_id = IasZone.cluster_id attr_id = 0xFFF0 # read attr diff --git a/custom_components/xiaomi_gateway3/core/devices.py b/custom_components/xiaomi_gateway3/core/devices.py index ce1e02cb..f7cda928 100644 --- a/custom_components/xiaomi_gateway3/core/devices.py +++ b/custom_components/xiaomi_gateway3/core/devices.py @@ -482,6 +482,7 @@ BaseConv("gas_density", "sensor", mi="0.1.85"), BoolConv("gas", "binary_sensor", mi="13.1.85"), ZLumiSensConv("sensitivity", "select"), # config + ZLumiGasHeartbeat("gas"), ], }, { "lumi.curtain": ["Aqara", "Curtain", "ZNCLDJ11LM"],