From 937d3e4a9651e4177b75c1ff486805e6b6bcdf88 Mon Sep 17 00:00:00 2001 From: Samuel Xiao <40679757+XiaoLing-git@users.noreply.github.com> Date: Fri, 12 Sep 2025 00:39:29 +0800 Subject: [PATCH] Add more light models to SwitchBot Cloud (#150986) --- homeassistant/components/switchbot_cloud/__init__.py | 2 ++ homeassistant/components/switchbot_cloud/light.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/switchbot_cloud/__init__.py b/homeassistant/components/switchbot_cloud/__init__.py index 44d1f8f30e51..0beba5dfc14d 100644 --- a/homeassistant/components/switchbot_cloud/__init__.py +++ b/homeassistant/components/switchbot_cloud/__init__.py @@ -247,6 +247,8 @@ async def make_device_data( "Strip Light 3", "Floor Lamp", "Color Bulb", + "RGBICWW Floor Lamp", + "RGBICWW Strip Light", ]: coordinator = await coordinator_for_device( hass, entry, api, device, coordinators_by_id diff --git a/homeassistant/components/switchbot_cloud/light.py b/homeassistant/components/switchbot_cloud/light.py index 645c6b4c62be..77062702831a 100644 --- a/homeassistant/components/switchbot_cloud/light.py +++ b/homeassistant/components/switchbot_cloud/light.py @@ -27,6 +27,11 @@ def value_map_brightness(value: int) -> int: return int(value / 255 * 100) +def brightness_map_value(value: int) -> int: + """Return brightness from map value.""" + return int(value * 255 / 100) + + async def async_setup_entry( hass: HomeAssistant, config: ConfigEntry, @@ -52,13 +57,14 @@ class SwitchBotCloudLight(SwitchBotCloudEntity, LightEntity): """Set attributes from coordinator data.""" if self.coordinator.data is None: return - power: str | None = self.coordinator.data.get("power") brightness: int | None = self.coordinator.data.get("brightness") color: str | None = self.coordinator.data.get("color") color_temperature: int | None = self.coordinator.data.get("colorTemperature") self._attr_is_on = power == "on" if power else None - self._attr_brightness: int | None = brightness if brightness else None + self._attr_brightness: int | None = ( + brightness_map_value(brightness) if brightness else None + ) self._attr_rgb_color: tuple | None = ( (tuple(int(i) for i in color.split(":"))) if color else None )