Use shorthand attributes in Zerproc (#99926)

This commit is contained in:
Joost Lekkerkerker 2023-09-08 17:27:18 +02:00 committed by GitHub
parent 5f6f2c2cab
commit c6f8766b1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -88,6 +88,12 @@ class ZerprocLight(LightEntity):
def __init__(self, light) -> None:
"""Initialize a Zerproc light."""
self._light = light
self._attr_unique_id = light.address
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, light.address)},
manufacturer="Zerproc",
name=light.name,
)
async def async_added_to_hass(self) -> None:
"""Run when entity about to be added to hass."""
@ -108,20 +114,6 @@ class ZerprocLight(LightEntity):
"Exception disconnecting from %s", self._light.address, exc_info=True
)
@property
def unique_id(self):
"""Return the ID of this light."""
return self._light.address
@property
def device_info(self) -> DeviceInfo:
"""Device info for this light."""
return DeviceInfo(
identifiers={(DOMAIN, self.unique_id)},
manufacturer="Zerproc",
name=self._light.name,
)
async def async_turn_on(self, **kwargs: Any) -> None:
"""Instruct the light to turn on."""
if ATTR_BRIGHTNESS in kwargs or ATTR_HS_COLOR in kwargs: