mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 08:47:57 +00:00
light returns enum
This commit is contained in:
parent
d62da432d0
commit
ddf7f08567
@ -913,6 +913,17 @@ class LightEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
|
||||
|
||||
__color_mode_reported = False
|
||||
|
||||
@property # type: ignore[misc]
|
||||
@final
|
||||
def state(self) -> str | None: # type: ignore[override]
|
||||
"""Return the state."""
|
||||
# Implemented in Home Assistant 2024.10 to enable light entity
|
||||
# to return an enum instead of a string.
|
||||
# When ToggleEntity can return an enum this can be removed.
|
||||
if (_is_on := self.is_on) is None:
|
||||
return None
|
||||
return LightState.ON if _is_on else LightState.OFF
|
||||
|
||||
@cached_property
|
||||
def brightness(self) -> int | None:
|
||||
"""Return the brightness of this light between 0..255."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user