Skip to content

Commit ce3a711

Browse files
committed
Add sensors for water leaks and supply problems
While here rename EwelinkCluster to match other Sonoff quirks.
1 parent b87ac89 commit ce3a711

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

zhaquirks/sonoff/swv.py

+22-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from zigpy.quirks import CustomCluster
44
from zigpy.quirks.v2 import QuirkBuilder
5+
from zigpy.quirks.v2.homeassistant.binary_sensor import BinarySensorDeviceClass
56
import zigpy.types as t
67
from zigpy.zcl.foundation import BaseAttributeDefs, ZCLAttributeDef
78

@@ -15,8 +16,8 @@ class ValveState(t.enum8):
1516
Water_Shortage_And_Leakage = 3
1617

1718

18-
class EwelinkCluster(CustomCluster):
19-
"""Ewelink specific cluster."""
19+
class CustomSonoffCluster(CustomCluster):
20+
"""Custom Sonoff cluster."""
2021

2122
cluster_id = 0xFC11
2223

@@ -35,6 +36,24 @@ def _is_manuf_specific(self):
3536

3637
(
3738
QuirkBuilder("SONOFF", "SWV")
38-
.replaces(EwelinkCluster)
39+
.replaces(CustomSonoffCluster)
40+
.binary_sensor(
41+
CustomSonoffCluster.AttributeDefs.water_valve_state.name,
42+
CustomSonoffCluster.cluster_id,
43+
device_class=BinarySensorDeviceClass.PROBLEM,
44+
unique_id_suffix="water_leak_status",
45+
translation_key="water_leak",
46+
fallback_name="Water leak",
47+
attribute_converter=lambda x: x & ValveState.Water_Shortage,
48+
)
49+
.binary_sensor(
50+
CustomSonoffCluster.AttributeDefs.water_valve_state.name,
51+
CustomSonoffCluster.cluster_id,
52+
device_class=BinarySensorDeviceClass.PROBLEM,
53+
unique_id_suffix="water_supply_status",
54+
translation_key="water_supply",
55+
fallback_name="Water supply",
56+
attribute_converter=lambda x: x & ValveState.Water_Leakage,
57+
)
3958
.add_to_registry()
4059
) # fmt: skip

0 commit comments

Comments
 (0)