Use shorthand attributes in UPB (#99892)
This commit is contained in:
parent
b2b57c5f87
commit
b2c3d95911
1 changed files with 3 additions and 8 deletions
|
@ -57,7 +57,7 @@ class UpbLight(UpbAttachedEntity, LightEntity):
|
|||
def __init__(self, element, unique_id, upb):
|
||||
"""Initialize an UpbLight."""
|
||||
super().__init__(element, unique_id, upb)
|
||||
self._brightness = self._element.status
|
||||
self._attr_brightness: int = self._element.status
|
||||
|
||||
@property
|
||||
def color_mode(self) -> ColorMode:
|
||||
|
@ -78,15 +78,10 @@ class UpbLight(UpbAttachedEntity, LightEntity):
|
|||
return LightEntityFeature.TRANSITION | LightEntityFeature.FLASH
|
||||
return LightEntityFeature.FLASH
|
||||
|
||||
@property
|
||||
def brightness(self):
|
||||
"""Get the brightness."""
|
||||
return self._brightness
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
"""Get the current brightness."""
|
||||
return self._brightness != 0
|
||||
return self._attr_brightness != 0
|
||||
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn on the light."""
|
||||
|
@ -123,4 +118,4 @@ class UpbLight(UpbAttachedEntity, LightEntity):
|
|||
|
||||
def _element_changed(self, element, changeset):
|
||||
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…
Add table
Reference in a new issue