Skip to content

Commit 2369ae1

Browse files
committed
Fix support Konesky WiFi Smart Mosquito Killer #1637
1 parent f27ab4d commit 2369ae1

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

custom_components/sonoff/light.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ class XLight57(XLight):
174174
def set_state(self, params: dict):
175175
XLight.set_state(self, params)
176176
# fix https://github.com/AlexxIT/SonoffLAN/issues/1637
177-
if (v := params.get("channel0")) and isinstance(v, int):
178-
self._attr_brightness = conv(v, 25, 255, 1, 255)
177+
if "channel0" in params:
178+
self._attr_brightness = conv(int(params["channel0"]), 25, 255, 1, 255)
179179

180180
def get_params(self, brightness, color_temp, rgb_color, effect) -> dict:
181181
if brightness:

tests/test_entity.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from custom_components.sonoff.light import (
3939
UIID22_MODES,
4040
XDiffuserLight,
41+
XLight57,
4142
XLightB05B,
4243
XLightB1,
4344
XLightGroup,
@@ -2084,3 +2085,32 @@ def test_swv():
20842085
water: XSensor = next(e for e in entities if e.uid == "water")
20852086
assert water.state == 8
20862087
assert water.unit_of_measurement == UnitOfVolume.LITERS
2088+
2089+
2090+
def test_mosquitto():
2091+
entities = get_entitites(
2092+
{
2093+
"extra": {"uiid": 57},
2094+
"params": {
2095+
"rssi": -47,
2096+
"staMac": "***",
2097+
"channel3": "255",
2098+
"channel4": "255",
2099+
"channel0": "25",
2100+
"fwVersion": "3.4.0",
2101+
"channel1": "255",
2102+
"channel2": "255",
2103+
"state": "on",
2104+
"version": 8,
2105+
"sledOnline": "on",
2106+
"init": 1,
2107+
"startup": "on",
2108+
"bindInfos": {},
2109+
"only_device": {"errorCh": 0, "errorPwm": 0},
2110+
},
2111+
}
2112+
)
2113+
2114+
light: XLight57 = entities[0]
2115+
assert light.state == "on"
2116+
assert light.brightness == 1

0 commit comments

Comments
 (0)