mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Use shorthand attributes in UPB (#99892)
This commit is contained in:
parent
b2b57c5f87
commit
b2c3d95911
@ -57,7 +57,7 @@ class UpbLight(UpbAttachedEntity, LightEntity):
|
|||||||
def __init__(self, element, unique_id, upb):
|
def __init__(self, element, unique_id, upb):
|
||||||
"""Initialize an UpbLight."""
|
"""Initialize an UpbLight."""
|
||||||
super().__init__(element, unique_id, upb)
|
super().__init__(element, unique_id, upb)
|
||||||
self._brightness = self._element.status
|
self._attr_brightness: int = self._element.status
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def color_mode(self) -> ColorMode:
|
def color_mode(self) -> ColorMode:
|
||||||
@ -78,15 +78,10 @@ class UpbLight(UpbAttachedEntity, LightEntity):
|
|||||||
return LightEntityFeature.TRANSITION | LightEntityFeature.FLASH
|
return LightEntityFeature.TRANSITION | LightEntityFeature.FLASH
|
||||||
return LightEntityFeature.FLASH
|
return LightEntityFeature.FLASH
|
||||||
|
|
||||||
@property
|
|
||||||
def brightness(self):
|
|
||||||
"""Get the brightness."""
|
|
||||||
return self._brightness
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
"""Get the current brightness."""
|
"""Get the current brightness."""
|
||||||
return self._brightness != 0
|
return self._attr_brightness != 0
|
||||||
|
|
||||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||||
"""Turn on the light."""
|
"""Turn on the light."""
|
||||||
@ -123,4 +118,4 @@ class UpbLight(UpbAttachedEntity, LightEntity):
|
|||||||
|
|
||||||
def _element_changed(self, element, changeset):
|
def _element_changed(self, element, changeset):
|
||||||
status = self._element.status
|
status = self._element.status
|
||||||
self._brightness = round(status * 2.55) if status else 0
|
self._attr_brightness = round(status * 2.55) if status else 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user