Update uiprotect to 1.20.0 (#120108)
parent
8aed04cd3c
commit
5e375dbf38
|
@ -40,7 +40,7 @@
|
|||
"integration_type": "hub",
|
||||
"iot_class": "local_push",
|
||||
"loggers": ["uiprotect", "unifi_discovery"],
|
||||
"requirements": ["uiprotect==1.19.3", "unifi-discovery==1.1.8"],
|
||||
"requirements": ["uiprotect==1.20.0", "unifi-discovery==1.1.8"],
|
||||
"ssdp": [
|
||||
{
|
||||
"manufacturer": "Ubiquiti Networks",
|
||||
|
|
|
@ -10,6 +10,7 @@ import logging
|
|||
from operator import attrgetter
|
||||
from typing import Any, Generic, TypeVar
|
||||
|
||||
from uiprotect import make_enabled_getter, make_required_getter, make_value_getter
|
||||
from uiprotect.data import (
|
||||
NVR,
|
||||
Event,
|
||||
|
@ -19,8 +20,6 @@ from uiprotect.data import (
|
|||
|
||||
from homeassistant.helpers.entity import EntityDescription
|
||||
|
||||
from .utils import get_nested_attr
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
T = TypeVar("T", bound=ProtectAdoptableDeviceModel | NVR)
|
||||
|
@ -61,22 +60,16 @@ class ProtectEntityDescription(EntityDescription, Generic[T]):
|
|||
"""Override get_ufp_value, has_required, and get_ufp_enabled if required."""
|
||||
_setter = partial(object.__setattr__, self)
|
||||
|
||||
if (_ufp_value := self.ufp_value) is not None:
|
||||
ufp_value = tuple(_ufp_value.split("."))
|
||||
_setter("get_ufp_value", partial(get_nested_attr, attrs=ufp_value))
|
||||
if (ufp_value := self.ufp_value) is not None:
|
||||
_setter("get_ufp_value", make_value_getter(ufp_value))
|
||||
elif (ufp_value_fn := self.ufp_value_fn) is not None:
|
||||
_setter("get_ufp_value", ufp_value_fn)
|
||||
|
||||
if (_ufp_enabled := self.ufp_enabled) is not None:
|
||||
ufp_enabled = tuple(_ufp_enabled.split("."))
|
||||
_setter("get_ufp_enabled", partial(get_nested_attr, attrs=ufp_enabled))
|
||||
if (ufp_enabled := self.ufp_enabled) is not None:
|
||||
_setter("get_ufp_enabled", make_enabled_getter(ufp_enabled))
|
||||
|
||||
if (_ufp_required_field := self.ufp_required_field) is not None:
|
||||
ufp_required_field = tuple(_ufp_required_field.split("."))
|
||||
_setter(
|
||||
"has_required",
|
||||
lambda obj: bool(get_nested_attr(obj, ufp_required_field)),
|
||||
)
|
||||
if (ufp_required_field := self.ufp_required_field) is not None:
|
||||
_setter("has_required", make_required_getter(ufp_required_field))
|
||||
|
||||
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
|
|
|
@ -4,10 +4,9 @@ from __future__ import annotations
|
|||
|
||||
from collections.abc import Iterable
|
||||
import contextlib
|
||||
from enum import Enum
|
||||
from pathlib import Path
|
||||
import socket
|
||||
from typing import TYPE_CHECKING, Any
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from aiohttp import CookieJar
|
||||
from typing_extensions import Generator
|
||||
|
@ -42,21 +41,6 @@ from .const import (
|
|||
if TYPE_CHECKING:
|
||||
from .data import UFPConfigEntry
|
||||
|
||||
_SENTINEL = object()
|
||||
|
||||
|
||||
def get_nested_attr(obj: Any, attrs: tuple[str, ...]) -> Any:
|
||||
"""Fetch a nested attribute."""
|
||||
if len(attrs) == 1:
|
||||
value = getattr(obj, attrs[0], None)
|
||||
else:
|
||||
value = obj
|
||||
for key in attrs:
|
||||
if (value := getattr(value, key, _SENTINEL)) is _SENTINEL:
|
||||
return None
|
||||
|
||||
return value.value if isinstance(value, Enum) else value
|
||||
|
||||
|
||||
@callback
|
||||
def _async_unifi_mac_from_hass(mac: str) -> str:
|
||||
|
|
|
@ -2794,7 +2794,7 @@ twitchAPI==4.0.0
|
|||
uasiren==0.0.1
|
||||
|
||||
# homeassistant.components.unifiprotect
|
||||
uiprotect==1.19.3
|
||||
uiprotect==1.20.0
|
||||
|
||||
# homeassistant.components.landisgyr_heat_meter
|
||||
ultraheat-api==0.5.7
|
||||
|
|
|
@ -2174,7 +2174,7 @@ twitchAPI==4.0.0
|
|||
uasiren==0.0.1
|
||||
|
||||
# homeassistant.components.unifiprotect
|
||||
uiprotect==1.19.3
|
||||
uiprotect==1.20.0
|
||||
|
||||
# homeassistant.components.landisgyr_heat_meter
|
||||
ultraheat-api==0.5.7
|
||||
|
|
Loading…
Reference in New Issue