1 """Support for Elgato lights."""
3 from __future__
import annotations
7 from elgato
import ElgatoError
20 async_get_current_platform,
23 from .
import ElgatorConfigEntry
24 from .const
import SERVICE_IDENTIFY
25 from .coordinator
import ElgatoDataUpdateCoordinator
26 from .entity
import ElgatoEntity
33 entry: ElgatorConfigEntry,
34 async_add_entities: AddEntitiesCallback,
36 """Set up Elgato Light based on a config entry."""
37 coordinator = entry.runtime_data
41 platform.async_register_entity_service(
44 ElgatoLight.async_identify.__name__,
49 """Defines an Elgato Light."""
52 _attr_min_mireds = 143
53 _attr_max_mireds = 344
55 def __init__(self, coordinator: ElgatoDataUpdateCoordinator) ->
None:
56 """Initialize Elgato Light."""
63 self.coordinator.data.info.product_name
66 "Elgato Light Strip Pro",
68 or self.coordinator.data.settings.power_on_hue
69 or self.coordinator.data.state.hue
is not None
77 """Return the brightness of this light between 1..255."""
78 return round((self.coordinator.data.state.brightness * 255) / 100)
82 """Return the CT color value in mireds."""
83 return self.coordinator.data.state.temperature
87 """Return the color mode of the light."""
88 if self.coordinator.data.state.hue
is not None:
91 return ColorMode.COLOR_TEMP
94 def hs_color(self) -> tuple[float, float] | None:
95 """Return the hue and saturation color value [float, float]."""
97 self.coordinator.data.state.hue
or 0,
98 self.coordinator.data.state.saturation
or 0,
103 """Return the state of the light."""
104 return self.coordinator.data.state.on
107 """Turn off the light."""
109 await self.coordinator.client.light(on=
False)
110 except ElgatoError
as error:
112 "An error occurred while updating the Elgato Light"
118 """Turn on the light."""
119 temperature = kwargs.get(ATTR_COLOR_TEMP)
123 if ATTR_HS_COLOR
in kwargs:
124 hue, saturation = kwargs[ATTR_HS_COLOR]
127 if ATTR_BRIGHTNESS
in kwargs:
128 brightness = round((kwargs[ATTR_BRIGHTNESS] / 255) * 100)
135 and ATTR_HS_COLOR
not in kwargs
136 and ATTR_COLOR_TEMP
not in kwargs
144 await self.coordinator.client.light(
146 brightness=brightness,
148 saturation=saturation,
149 temperature=temperature,
151 except ElgatoError
as error:
153 "An error occurred while updating the Elgato Light"
159 """Identify the light, will make it blink."""
161 await self.coordinator.client.identify()
162 except ElgatoError
as error:
164 "An error occurred while identifying the Elgato Light"
str|None color_mode(self)
None async_identify(self)
None __init__(self, ElgatoDataUpdateCoordinator coordinator)
tuple[float, float]|None hs_color(self)
None async_turn_off(self, **Any kwargs)
int|None color_temp(self)
_attr_supported_color_modes
int|None brightness(self)
None async_turn_on(self, **Any kwargs)
int|None color_temp(self)
set[ColorMode]|set[str]|None supported_color_modes(self)
ColorMode|str|None color_mode(self)
None async_setup_entry(HomeAssistant hass, ElgatorConfigEntry entry, AddEntitiesCallback async_add_entities)