diff --git a/custom_components/sonoff/binary_sensor.py b/custom_components/sonoff/binary_sensor.py index d278642..4c96a33 100644 --- a/custom_components/sonoff/binary_sensor.py +++ b/custom_components/sonoff/binary_sensor.py @@ -89,6 +89,15 @@ def set_state(self, params: dict): self._attr_is_on = params[self.param] == "brighter" +class XWaterSensor(XEntity, BinarySensorEntity): + param = "water" + uid = "moisture" + _attr_device_class = BinarySensorDeviceClass.MOISTURE + + def set_state(self, params: dict): + self._attr_is_on = params[self.param] == 1 + + # noinspection PyAbstractClass class XRemoteSensor(BinarySensorEntity, RestoreEntity): _attr_is_on = False diff --git a/custom_components/sonoff/core/devices.py b/custom_components/sonoff/core/devices.py index b3aae87..212d9ee 100644 --- a/custom_components/sonoff/core/devices.py +++ b/custom_components/sonoff/core/devices.py @@ -24,6 +24,7 @@ XZigbeeMotion, XHumanSensor, XLightSensor, + XWaterSensor, ) from ..climate import XClimateNS, XClimateTH, XThermostat from ..core.entity import XEntity @@ -428,6 +429,8 @@ def spec(cls, base: str = None, enabled: bool = None, **kwargs) -> type: Battery, ], # https://github.com/AlexxIT/SonoffLAN/issues/1166 7016: [XHumanSensor, XLightSensor, XSensitivity, ZRSSI], # SNZB-06P + # SNZB-05P https://github.com/AlexxIT/SonoffLAN/issues/1496 + 7019: [XWaterSensor, Battery], }