Use entity class vars in Elgato (#50973)
This commit is contained in:
parent
41a940f644
commit
58586d5e1f
1 changed files with 12 additions and 32 deletions
|
@ -67,32 +67,27 @@ class ElgatoLight(LightEntity):
|
||||||
self._state: State | None = None
|
self._state: State | None = None
|
||||||
self.elgato = elgato
|
self.elgato = elgato
|
||||||
|
|
||||||
self._min_mired = 143
|
min_mired = 143
|
||||||
self._max_mired = 344
|
max_mired = 344
|
||||||
self._supported_color_modes = {COLOR_MODE_COLOR_TEMP}
|
supported_color_modes = {COLOR_MODE_COLOR_TEMP}
|
||||||
|
|
||||||
# Elgato Light supporting color, have a different temperature range
|
# Elgato Light supporting color, have a different temperature range
|
||||||
if settings.power_on_hue is not None:
|
if settings.power_on_hue is not None:
|
||||||
self._supported_color_modes = {COLOR_MODE_COLOR_TEMP, COLOR_MODE_HS}
|
supported_color_modes = {COLOR_MODE_COLOR_TEMP, COLOR_MODE_HS}
|
||||||
self._min_mired = 153
|
min_mired = 153
|
||||||
self._max_mired = 285
|
max_mired = 285
|
||||||
|
|
||||||
@property
|
self._attr_max_mired = max_mired
|
||||||
def name(self) -> str:
|
self._attr_min_mired = min_mired
|
||||||
"""Return the name of the entity."""
|
self._attr_name = info.display_name or info.product_name
|
||||||
# Return the product name, if display name is not set
|
self._attr_supported_color_modes = supported_color_modes
|
||||||
return self._info.display_name or self._info.product_name
|
self._attr_unique_id = info.serial_number
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self) -> bool:
|
def available(self) -> bool:
|
||||||
"""Return True if entity is available."""
|
"""Return True if entity is available."""
|
||||||
return self._state is not None
|
return self._state is not None
|
||||||
|
|
||||||
@property
|
|
||||||
def unique_id(self) -> str:
|
|
||||||
"""Return the unique ID for this sensor."""
|
|
||||||
return self._info.serial_number
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def brightness(self) -> int | None:
|
def brightness(self) -> int | None:
|
||||||
"""Return the brightness of this light between 1..255."""
|
"""Return the brightness of this light between 1..255."""
|
||||||
|
@ -105,22 +100,6 @@ class ElgatoLight(LightEntity):
|
||||||
assert self._state is not None
|
assert self._state is not None
|
||||||
return self._state.temperature
|
return self._state.temperature
|
||||||
|
|
||||||
@property
|
|
||||||
def min_mireds(self) -> int:
|
|
||||||
"""Return the coldest color_temp that this light supports."""
|
|
||||||
return self._min_mired
|
|
||||||
|
|
||||||
@property
|
|
||||||
def max_mireds(self) -> int:
|
|
||||||
"""Return the warmest color_temp that this light supports."""
|
|
||||||
# Elgato lights with color capabilities have a different highest value
|
|
||||||
return self._max_mired
|
|
||||||
|
|
||||||
@property
|
|
||||||
def supported_color_modes(self) -> set[str]:
|
|
||||||
"""Flag supported color modes."""
|
|
||||||
return self._supported_color_modes
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def color_mode(self) -> str | None:
|
def color_mode(self) -> str | None:
|
||||||
"""Return the color mode of the light."""
|
"""Return the color mode of the light."""
|
||||||
|
@ -175,6 +154,7 @@ class ElgatoLight(LightEntity):
|
||||||
brightness
|
brightness
|
||||||
and ATTR_HS_COLOR not in kwargs
|
and ATTR_HS_COLOR not in kwargs
|
||||||
and ATTR_COLOR_TEMP not in kwargs
|
and ATTR_COLOR_TEMP not in kwargs
|
||||||
|
and self.supported_color_modes
|
||||||
and COLOR_MODE_HS in self.supported_color_modes
|
and COLOR_MODE_HS in self.supported_color_modes
|
||||||
and self.color_mode == COLOR_MODE_COLOR_TEMP
|
and self.color_mode == COLOR_MODE_COLOR_TEMP
|
||||||
):
|
):
|
||||||
|
|
Loading…
Add table
Reference in a new issue