Skip to content

Commit 0498ac7

Browse files
authored
Migrate supported_color_modes to shorthand attribute in zwave_js lights (home-assistant#162296)
1 parent 67bdeb9 commit 0498ac7

File tree

1 file changed

+7
-12
lines changed
  • homeassistant/components/zwave_js

1 file changed

+7
-12
lines changed

homeassistant/components/zwave_js/light.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ def __init__(
130130
CommandClass.SWITCH_COLOR,
131131
value_property_key=ColorComponent.COLD_WHITE,
132132
)
133-
self._supported_color_modes: set[ColorMode] = set()
134133

135134
self._target_brightness: Value | None = None
136135

@@ -176,17 +175,18 @@ def __init__(
176175
)
177176

178177
self._calculate_color_support()
178+
self._attr_supported_color_modes = set()
179179
if self._supports_rgbw:
180-
self._supported_color_modes.add(ColorMode.RGBW)
180+
self._attr_supported_color_modes.add(ColorMode.RGBW)
181181
elif self._supports_color:
182-
self._supported_color_modes.add(ColorMode.HS)
182+
self._attr_supported_color_modes.add(ColorMode.HS)
183183
if self._supports_color_temp:
184-
self._supported_color_modes.add(ColorMode.COLOR_TEMP)
185-
if not self._supported_color_modes:
184+
self._attr_supported_color_modes.add(ColorMode.COLOR_TEMP)
185+
if not self._attr_supported_color_modes:
186186
if self.info.primary_value.command_class == CommandClass.SWITCH_BINARY:
187-
self._supported_color_modes.add(ColorMode.ONOFF)
187+
self._attr_supported_color_modes.add(ColorMode.ONOFF)
188188
else:
189-
self._supported_color_modes.add(ColorMode.BRIGHTNESS)
189+
self._attr_supported_color_modes.add(ColorMode.BRIGHTNESS)
190190
self._calculate_color_values()
191191

192192
# Entity class attributes
@@ -230,11 +230,6 @@ def is_on(self) -> bool | None:
230230
brightness = self.brightness
231231
return brightness > 0 if brightness is not None else None
232232

233-
@property
234-
def supported_color_modes(self) -> set[ColorMode] | None:
235-
"""Flag supported features."""
236-
return self._supported_color_modes
237-
238233
async def async_turn_on(self, **kwargs: Any) -> None:
239234
"""Turn the device on."""
240235

0 commit comments

Comments
 (0)