mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 06:37:52 +00:00
Refactor static attributes to class attrs for UniFi Protect (#63236)
This commit is contained in:
parent
50188e06ac
commit
4099d84fa4
@ -39,6 +39,9 @@ async def async_setup_entry(
|
|||||||
class ProtectButton(ProtectDeviceEntity, ButtonEntity):
|
class ProtectButton(ProtectDeviceEntity, ButtonEntity):
|
||||||
"""A Ubiquiti UniFi Protect Reboot button."""
|
"""A Ubiquiti UniFi Protect Reboot button."""
|
||||||
|
|
||||||
|
_attr_entity_registry_enabled_default = False
|
||||||
|
_attr_device_class = ButtonDeviceClass.RESTART
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
data: ProtectData,
|
data: ProtectData,
|
||||||
@ -47,8 +50,6 @@ class ProtectButton(ProtectDeviceEntity, ButtonEntity):
|
|||||||
"""Initialize an UniFi camera."""
|
"""Initialize an UniFi camera."""
|
||||||
super().__init__(data, device)
|
super().__init__(data, device)
|
||||||
self._attr_name = f"{self.device.name} Reboot 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:
|
async def async_press(self) -> None:
|
||||||
"""Press the button."""
|
"""Press the button."""
|
||||||
|
@ -56,6 +56,9 @@ def hass_to_unifi_brightness(value: int) -> int:
|
|||||||
class ProtectLight(ProtectDeviceEntity, LightEntity):
|
class ProtectLight(ProtectDeviceEntity, LightEntity):
|
||||||
"""A Ubiquiti UniFi Protect Light Entity."""
|
"""A Ubiquiti UniFi Protect Light Entity."""
|
||||||
|
|
||||||
|
_attr_icon = "mdi:spotlight-beam"
|
||||||
|
_attr_supported_features = SUPPORT_BRIGHTNESS
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
data: ProtectData,
|
data: ProtectData,
|
||||||
@ -64,8 +67,6 @@ class ProtectLight(ProtectDeviceEntity, LightEntity):
|
|||||||
"""Initialize an UniFi light."""
|
"""Initialize an UniFi light."""
|
||||||
self.device: Light = device
|
self.device: Light = device
|
||||||
super().__init__(data)
|
super().__init__(data)
|
||||||
self._attr_icon = "mdi:spotlight-beam"
|
|
||||||
self._attr_supported_features = SUPPORT_BRIGHTNESS
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _async_update_device_from_protect(self) -> None:
|
def _async_update_device_from_protect(self) -> None:
|
||||||
|
@ -73,7 +73,7 @@ CAMERA_NUMBERS: tuple[ProtectNumberEntityDescription, ...] = (
|
|||||||
),
|
),
|
||||||
ProtectNumberEntityDescription(
|
ProtectNumberEntityDescription(
|
||||||
key=_KEY_ZOOM_POS,
|
key=_KEY_ZOOM_POS,
|
||||||
name="Zoom Position",
|
name="Zoom Level",
|
||||||
icon="mdi:magnify-plus-outline",
|
icon="mdi:magnify-plus-outline",
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
ufp_min=0,
|
ufp_min=0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user