Skip to content

Commit

Permalink
Add support SNZB-06P #1245
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed May 3, 2024
1 parent 20a7051 commit af72518
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 4 deletions.
18 changes: 18 additions & 0 deletions custom_components/sonoff/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,24 @@ def set_state(self, params: dict):
self._attr_is_on = False


class XHumanSensor(XEntity, BinarySensorEntity):
param = "human"
uid = "occupancy"
_attr_device_class = BinarySensorDeviceClass.OCCUPANCY

def set_state(self, params: dict):
self._attr_is_on = params[self.param] == 1


class XLightSensor(XEntity, BinarySensorEntity):
param = "brState"
uid = "light"
_attr_device_class = BinarySensorDeviceClass.LIGHT

def set_state(self, params: dict):
self._attr_is_on = params[self.param] == "brighter"


# noinspection PyAbstractClass
class XRemoteSensor(BinarySensorEntity, RestoreEntity):
_attr_is_on = False
Expand Down
12 changes: 9 additions & 3 deletions custom_components/sonoff/core/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@
from homeassistant.components.switch import SwitchEntity

from .ewelink import XDevice
from ..binary_sensor import XBinarySensor, XWiFiDoor, XZigbeeMotion
from ..binary_sensor import (
XBinarySensor,
XWiFiDoor,
XZigbeeMotion,
XHumanSensor,
XLightSensor,
)
from ..climate import XClimateNS, XClimateTH, XThermostat
from ..core.entity import XEntity
from ..cover import XCover, XCoverDualR3, XZigbeeCover, XCover91
Expand All @@ -39,7 +45,7 @@
XT5Light,
XZigbeeLight,
)
from ..number import XPulseWidth
from ..number import XPulseWidth, XSensitivity
from ..remote import XRemote
from ..sensor import (
XEnergySensor,
Expand Down Expand Up @@ -408,7 +414,7 @@ def spec(cls, base: str = None, enabled: bool = None, **kwargs) -> type:
spec(XSensor100, param="humidity"),
Battery,
], # https://github.com/AlexxIT/SonoffLAN/issues/1166
7016: [ZRSSI], # SNZB-06P
7016: [XHumanSensor, XLightSensor, XSensitivity, ZRSSI], # SNZB-06P
}


Expand Down
3 changes: 2 additions & 1 deletion custom_components/sonoff/core/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
"battery": EntityCategory.DIAGNOSTIC,
"battery_voltage": EntityCategory.DIAGNOSTIC,
"led": EntityCategory.CONFIG,
"rssi": EntityCategory.DIAGNOSTIC,
"pulse": EntityCategory.CONFIG,
"pulseWidth": EntityCategory.CONFIG,
"rssi": EntityCategory.DIAGNOSTIC,
"sensitivity": EntityCategory.CONFIG,
}

ICONS = {
Expand Down
8 changes: 8 additions & 0 deletions custom_components/sonoff/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,11 @@ async def async_set_native_value(self, value: float) -> None:
await self.ewelink.send(
self.device, {"pulse": "on", "pulseWidth": int(value / 0.5) * 500}
)


class XSensitivity(XNumber):
param = "sensitivity"

_attr_entity_registry_enabled_default = False
_attr_native_max_value = 3
_attr_native_min_value = 1

0 comments on commit af72518

Please sign in to comment.