1 """Support for Big Ass Fans lights."""
3 from __future__
import annotations
7 from aiobafi6
import Device, OffOnAuto
18 color_temperature_kelvin_to_mired,
19 color_temperature_mired_to_kelvin,
22 from .
import BAFConfigEntry
23 from .entity
import BAFEntity
28 entry: BAFConfigEntry,
29 async_add_entities: AddEntitiesCallback,
31 """Set up BAF lights."""
32 device = entry.runtime_data
34 klass = BAFFanLight
if device.has_fan
else BAFStandaloneLight
39 """Representation of a Big Ass Fans light."""
45 """Update attrs from device."""
47 if self.
_device_device.light_brightness_level
is not None:
49 self.
_device_device.light_brightness_level / 16 * 255
53 """Turn on the light."""
54 if (brightness := kwargs.get(ATTR_BRIGHTNESS))
is not None:
55 self.
_device_device.light_brightness_level =
max(
int(brightness / 255 * 16), 1)
57 self.
_device_device.light_mode = OffOnAuto.ON
60 """Turn off the light."""
61 self.
_device_device.light_mode = OffOnAuto.OFF
65 """Representation of a Big Ass Fans light on a fan."""
67 _attr_supported_color_modes = {ColorMode.BRIGHTNESS}
68 _attr_color_mode = ColorMode.BRIGHTNESS
72 """Representation of a Big Ass Fans light."""
74 _attr_supported_color_modes = {ColorMode.COLOR_TEMP}
75 _attr_color_mode = ColorMode.COLOR_TEMP
78 """Init a standalone light."""
81 device.light_warmest_color_temperature
84 device.light_coolest_color_temperature
89 """Update attrs from device."""
92 self.
_device_device.light_color_temperature
96 """Turn on the light."""
97 if (color_temp := kwargs.get(ATTR_COLOR_TEMP))
is not None:
None _async_update_attrs(self)
None async_turn_off(self, **Any kwargs)
None async_turn_on(self, **Any kwargs)
None async_turn_on(self, **Any kwargs)
None _async_update_attrs(self)
None __init__(self, Device device)
None async_setup_entry(HomeAssistant hass, BAFConfigEntry entry, AddEntitiesCallback async_add_entities)
int color_temperature_mired_to_kelvin(float mired_temperature)
int color_temperature_kelvin_to_mired(float kelvin_temperature)