Skip to content

Commit 7d471f9

Browse files
authored
Add rgbicww light for switchbot integration (#151129)
1 parent 83f3b3e commit 7d471f9

File tree

6 files changed

+130
-6
lines changed

6 files changed

+130
-6
lines changed

homeassistant/components/switchbot/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@
9595
SupportedModels.EVAPORATIVE_HUMIDIFIER: [Platform.HUMIDIFIER, Platform.SENSOR],
9696
SupportedModels.FLOOR_LAMP.value: [Platform.LIGHT, Platform.SENSOR],
9797
SupportedModels.STRIP_LIGHT_3.value: [Platform.LIGHT, Platform.SENSOR],
98+
SupportedModels.RGBICWW_FLOOR_LAMP.value: [Platform.LIGHT, Platform.SENSOR],
99+
SupportedModels.RGBICWW_STRIP_LIGHT.value: [Platform.LIGHT, Platform.SENSOR],
98100
}
99101
CLASS_BY_DEVICE = {
100102
SupportedModels.CEILING_LIGHT.value: switchbot.SwitchbotCeilingLight,
@@ -123,6 +125,8 @@
123125
SupportedModels.EVAPORATIVE_HUMIDIFIER: switchbot.SwitchbotEvaporativeHumidifier,
124126
SupportedModels.FLOOR_LAMP.value: switchbot.SwitchbotStripLight3,
125127
SupportedModels.STRIP_LIGHT_3.value: switchbot.SwitchbotStripLight3,
128+
SupportedModels.RGBICWW_FLOOR_LAMP.value: switchbot.SwitchbotRgbicLight,
129+
SupportedModels.RGBICWW_STRIP_LIGHT.value: switchbot.SwitchbotRgbicLight,
126130
}
127131

128132

homeassistant/components/switchbot/const.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ class SupportedModels(StrEnum):
5151
EVAPORATIVE_HUMIDIFIER = "evaporative_humidifier"
5252
FLOOR_LAMP = "floor_lamp"
5353
STRIP_LIGHT_3 = "strip_light_3"
54+
RGBICWW_STRIP_LIGHT = "rgbicww_strip_light"
55+
RGBICWW_FLOOR_LAMP = "rgbicww_floor_lamp"
5456

5557

5658
CONNECTABLE_SUPPORTED_MODEL_TYPES = {
@@ -81,6 +83,8 @@ class SupportedModels(StrEnum):
8183
SwitchbotModel.EVAPORATIVE_HUMIDIFIER: SupportedModels.EVAPORATIVE_HUMIDIFIER,
8284
SwitchbotModel.FLOOR_LAMP: SupportedModels.FLOOR_LAMP,
8385
SwitchbotModel.STRIP_LIGHT_3: SupportedModels.STRIP_LIGHT_3,
86+
SwitchbotModel.RGBICWW_STRIP_LIGHT: SupportedModels.RGBICWW_STRIP_LIGHT,
87+
SwitchbotModel.RGBICWW_FLOOR_LAMP: SupportedModels.RGBICWW_FLOOR_LAMP,
8488
}
8589

8690
NON_CONNECTABLE_SUPPORTED_MODEL_TYPES = {
@@ -112,6 +116,8 @@ class SupportedModels(StrEnum):
112116
SwitchbotModel.EVAPORATIVE_HUMIDIFIER,
113117
SwitchbotModel.FLOOR_LAMP,
114118
SwitchbotModel.STRIP_LIGHT_3,
119+
SwitchbotModel.RGBICWW_STRIP_LIGHT,
120+
SwitchbotModel.RGBICWW_FLOOR_LAMP,
115121
}
116122

117123
ENCRYPTED_SWITCHBOT_MODEL_TO_CLASS: dict[
@@ -128,6 +134,8 @@ class SupportedModels(StrEnum):
128134
SwitchbotModel.EVAPORATIVE_HUMIDIFIER: switchbot.SwitchbotEvaporativeHumidifier,
129135
SwitchbotModel.FLOOR_LAMP: switchbot.SwitchbotStripLight3,
130136
SwitchbotModel.STRIP_LIGHT_3: switchbot.SwitchbotStripLight3,
137+
SwitchbotModel.RGBICWW_STRIP_LIGHT: switchbot.SwitchbotRgbicLight,
138+
SwitchbotModel.RGBICWW_FLOOR_LAMP: switchbot.SwitchbotRgbicLight,
131139
}
132140

133141
HASS_SENSOR_TYPE_TO_SWITCHBOT_MODEL = {

homeassistant/components/switchbot/icons.json

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,30 @@
9999
"rose": "mdi:flower",
100100
"colorful": "mdi:looks",
101101
"flickering": "mdi:led-strip-variant",
102-
"breathing": "mdi:heart-pulse"
102+
"breathing": "mdi:heart-pulse",
103+
"romance": "mdi:heart-outline",
104+
"energy": "mdi:run",
105+
"heartbeat": "mdi:heart-pulse",
106+
"party": "mdi:party-popper",
107+
"dynamic": "mdi:palette",
108+
"mystery": "mdi:alien-outline",
109+
"lightning": "mdi:flash-outline",
110+
"rock": "mdi:guitar-electric",
111+
"starlight": "mdi:creation",
112+
"valentine_day": "mdi:emoticon-kiss-outline",
113+
"dream": "mdi:sleep",
114+
"alarm": "mdi:alarm-light",
115+
"fireworks": "mdi:firework",
116+
"waves": "mdi:waves",
117+
"rainbow": "mdi:looks",
118+
"game": "mdi:gamepad-variant-outline",
119+
"meditation": "mdi:meditation",
120+
"starlit_sky": "mdi:weather-night",
121+
"sleep": "mdi:power-sleep",
122+
"movie": "mdi:popcorn",
123+
"sunrise": "mdi:weather-sunset-up",
124+
"new_year": "mdi:glass-wine",
125+
"cherry_blossom": "mdi:flower-outline"
103126
}
104127
}
105128
}

homeassistant/components/switchbot/strings.json

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,30 @@
270270
"rose": "Rose",
271271
"colorful": "Colorful",
272272
"flickering": "Flickering",
273-
"breathing": "Breathing"
273+
"breathing": "Breathing",
274+
"romance": "Romance",
275+
"energy": "Energy",
276+
"heartbeat": "Heartbeat",
277+
"party": "Party",
278+
"dynamic": "Dynamic",
279+
"mystery": "Mystery",
280+
"lightning": "Lightning",
281+
"rock": "Rock",
282+
"starlight": "Starlight",
283+
"valentine_day": "Valentine's Day",
284+
"dream": "Dream",
285+
"alarm": "Alarm",
286+
"fireworks": "Fireworks",
287+
"waves": "Waves",
288+
"rainbow": "Rainbow",
289+
"game": "Game",
290+
"meditation": "Meditation",
291+
"starlit_sky": "Starlit Sky",
292+
"sleep": "Sleep",
293+
"movie": "Movie",
294+
"sunrise": "Sunrise",
295+
"new_year": "New Year",
296+
"cherry_blossom": "Cherry Blossom"
274297
}
275298
}
276299
}

