Skip to content

Commit 937d3e4

Browse files
authored
Add more light models to SwitchBot Cloud (home-assistant#150986)
1 parent a368ad4 commit 937d3e4

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

homeassistant/components/switchbot_cloud/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ async def make_device_data(
247247
"Strip Light 3",
248248
"Floor Lamp",
249249
"Color Bulb",
250+
"RGBICWW Floor Lamp",
251+
"RGBICWW Strip Light",
250252
]:
251253
coordinator = await coordinator_for_device(
252254
hass, entry, api, device, coordinators_by_id

homeassistant/components/switchbot_cloud/light.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ def value_map_brightness(value: int) -> int:
2727
return int(value / 255 * 100)
2828

2929

30+
def brightness_map_value(value: int) -> int:
31+
"""Return brightness from map value."""
32+
return int(value * 255 / 100)
33+
34+
3035
async def async_setup_entry(
3136
hass: HomeAssistant,
3237
config: ConfigEntry,
@@ -52,13 +57,14 @@ def _set_attributes(self) -> None:
5257
"""Set attributes from coordinator data."""
5358
if self.coordinator.data is None:
5459
return
55-
5660
power: str | None = self.coordinator.data.get("power")
5761
brightness: int | None = self.coordinator.data.get("brightness")
5862
color: str | None = self.coordinator.data.get("color")
5963
color_temperature: int | None = self.coordinator.data.get("colorTemperature")
6064
self._attr_is_on = power == "on" if power else None
61-
self._attr_brightness: int | None = brightness if brightness else None
65+
self._attr_brightness: int | None = (
66+
brightness_map_value(brightness) if brightness else None
67+
)
6268
self._attr_rgb_color: tuple | None = (
6369
(tuple(int(i) for i in color.split(":"))) if color else None
6470
)

0 commit comments

Comments
 (0)