Skip to content

Commit 87752a9

Browse files
authored
feat: add basic support for the color bulbs (#57)
1 parent b771509 commit 87752a9

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

switchbot/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,20 @@ def _process_woplugmini(data: bytes, mfr_data: bytes | None) -> dict[str, bool |
146146
}
147147

148148

149+
def _process_color_bulb(data: bytes, mfr_data: bytes | None) -> dict[str, bool | int]:
150+
"""Process WoBulb services data."""
151+
return {
152+
"sequence_number": mfr_data[6],
153+
"isOn": bool(mfr_data[7] & 0b10000000),
154+
"brightness": mfr_data[7] & 0b01111111,
155+
"delay": bool(mfr_data[8] & 0b10000000),
156+
"preset": bool(mfr_data[8] & 0b00001000),
157+
"light_state": mfr_data[8] & 0b00000111,
158+
"speed": mfr_data[9] & 0b01111111,
159+
"loop_index": mfr_data[10] & 0b11111110,
160+
}
161+
162+
149163
@dataclass
150164
class SwitchBotAdvertisement:
151165
"""Switchbot advertisement."""
@@ -176,6 +190,7 @@ def parse_advertisement_data(
176190
"T": {"modelName": "WoSensorTH", "func": _process_wosensorth},
177191
"i": {"modelName": "WoSensorTH", "func": _process_wosensorth},
178192
"g": {"modelName": "WoPlug", "func": _process_woplugmini},
193+
"u": {"modelName": "WoBulb", "func": _process_color_bulb},
179194
}
180195

181196
data = {

0 commit comments

Comments
 (0)