tests/components/switchbot/__init__.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,3 +999,60 @@ def make_advertisement(
999999
connectable=True,
10001000
tx_power=-127,
10011001
)
1002+
1003+
RGBICWW_STRIP_LIGHT_SERVICE_INFO = BluetoothServiceInfoBleak(
1004+
name="RGBICWW Strip Light",
1005+
manufacturer_data={
1006+
2409: b'(7/L\x94\xb2\x0c\x9e"\x00\x11:\x00',
1007+
},
1008+
service_data={
1009+
"0000fd3d-0000-1000-8000-00805f9b34fb": b"\x00\x00\x00\x00\x10\xd0\xb3"
1010+
},
1011+
service_uuids=["cba20d00-224d-11e6-9fb8-0002a5d5c51b"],
1012+
address="AA:BB:CC:DD:EE:FF",
1013+
rssi=-60,
1014+
source="local",
1015+
advertisement=generate_advertisement_data(
1016+
local_name="RGBICWW Strip Light",
1017+
manufacturer_data={
1018+
2409: b'(7/L\x94\xb2\x0c\x9e"\x00\x11:\x00',
1019+
},
1020+
service_data={
1021+
"0000fd3d-0000-1000-8000-00805f9b34fb": b"\x00\x00\x00\x00\x10\xd0\xb3"
1022+
},
1023+
service_uuids=["cba20d00-224d-11e6-9fb8-0002a5d5c51b"],
1024+
),
1025+
device=generate_ble_device("AA:BB:CC:DD:EE:FF", "RGBICWW Strip Light"),
1026+
time=0,
1027+
connectable=True,
1028+
tx_power=-127,
1029+
)
1030+
1031+
1032+
RGBICWW_FLOOR_LAMP_SERVICE_INFO = BluetoothServiceInfoBleak(
1033+
name="RGBICWW Floor Lamp",
1034+
manufacturer_data={
1035+
2409: b'\xdc\x06u\xa6\xfb\xb2y\x9e"\x00\x11\xb8\x00',
1036+
},
1037+
service_data={
1038+
"0000fd3d-0000-1000-8000-00805f9b34fb": b"\x00\x00\x00\x00\x10\xd0\xb4"
1039+
},
1040+
service_uuids=["cba20d00-224d-11e6-9fb8-0002a5d5c51b"],
1041+
address="AA:BB:CC:DD:EE:FF",
1042+
rssi=-60,
1043+
source="local",
1044+
advertisement=generate_advertisement_data(
1045+
local_name="RGBICWW Floor Lamp",
1046+
manufacturer_data={
1047+
2409: b'\xdc\x06u\xa6\xfb\xb2y\x9e"\x00\x11\xb8\x00',
1048+
},
1049+
service_data={
1050+
"0000fd3d-0000-1000-8000-00805f9b34fb": b"\x00\x00\x00\x00\x10\xd0\xb4"
1051+
},
1052+
service_uuids=["cba20d00-224d-11e6-9fb8-0002a5d5c51b"],
1053+
),
1054+
device=generate_ble_device("AA:BB:CC:DD:EE:FF", "RGBICWW Floor Lamp"),
1055+
time=0,
1056+
connectable=True,
1057+
tx_power=-127,
1058+
)

tests/components/switchbot/test_light.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
BULB_SERVICE_INFO,
2626
CEILING_LIGHT_SERVICE_INFO,
2727
FLOOR_LAMP_SERVICE_INFO,
28+
RGBICWW_FLOOR_LAMP_SERVICE_INFO,
29+
RGBICWW_STRIP_LIGHT_SERVICE_INFO,
2830
STRIP_LIGHT_3_SERVICE_INFO,
2931
WOSTRIP_SERVICE_INFO,
3032
)
@@ -343,10 +345,16 @@ async def test_strip_light_services_exception(
343345

344346

345347
@pytest.mark.parametrize(
346-
("sensor_type", "service_info"),
348+
("sensor_type", "service_info", "dev_cls"),
347349
[
348-
("strip_light_3", STRIP_LIGHT_3_SERVICE_INFO),
349-
("floor_lamp", FLOOR_LAMP_SERVICE_INFO),
350+
("strip_light_3", STRIP_LIGHT_3_SERVICE_INFO, "SwitchbotStripLight3"),
351+
("floor_lamp", FLOOR_LAMP_SERVICE_INFO, "SwitchbotStripLight3"),
352+
(
353+
"rgbicww_strip_light",
354+
RGBICWW_STRIP_LIGHT_SERVICE_INFO,
355+
"SwitchbotRgbicLight",
356+
),
357+
("rgbicww_floor_lamp", RGBICWW_FLOOR_LAMP_SERVICE_INFO, "SwitchbotRgbicLight"),
350358
],
351359
)
352360
@pytest.mark.parametrize(*FLOOR_LAMP_PARAMETERS)
@@ -355,6 +363,7 @@ async def test_floor_lamp_services(
355363
mock_entry_encrypted_factory: Callable[[str], MockConfigEntry],
356364
sensor_type: str,
357365
service_info: BluetoothServiceInfoBleak,
366+
dev_cls: str,
358367
service: str,
359368
service_data: dict,
360369
mock_method: str,
@@ -370,7 +379,7 @@ async def test_floor_lamp_services(
370379
mocked_instance = AsyncMock(return_value=True)
371380

372381
with patch.multiple(
373-
"homeassistant.components.switchbot.light.switchbot.SwitchbotStripLight3",
382+
f"homeassistant.components.switchbot.light.switchbot.{dev_cls}",
374383
**{mock_method: mocked_instance},
375384
update=AsyncMock(return_value=None),
376385
):

0 commit comments

Comments
 (0)