Fix unifiprotect TypeVar inheritance (#70782)
This commit is contained in:
parent
abdf5bb86a
commit
a5fa40180c
5 changed files with 9 additions and 10 deletions
|
@ -46,7 +46,7 @@ class ProtectRequiredKeysMixin(EntityDescription, Generic[T]):
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class ProtectSetableKeysMixin(ProtectRequiredKeysMixin, Generic[T]):
|
class ProtectSetableKeysMixin(ProtectRequiredKeysMixin[T]):
|
||||||
"""Mixin for settable values."""
|
"""Mixin for settable values."""
|
||||||
|
|
||||||
ufp_set_method: str | None = None
|
ufp_set_method: str | None = None
|
||||||
|
|
|
@ -3,7 +3,6 @@ from __future__ import annotations
|
||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from typing import Generic
|
|
||||||
|
|
||||||
from pyunifiprotect.data.devices import Camera, Doorlock, Light
|
from pyunifiprotect.data.devices import Camera, Doorlock, Light
|
||||||
|
|
||||||
|
@ -31,7 +30,7 @@ class NumberKeysMixin:
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class ProtectNumberEntityDescription(
|
class ProtectNumberEntityDescription(
|
||||||
ProtectSetableKeysMixin, NumberEntityDescription, NumberKeysMixin, Generic[T]
|
ProtectSetableKeysMixin[T], NumberEntityDescription, NumberKeysMixin
|
||||||
):
|
):
|
||||||
"""Describes UniFi Protect Number entity."""
|
"""Describes UniFi Protect Number entity."""
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ from dataclasses import dataclass
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, Final, Generic
|
from typing import Any, Final
|
||||||
|
|
||||||
from pyunifiprotect.api import ProtectApiClient
|
from pyunifiprotect.api import ProtectApiClient
|
||||||
from pyunifiprotect.data import (
|
from pyunifiprotect.data import (
|
||||||
|
@ -104,7 +104,7 @@ SET_DOORBELL_LCD_MESSAGE_SCHEMA = vol.Schema(
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class ProtectSelectEntityDescription(
|
class ProtectSelectEntityDescription(
|
||||||
ProtectSetableKeysMixin, SelectEntityDescription, Generic[T]
|
ProtectSetableKeysMixin[T], SelectEntityDescription
|
||||||
):
|
):
|
||||||
"""Describes UniFi Protect Select entity."""
|
"""Describes UniFi Protect Select entity."""
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, Generic
|
from typing import Any
|
||||||
|
|
||||||
from pyunifiprotect.data import (
|
from pyunifiprotect.data import (
|
||||||
NVR,
|
NVR,
|
||||||
|
@ -54,13 +54,13 @@ DEVICE_CLASS_DETECTION = "unifiprotect__detection"
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class ProtectSensorEntityDescription(
|
class ProtectSensorEntityDescription(
|
||||||
ProtectRequiredKeysMixin, SensorEntityDescription, Generic[T]
|
ProtectRequiredKeysMixin[T], SensorEntityDescription
|
||||||
):
|
):
|
||||||
"""Describes UniFi Protect Sensor entity."""
|
"""Describes UniFi Protect Sensor entity."""
|
||||||
|
|
||||||
precision: int | None = None
|
precision: int | None = None
|
||||||
|
|
||||||
def get_ufp_value(self, obj: ProtectDeviceModel) -> Any:
|
def get_ufp_value(self, obj: T) -> Any:
|
||||||
"""Return value from UniFi Protect device."""
|
"""Return value from UniFi Protect device."""
|
||||||
value = super().get_ufp_value(obj)
|
value = super().get_ufp_value(obj)
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, Generic
|
from typing import Any
|
||||||
|
|
||||||
from pyunifiprotect.data import Camera, RecordingMode, VideoMode
|
from pyunifiprotect.data import Camera, RecordingMode, VideoMode
|
||||||
from pyunifiprotect.data.base import ProtectAdoptableDeviceModel
|
from pyunifiprotect.data.base import ProtectAdoptableDeviceModel
|
||||||
|
@ -24,7 +24,7 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class ProtectSwitchEntityDescription(
|
class ProtectSwitchEntityDescription(
|
||||||
ProtectSetableKeysMixin, SwitchEntityDescription, Generic[T]
|
ProtectSetableKeysMixin[T], SwitchEntityDescription
|
||||||
):
|
):
|
||||||
"""Describes UniFi Protect Switch entity."""
|
"""Describes UniFi Protect Switch entity."""
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue