From 97e038eb2e70505dfc2b3bbc8ac4ff8b509e67cd Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Wed, 24 Jan 2024 15:29:16 +0100 Subject: [PATCH] Fix light color mode in netatmo (#108759) --- homeassistant/components/netatmo/light.py | 11 +++++++---- tests/components/netatmo/snapshots/test_light.ambr | 2 ++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/netatmo/light.py b/homeassistant/components/netatmo/light.py index e5dd3b7354a..c38aec41564 100644 --- a/homeassistant/components/netatmo/light.py +++ b/homeassistant/components/netatmo/light.py @@ -64,7 +64,9 @@ async def async_setup_entry( class NetatmoCameraLight(NetatmoBaseEntity, LightEntity): """Representation of a Netatmo Presence camera light.""" + _attr_color_mode = ColorMode.ONOFF _attr_has_entity_name = True + _attr_supported_color_modes = {ColorMode.ONOFF} def __init__( self, @@ -170,10 +172,11 @@ class NetatmoLight(NetatmoBaseEntity, LightEntity): self._attr_brightness = 0 self._attr_unique_id = f"{self._id}-light" - self._attr_supported_color_modes: set[str] = set() - - if not self._attr_supported_color_modes and self._dimmer.brightness is not None: - self._attr_supported_color_modes.add(ColorMode.BRIGHTNESS) + if self._dimmer.brightness is not None: + self._attr_color_mode = ColorMode.BRIGHTNESS + else: + self._attr_color_mode = ColorMode.ONOFF + self._attr_supported_color_modes = {self._attr_color_mode} self._signal_name = f"{HOME}-{self._home_id}" self._publishers.extend( diff --git a/tests/components/netatmo/snapshots/test_light.ambr b/tests/components/netatmo/snapshots/test_light.ambr index 7fac90b4ec0..a116c6a3e08 100644 --- a/tests/components/netatmo/snapshots/test_light.ambr +++ b/tests/components/netatmo/snapshots/test_light.ambr @@ -6,6 +6,7 @@ 'area_id': None, 'capabilities': dict({ 'supported_color_modes': list([ + , ]), }), 'config_entry_id': , @@ -40,6 +41,7 @@ 'color_mode': None, 'friendly_name': 'Bathroom light', 'supported_color_modes': list([ + , ]), 'supported_features': , }),