1
mirror of https://github.com/home-assistant/core synced 2024-08-28 03:36:46 +02:00

Initialize static shorthand attributes outside of constructor for BAF (#99202)

Initialize static shorthand attributes outside of init
This commit is contained in:
Joost Lekkerkerker 2023-08-28 14:43:51 +02:00 committed by GitHub
parent 60844954d2
commit 3f0a8b7a56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -39,6 +39,8 @@ async def async_setup_entry(
class BAFLight(BAFEntity, LightEntity):
"""Representation of a Big Ass Fans light."""
_attr_name = None
@callback
def _async_update_attrs(self) -> None:
"""Update attrs from device."""
@ -63,23 +65,19 @@ class BAFLight(BAFEntity, LightEntity):
class BAFFanLight(BAFLight):
"""Representation of a Big Ass Fans light on a fan."""
_attr_name = None
def __init__(self, device: Device) -> None:
"""Init a fan light."""
super().__init__(device)
self._attr_supported_color_modes = {ColorMode.BRIGHTNESS}
self._attr_color_mode = ColorMode.BRIGHTNESS
_attr_supported_color_modes = {ColorMode.BRIGHTNESS}
_attr_color_mode = ColorMode.BRIGHTNESS
class BAFStandaloneLight(BAFLight):
"""Representation of a Big Ass Fans light."""
_attr_supported_color_modes = {ColorMode.COLOR_TEMP}
_attr_color_mode = ColorMode.COLOR_TEMP
def __init__(self, device: Device) -> None:
"""Init a standalone light."""
super().__init__(device)
self._attr_supported_color_modes = {ColorMode.COLOR_TEMP}
self._attr_color_mode = ColorMode.COLOR_TEMP
self._attr_min_mireds = color_temperature_kelvin_to_mired(
device.light_warmest_color_temperature
)