From be38fffd6f479a677fb207f332caf4545999e7b2 Mon Sep 17 00:00:00 2001 From: Alex X Date: Wed, 1 May 2024 08:25:46 +0300 Subject: [PATCH] Add RSSI to ZBMINIL2 and SNZB-06P #1398 --- custom_components/sonoff/core/devices.py | 4 ++++ tests/test_entity.py | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/custom_components/sonoff/core/devices.py b/custom_components/sonoff/core/devices.py index 3dc2bb5d..8e799d29 100644 --- a/custom_components/sonoff/core/devices.py +++ b/custom_components/sonoff/core/devices.py @@ -111,6 +111,7 @@ def spec(cls, base: str = None, enabled: bool = None, **kwargs) -> type: LED = spec(XToggle, param="sledOnline", uid="led", enabled=False) RSSI = spec(XSensor, param="rssi", enabled=False) PULSE = spec(XToggle, param="pulse", enabled=False) +ZRSSI = spec(XSensor, param="subDevRssi", uid="rssi", enabled=False) SPEC_SWITCH = [XSwitch, LED, RSSI, PULSE, XPulseWidth] SPEC_1CH = [Switch1, LED, RSSI] @@ -398,6 +399,8 @@ def spec(cls, base: str = None, enabled: bool = None, **kwargs) -> type: XRemoteButton, Battery, ], + # https://github.com/AlexxIT/SonoffLAN/issues/1398 + 7004: [XSwitch, ZRSSI], # ZBMINIL2 # https://github.com/AlexxIT/SonoffLAN/issues/1283 7006: [XZigbeeCover, spec(XSensor, param="battery")], 7014: [ @@ -405,6 +408,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 } diff --git a/tests/test_entity.py b/tests/test_entity.py index a136388a..3e0e5190 100644 --- a/tests/test_entity.py +++ b/tests/test_entity.py @@ -1874,3 +1874,25 @@ def test_issue1386(): light: XT5Light = next(i for i in entities if isinstance(i, XT5Light)) light.internal_update({"lightMode": 101}) assert light.hass.states.get(light.entity_id).state == "off" + + +def test_zbminil2(): + device = { + "extra": {"uiid": 7004}, + "params": { + "bindInfos": "***", + "subDevId": "4e0560fefff410347004", + "parentid": "100202124f", + "fwVersion": "1.0.14", + "switch": "on", + "startup": "stay", + "subDevRssiSetting": {"active": 60, "duration": 5}, + "subDevRssi": -61, + "sledOnline": "on", + }, + "model": "ZBMINIL2", + } + + entities = get_entitites(device) + assert entities[0].state == "on" + assert entities[1].state == -61