Remove unnecessary type definitions in zha (#73735)
* Cleanup ZigpyClusterType * Cleanup ZigpyDeviceType * Cleanup ZigpyEndpointType * Cleanup ZigpyGroupType * Cleanup ZigpyZdoTypepull/73744/head
parent
b145aeaf75
commit
2de4b193e3
|
@ -8,6 +8,7 @@ import logging
|
||||||
from typing import TYPE_CHECKING, Any
|
from typing import TYPE_CHECKING, Any
|
||||||
|
|
||||||
import zigpy.exceptions
|
import zigpy.exceptions
|
||||||
|
import zigpy.zcl
|
||||||
from zigpy.zcl.foundation import (
|
from zigpy.zcl.foundation import (
|
||||||
CommandSchema,
|
CommandSchema,
|
||||||
ConfigureReportingResponseRecord,
|
ConfigureReportingResponseRecord,
|
||||||
|
@ -19,7 +20,6 @@ from homeassistant.const import ATTR_COMMAND
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||||
|
|
||||||
from .. import typing as zha_typing
|
|
||||||
from ..const import (
|
from ..const import (
|
||||||
ATTR_ARGS,
|
ATTR_ARGS,
|
||||||
ATTR_ATTRIBUTE_ID,
|
ATTR_ATTRIBUTE_ID,
|
||||||
|
@ -107,9 +107,7 @@ class ZigbeeChannel(LogMixin):
|
||||||
# attribute read is acceptable.
|
# attribute read is acceptable.
|
||||||
ZCL_INIT_ATTRS: dict[int | str, bool] = {}
|
ZCL_INIT_ATTRS: dict[int | str, bool] = {}
|
||||||
|
|
||||||
def __init__(
|
def __init__(self, cluster: zigpy.zcl.Cluster, ch_pool: ChannelPool) -> None:
|
||||||
self, cluster: zha_typing.ZigpyClusterType, ch_pool: ChannelPool
|
|
||||||
) -> None:
|
|
||||||
"""Initialize ZigbeeChannel."""
|
"""Initialize ZigbeeChannel."""
|
||||||
self._generic_id = f"channel_0x{cluster.cluster_id:04x}"
|
self._generic_id = f"channel_0x{cluster.cluster_id:04x}"
|
||||||
self._ch_pool = ch_pool
|
self._ch_pool = ch_pool
|
||||||
|
|
|
@ -7,13 +7,14 @@ from typing import TYPE_CHECKING, Any
|
||||||
|
|
||||||
import zigpy.exceptions
|
import zigpy.exceptions
|
||||||
import zigpy.types as t
|
import zigpy.types as t
|
||||||
|
import zigpy.zcl
|
||||||
from zigpy.zcl.clusters import general
|
from zigpy.zcl.clusters import general
|
||||||
from zigpy.zcl.foundation import Status
|
from zigpy.zcl.foundation import Status
|
||||||
|
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers.event import async_call_later
|
from homeassistant.helpers.event import async_call_later
|
||||||
|
|
||||||
from .. import registries, typing as zha_typing
|
from .. import registries
|
||||||
from ..const import (
|
from ..const import (
|
||||||
REPORT_CONFIG_ASAP,
|
REPORT_CONFIG_ASAP,
|
||||||
REPORT_CONFIG_BATTERY_SAVE,
|
REPORT_CONFIG_BATTERY_SAVE,
|
||||||
|
@ -307,9 +308,7 @@ class OnOffChannel(ZigbeeChannel):
|
||||||
"start_up_on_off": True,
|
"start_up_on_off": True,
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(
|
def __init__(self, cluster: zigpy.zcl.Cluster, ch_pool: ChannelPool) -> None:
|
||||||
self, cluster: zha_typing.ZigpyClusterType, ch_pool: ChannelPool
|
|
||||||
) -> None:
|
|
||||||
"""Initialize OnOffChannel."""
|
"""Initialize OnOffChannel."""
|
||||||
super().__init__(cluster, ch_pool)
|
super().__init__(cluster, ch_pool)
|
||||||
self._off_listener = None
|
self._off_listener = None
|
||||||
|
|
|
@ -4,9 +4,11 @@ from __future__ import annotations
|
||||||
import logging
|
import logging
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
import zigpy.zcl
|
||||||
|
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
|
|
||||||
from .. import registries, typing as zha_typing
|
from .. import registries
|
||||||
from ..const import (
|
from ..const import (
|
||||||
ATTR_ATTRIBUTE_ID,
|
ATTR_ATTRIBUTE_ID,
|
||||||
ATTR_ATTRIBUTE_NAME,
|
ATTR_ATTRIBUTE_NAME,
|
||||||
|
@ -60,9 +62,7 @@ class OppleRemote(ZigbeeChannel):
|
||||||
|
|
||||||
REPORT_CONFIG = []
|
REPORT_CONFIG = []
|
||||||
|
|
||||||
def __init__(
|
def __init__(self, cluster: zigpy.zcl.Cluster, ch_pool: ChannelPool) -> None:
|
||||||
self, cluster: zha_typing.ZigpyClusterType, ch_pool: ChannelPool
|
|
||||||
) -> None:
|
|
||||||
"""Initialize Opple channel."""
|
"""Initialize Opple channel."""
|
||||||
super().__init__(cluster, ch_pool)
|
super().__init__(cluster, ch_pool)
|
||||||
if self.cluster.endpoint.model == "lumi.motion.ac02":
|
if self.cluster.endpoint.model == "lumi.motion.ac02":
|
||||||
|
|
|
@ -10,12 +10,13 @@ import asyncio
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from zigpy.exceptions import ZigbeeException
|
from zigpy.exceptions import ZigbeeException
|
||||||
|
import zigpy.zcl
|
||||||
from zigpy.zcl.clusters import security
|
from zigpy.zcl.clusters import security
|
||||||
from zigpy.zcl.clusters.security import IasAce as AceCluster
|
from zigpy.zcl.clusters.security import IasAce as AceCluster
|
||||||
|
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
|
|
||||||
from .. import registries, typing as zha_typing
|
from .. import registries
|
||||||
from ..const import (
|
from ..const import (
|
||||||
SIGNAL_ATTR_UPDATED,
|
SIGNAL_ATTR_UPDATED,
|
||||||
WARNING_DEVICE_MODE_EMERGENCY,
|
WARNING_DEVICE_MODE_EMERGENCY,
|
||||||
|
@ -51,9 +52,7 @@ SIGNAL_ALARM_TRIGGERED = "zha_armed_triggered"
|
||||||
class IasAce(ZigbeeChannel):
|
class IasAce(ZigbeeChannel):
|
||||||
"""IAS Ancillary Control Equipment channel."""
|
"""IAS Ancillary Control Equipment channel."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(self, cluster: zigpy.zcl.Cluster, ch_pool: ChannelPool) -> None:
|
||||||
self, cluster: zha_typing.ZigpyClusterType, ch_pool: ChannelPool
|
|
||||||
) -> None:
|
|
||||||
"""Initialize IAS Ancillary Control Equipment channel."""
|
"""Initialize IAS Ancillary Control Equipment channel."""
|
||||||
super().__init__(cluster, ch_pool)
|
super().__init__(cluster, ch_pool)
|
||||||
self.command_map: dict[int, CALLABLE_T] = {
|
self.command_map: dict[int, CALLABLE_T] = {
|
||||||
|
|
|
@ -5,9 +5,10 @@ import enum
|
||||||
from functools import partialmethod
|
from functools import partialmethod
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
import zigpy.zcl
|
||||||
from zigpy.zcl.clusters import smartenergy
|
from zigpy.zcl.clusters import smartenergy
|
||||||
|
|
||||||
from .. import registries, typing as zha_typing
|
from .. import registries
|
||||||
from ..const import (
|
from ..const import (
|
||||||
REPORT_CONFIG_ASAP,
|
REPORT_CONFIG_ASAP,
|
||||||
REPORT_CONFIG_DEFAULT,
|
REPORT_CONFIG_DEFAULT,
|
||||||
|
@ -118,9 +119,7 @@ class Metering(ZigbeeChannel):
|
||||||
DEMAND = 0
|
DEMAND = 0
|
||||||
SUMMATION = 1
|
SUMMATION = 1
|
||||||
|
|
||||||
def __init__(
|
def __init__(self, cluster: zigpy.zcl.Cluster, ch_pool: ChannelPool) -> None:
|
||||||
self, cluster: zha_typing.ZigpyClusterType, ch_pool: ChannelPool
|
|
||||||
) -> None:
|
|
||||||
"""Initialize Metering."""
|
"""Initialize Metering."""
|
||||||
super().__init__(cluster, ch_pool)
|
super().__init__(cluster, ch_pool)
|
||||||
self._format_spec = None
|
self._format_spec = None
|
||||||
|
|
|
@ -12,6 +12,7 @@ import time
|
||||||
from typing import TYPE_CHECKING, Any
|
from typing import TYPE_CHECKING, Any
|
||||||
|
|
||||||
from zigpy import types
|
from zigpy import types
|
||||||
|
import zigpy.device
|
||||||
import zigpy.exceptions
|
import zigpy.exceptions
|
||||||
from zigpy.profiles import PROFILES
|
from zigpy.profiles import PROFILES
|
||||||
import zigpy.quirks
|
import zigpy.quirks
|
||||||
|
@ -27,7 +28,7 @@ from homeassistant.helpers.dispatcher import (
|
||||||
)
|
)
|
||||||
from homeassistant.helpers.event import async_track_time_interval
|
from homeassistant.helpers.event import async_track_time_interval
|
||||||
|
|
||||||
from . import channels, typing as zha_typing
|
from . import channels
|
||||||
from .const import (
|
from .const import (
|
||||||
ATTR_ARGS,
|
ATTR_ARGS,
|
||||||
ATTR_ATTRIBUTE,
|
ATTR_ATTRIBUTE,
|
||||||
|
@ -100,7 +101,7 @@ class ZHADevice(LogMixin):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
zigpy_device: zha_typing.ZigpyDeviceType,
|
zigpy_device: zigpy.device.Device,
|
||||||
zha_gateway: ZHAGateway,
|
zha_gateway: ZHAGateway,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the gateway."""
|
"""Initialize the gateway."""
|
||||||
|
@ -151,7 +152,7 @@ class ZHADevice(LogMixin):
|
||||||
self._ha_device_id = device_id
|
self._ha_device_id = device_id
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device(self) -> zha_typing.ZigpyDeviceType:
|
def device(self) -> zigpy.device.Device:
|
||||||
"""Return underlying Zigpy device."""
|
"""Return underlying Zigpy device."""
|
||||||
return self._zigpy_device
|
return self._zigpy_device
|
||||||
|
|
||||||
|
@ -332,7 +333,7 @@ class ZHADevice(LogMixin):
|
||||||
def new(
|
def new(
|
||||||
cls,
|
cls,
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
zigpy_dev: zha_typing.ZigpyDeviceType,
|
zigpy_dev: zigpy.device.Device,
|
||||||
gateway: ZHAGateway,
|
gateway: ZHAGateway,
|
||||||
restored: bool = False,
|
restored: bool = False,
|
||||||
):
|
):
|
||||||
|
|
|
@ -21,6 +21,7 @@ import voluptuous as vol
|
||||||
import zigpy.exceptions
|
import zigpy.exceptions
|
||||||
import zigpy.types
|
import zigpy.types
|
||||||
import zigpy.util
|
import zigpy.util
|
||||||
|
import zigpy.zcl
|
||||||
import zigpy.zdo.types as zdo_types
|
import zigpy.zdo.types as zdo_types
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
@ -35,7 +36,6 @@ from .const import (
|
||||||
DATA_ZHA_GATEWAY,
|
DATA_ZHA_GATEWAY,
|
||||||
)
|
)
|
||||||
from .registries import BINDABLE_CLUSTERS
|
from .registries import BINDABLE_CLUSTERS
|
||||||
from .typing import ZigpyClusterType
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from .device import ZHADevice
|
from .device import ZHADevice
|
||||||
|
@ -48,7 +48,7 @@ _T = TypeVar("_T")
|
||||||
class BindingPair:
|
class BindingPair:
|
||||||
"""Information for binding."""
|
"""Information for binding."""
|
||||||
|
|
||||||
source_cluster: ZigpyClusterType
|
source_cluster: zigpy.zcl.Cluster
|
||||||
target_ieee: zigpy.types.EUI64
|
target_ieee: zigpy.types.EUI64
|
||||||
target_ep_id: int
|
target_ep_id: int
|
||||||
|
|
||||||
|
|
|
@ -2,16 +2,5 @@
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from typing import TypeVar
|
from typing import TypeVar
|
||||||
|
|
||||||
import zigpy.device
|
|
||||||
import zigpy.endpoint
|
|
||||||
import zigpy.group
|
|
||||||
import zigpy.zcl
|
|
||||||
import zigpy.zdo
|
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
# pylint: disable=invalid-name
|
||||||
CALLABLE_T = TypeVar("CALLABLE_T", bound=Callable)
|
CALLABLE_T = TypeVar("CALLABLE_T", bound=Callable)
|
||||||
ZigpyClusterType = zigpy.zcl.Cluster
|
|
||||||
ZigpyDeviceType = zigpy.device.Device
|
|
||||||
ZigpyEndpointType = zigpy.endpoint.Endpoint
|
|
||||||
ZigpyGroupType = zigpy.group.Group
|
|
||||||
ZigpyZdoType = zigpy.zdo.ZDO
|
|
||||||
|
|
Loading…
Reference in New Issue