Refactor static attributes to class attrs for UniFi Protect (#63236)

This commit is contained in:
Christopher Bailey 2022-01-02 16:16:14 -05:00 committed by GitHub
parent 50188e06ac
commit 4099d84fa4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 5 deletions

View file

@ -39,6 +39,9 @@ async def async_setup_entry(
class ProtectButton(ProtectDeviceEntity, ButtonEntity):
"""A Ubiquiti UniFi Protect Reboot button."""
_attr_entity_registry_enabled_default = False
_attr_device_class = ButtonDeviceClass.RESTART
def __init__(
self,
data: ProtectData,
@ -47,8 +50,6 @@ class ProtectButton(ProtectDeviceEntity, ButtonEntity):
"""Initialize an UniFi camera."""
super().__init__(data, device)
self._attr_name = f"{self.device.name} Reboot Device"
self._attr_entity_registry_enabled_default = False
self._attr_device_class = ButtonDeviceClass.RESTART
async def async_press(self) -> None:
"""Press the button."""

View file

@ -56,6 +56,9 @@ def hass_to_unifi_brightness(value: int) -> int:
class ProtectLight(ProtectDeviceEntity, LightEntity):
"""A Ubiquiti UniFi Protect Light Entity."""
_attr_icon = "mdi:spotlight-beam"
_attr_supported_features = SUPPORT_BRIGHTNESS
def __init__(
self,
data: ProtectData,
@ -64,8 +67,6 @@ class ProtectLight(ProtectDeviceEntity, LightEntity):
"""Initialize an UniFi light."""
self.device: Light = device
super().__init__(data)
self._attr_icon = "mdi:spotlight-beam"
self._attr_supported_features = SUPPORT_BRIGHTNESS
@callback
def _async_update_device_from_protect(self) -> None:

View file

@ -73,7 +73,7 @@ CAMERA_NUMBERS: tuple[ProtectNumberEntityDescription, ...] = (
),
ProtectNumberEntityDescription(
key=_KEY_ZOOM_POS,
name="Zoom Position",
name="Zoom Level",
icon="mdi:magnify-plus-outline",
entity_category=EntityCategory.CONFIG,
ufp_min=0,