Remove invalid type definitions in zha (#73596)
This commit is contained in:
parent
120479acef
commit
06e45893aa
21 changed files with 135 additions and 132 deletions
|
@ -1,5 +1,8 @@
|
|||
"""Alarm control panels on Zigbee Home Automation networks."""
|
||||
from __future__ import annotations
|
||||
|
||||
import functools
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from zigpy.zcl.clusters.security import IasAce
|
||||
|
||||
|
@ -38,9 +41,11 @@ from .core.const import (
|
|||
)
|
||||
from .core.helpers import async_get_zha_config_value
|
||||
from .core.registries import ZHA_ENTITIES
|
||||
from .core.typing import ZhaDeviceType
|
||||
from .entity import ZhaEntity
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .core.device import ZHADevice
|
||||
|
||||
STRICT_MATCH = functools.partial(
|
||||
ZHA_ENTITIES.strict_match, Platform.ALARM_CONTROL_PANEL
|
||||
)
|
||||
|
@ -83,7 +88,7 @@ class ZHAAlarmControlPanel(ZhaEntity, AlarmControlPanelEntity):
|
|||
| AlarmControlPanelEntityFeature.TRIGGER
|
||||
)
|
||||
|
||||
def __init__(self, unique_id, zha_device: ZhaDeviceType, channels, **kwargs):
|
||||
def __init__(self, unique_id, zha_device: ZHADevice, channels, **kwargs):
|
||||
"""Initialize the ZHA alarm control device."""
|
||||
super().__init__(unique_id, zha_device, channels, **kwargs)
|
||||
cfg_entry = zha_device.gateway.config_entry
|
||||
|
|
|
@ -69,11 +69,11 @@ from .core.helpers import (
|
|||
get_matched_clusters,
|
||||
qr_to_install_code,
|
||||
)
|
||||
from .core.typing import ZhaDeviceType
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from homeassistant.components.websocket_api.connection import ActiveConnection
|
||||
|
||||
from .core.device import ZHADevice
|
||||
from .core.gateway import ZHAGateway
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -559,7 +559,7 @@ async def websocket_reconfigure_node(
|
|||
"""Reconfigure a ZHA nodes entities by its ieee address."""
|
||||
zha_gateway: ZHAGateway = hass.data[DATA_ZHA][DATA_ZHA_GATEWAY]
|
||||
ieee: EUI64 = msg[ATTR_IEEE]
|
||||
device: ZhaDeviceType = zha_gateway.get_device(ieee)
|
||||
device: ZHADevice = zha_gateway.get_device(ieee)
|
||||
|
||||
async def forward_messages(data):
|
||||
"""Forward events to websocket."""
|
||||
|
@ -1084,7 +1084,7 @@ def async_load_api(hass: HomeAssistant) -> None:
|
|||
"""Remove a node from the network."""
|
||||
zha_gateway: ZHAGateway = hass.data[DATA_ZHA][DATA_ZHA_GATEWAY]
|
||||
ieee: EUI64 = service.data[ATTR_IEEE]
|
||||
zha_device: ZhaDeviceType = zha_gateway.get_device(ieee)
|
||||
zha_device: ZHADevice = zha_gateway.get_device(ieee)
|
||||
if zha_device is not None and (
|
||||
zha_device.is_coordinator
|
||||
and zha_device.ieee == zha_gateway.application_controller.ieee
|
||||
|
|
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||
import abc
|
||||
import functools
|
||||
import logging
|
||||
from typing import Any
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
import zigpy.exceptions
|
||||
from zigpy.zcl.foundation import Status
|
||||
|
@ -20,9 +20,13 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|||
from .core import discovery
|
||||
from .core.const import CHANNEL_IDENTIFY, DATA_ZHA, SIGNAL_ADD_ENTITIES
|
||||
from .core.registries import ZHA_ENTITIES
|
||||
from .core.typing import ChannelType, ZhaDeviceType
|
||||
from .entity import ZhaEntity
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .core.channels.base import ZigbeeChannel
|
||||
from .core.device import ZHADevice
|
||||
|
||||
|
||||
MULTI_MATCH = functools.partial(ZHA_ENTITIES.multipass_match, Platform.BUTTON)
|
||||
CONFIG_DIAGNOSTIC_MATCH = functools.partial(
|
||||
ZHA_ENTITIES.config_diagnostic_match, Platform.BUTTON
|
||||
|
@ -60,13 +64,13 @@ class ZHAButton(ZhaEntity, ButtonEntity):
|
|||
def __init__(
|
||||
self,
|
||||
unique_id: str,
|
||||
zha_device: ZhaDeviceType,
|
||||
channels: list[ChannelType],
|
||||
zha_device: ZHADevice,
|
||||
channels: list[ZigbeeChannel],
|
||||
**kwargs,
|
||||
) -> None:
|
||||
"""Init this button."""
|
||||
super().__init__(unique_id, zha_device, channels, **kwargs)
|
||||
self._channel: ChannelType = channels[0]
|
||||
self._channel: ZigbeeChannel = channels[0]
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_args(self) -> list[Any]:
|
||||
|
@ -87,8 +91,8 @@ class ZHAIdentifyButton(ZHAButton):
|
|||
def create_entity(
|
||||
cls,
|
||||
unique_id: str,
|
||||
zha_device: ZhaDeviceType,
|
||||
channels: list[ChannelType],
|
||||
zha_device: ZHADevice,
|
||||
channels: list[ZigbeeChannel],
|
||||
**kwargs,
|
||||
) -> ZhaEntity | None:
|
||||
"""Entity Factory.
|
||||
|
@ -120,13 +124,13 @@ class ZHAAttributeButton(ZhaEntity, ButtonEntity):
|
|||
def __init__(
|
||||
self,
|
||||
unique_id: str,
|
||||
zha_device: ZhaDeviceType,
|
||||
channels: list[ChannelType],
|
||||
zha_device: ZHADevice,
|
||||
channels: list[ZigbeeChannel],
|
||||
**kwargs,
|
||||
) -> None:
|
||||
"""Init this button."""
|
||||
super().__init__(unique_id, zha_device, channels, **kwargs)
|
||||
self._channel: ChannelType = channels[0]
|
||||
self._channel: ZigbeeChannel = channels[0]
|
||||
|
||||
async def async_press(self) -> None:
|
||||
"""Write attribute with defined value."""
|
||||
|
|
|
@ -5,7 +5,7 @@ import asyncio
|
|||
from enum import Enum
|
||||
from functools import partialmethod, wraps
|
||||
import logging
|
||||
from typing import Any
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
import zigpy.exceptions
|
||||
from zigpy.zcl.foundation import (
|
||||
|
@ -40,6 +40,9 @@ from ..const import (
|
|||
)
|
||||
from ..helpers import LogMixin, retryable_req, safe_read
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from . import ChannelPool
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -105,7 +108,7 @@ class ZigbeeChannel(LogMixin):
|
|||
ZCL_INIT_ATTRS: dict[int | str, bool] = {}
|
||||
|
||||
def __init__(
|
||||
self, cluster: zha_typing.ZigpyClusterType, ch_pool: zha_typing.ChannelPoolType
|
||||
self, cluster: zha_typing.ZigpyClusterType, ch_pool: ChannelPool
|
||||
) -> None:
|
||||
"""Initialize ZigbeeChannel."""
|
||||
self._generic_id = f"channel_0x{cluster.cluster_id:04x}"
|
||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||
|
||||
import asyncio
|
||||
from collections.abc import Coroutine
|
||||
from typing import Any
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
import zigpy.exceptions
|
||||
import zigpy.types as t
|
||||
|
@ -28,6 +28,9 @@ from ..const import (
|
|||
)
|
||||
from .base import ClientChannel, ZigbeeChannel, parse_and_log_command
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from . import ChannelPool
|
||||
|
||||
|
||||
@registries.ZIGBEE_CHANNEL_REGISTRY.register(general.Alarms.cluster_id)
|
||||
class Alarms(ZigbeeChannel):
|
||||
|
@ -305,7 +308,7 @@ class OnOffChannel(ZigbeeChannel):
|
|||
}
|
||||
|
||||
def __init__(
|
||||
self, cluster: zha_typing.ZigpyClusterType, ch_pool: zha_typing.ChannelPoolType
|
||||
self, cluster: zha_typing.ZigpyClusterType, ch_pool: ChannelPool
|
||||
) -> None:
|
||||
"""Initialize OnOffChannel."""
|
||||
super().__init__(cluster, ch_pool)
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
"""Manufacturer specific channels module for Zigbee Home Automation."""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from homeassistant.core import callback
|
||||
|
||||
|
@ -16,6 +19,9 @@ from ..const import (
|
|||
)
|
||||
from .base import ClientChannel, ZigbeeChannel
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from . import ChannelPool
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -55,7 +61,7 @@ class OppleRemote(ZigbeeChannel):
|
|||
REPORT_CONFIG = []
|
||||
|
||||
def __init__(
|
||||
self, cluster: zha_typing.ZigpyClusterType, ch_pool: zha_typing.ChannelPoolType
|
||||
self, cluster: zha_typing.ZigpyClusterType, ch_pool: ChannelPool
|
||||
) -> None:
|
||||
"""Initialize Opple channel."""
|
||||
super().__init__(cluster, ch_pool)
|
||||
|
|
|
@ -7,6 +7,7 @@ https://home-assistant.io/integrations/zha/
|
|||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from zigpy.exceptions import ZigbeeException
|
||||
from zigpy.zcl.clusters import security
|
||||
|
@ -26,6 +27,9 @@ from ..const import (
|
|||
from ..typing import CALLABLE_T
|
||||
from .base import ChannelStatus, ZigbeeChannel
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from . import ChannelPool
|
||||
|
||||
IAS_ACE_ARM = 0x0000 # ("arm", (t.enum8, t.CharacterString, t.uint8_t), False),
|
||||
IAS_ACE_BYPASS = 0x0001 # ("bypass", (t.LVList(t.uint8_t), t.CharacterString), False),
|
||||
IAS_ACE_EMERGENCY = 0x0002 # ("emergency", (), False),
|
||||
|
@ -48,7 +52,7 @@ class IasAce(ZigbeeChannel):
|
|||
"""IAS Ancillary Control Equipment channel."""
|
||||
|
||||
def __init__(
|
||||
self, cluster: zha_typing.ZigpyClusterType, ch_pool: zha_typing.ChannelPoolType
|
||||
self, cluster: zha_typing.ZigpyClusterType, ch_pool: ChannelPool
|
||||
) -> None:
|
||||
"""Initialize IAS Ancillary Control Equipment channel."""
|
||||
super().__init__(cluster, ch_pool)
|
||||
|
|
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
|||
|
||||
import enum
|
||||
from functools import partialmethod
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from zigpy.zcl.clusters import smartenergy
|
||||
|
||||
|
@ -15,6 +16,9 @@ from ..const import (
|
|||
)
|
||||
from .base import ZigbeeChannel
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from . import ChannelPool
|
||||
|
||||
|
||||
@registries.ZIGBEE_CHANNEL_REGISTRY.register(smartenergy.Calendar.cluster_id)
|
||||
class Calendar(ZigbeeChannel):
|
||||
|
@ -115,7 +119,7 @@ class Metering(ZigbeeChannel):
|
|||
SUMMATION = 1
|
||||
|
||||
def __init__(
|
||||
self, cluster: zha_typing.ZigpyClusterType, ch_pool: zha_typing.ChannelPoolType
|
||||
self, cluster: zha_typing.ZigpyClusterType, ch_pool: ChannelPool
|
||||
) -> None:
|
||||
"""Initialize Metering."""
|
||||
super().__init__(cluster, ch_pool)
|
||||
|
|
|
@ -78,6 +78,7 @@ from .helpers import LogMixin, async_get_zha_config_value
|
|||
|
||||
if TYPE_CHECKING:
|
||||
from ..api import ClusterBinding
|
||||
from .gateway import ZHAGateway
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
_UPDATE_ALIVE_INTERVAL = (60, 90)
|
||||
|
@ -100,7 +101,7 @@ class ZHADevice(LogMixin):
|
|||
self,
|
||||
hass: HomeAssistant,
|
||||
zigpy_device: zha_typing.ZigpyDeviceType,
|
||||
zha_gateway: zha_typing.ZhaGatewayType,
|
||||
zha_gateway: ZHAGateway,
|
||||
) -> None:
|
||||
"""Initialize the gateway."""
|
||||
self.hass = hass
|
||||
|
@ -155,12 +156,12 @@ class ZHADevice(LogMixin):
|
|||
return self._zigpy_device
|
||||
|
||||
@property
|
||||
def channels(self) -> zha_typing.ChannelsType:
|
||||
def channels(self) -> channels.Channels:
|
||||
"""Return ZHA channels."""
|
||||
return self._channels
|
||||
|
||||
@channels.setter
|
||||
def channels(self, value: zha_typing.ChannelsType) -> None:
|
||||
def channels(self, value: channels.Channels) -> None:
|
||||
"""Channels setter."""
|
||||
assert isinstance(value, channels.Channels)
|
||||
self._channels = value
|
||||
|
@ -332,7 +333,7 @@ class ZHADevice(LogMixin):
|
|||
cls,
|
||||
hass: HomeAssistant,
|
||||
zigpy_dev: zha_typing.ZigpyDeviceType,
|
||||
gateway: zha_typing.ZhaGatewayType,
|
||||
gateway: ZHAGateway,
|
||||
restored: bool = False,
|
||||
):
|
||||
"""Create new device."""
|
||||
|
|
|
@ -35,7 +35,7 @@ from .const import (
|
|||
DATA_ZHA_GATEWAY,
|
||||
)
|
||||
from .registries import BINDABLE_CLUSTERS
|
||||
from .typing import ZhaDeviceType, ZigpyClusterType
|
||||
from .typing import ZigpyClusterType
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .device import ZHADevice
|
||||
|
@ -82,7 +82,7 @@ async def safe_read(
|
|||
|
||||
|
||||
async def get_matched_clusters(
|
||||
source_zha_device: ZhaDeviceType, target_zha_device: ZhaDeviceType
|
||||
source_zha_device: ZHADevice, target_zha_device: ZHADevice
|
||||
) -> list[BindingPair]:
|
||||
"""Get matched input/output cluster pairs for 2 devices."""
|
||||
source_clusters = source_zha_device.async_get_std_clusters()
|
||||
|
|
|
@ -17,7 +17,7 @@ from homeassistant.const import Platform
|
|||
# importing channels updates registries
|
||||
from . import channels as zha_channels # noqa: F401 pylint: disable=unused-import
|
||||
from .decorators import DictRegistry, SetRegistry
|
||||
from .typing import CALLABLE_T, ChannelType
|
||||
from .typing import CALLABLE_T
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .channels.base import ClientChannel, ZigbeeChannel
|
||||
|
@ -161,7 +161,7 @@ class MatchRule:
|
|||
weight += 1 * len(self.aux_channels)
|
||||
return weight
|
||||
|
||||
def claim_channels(self, channel_pool: list[ChannelType]) -> list[ChannelType]:
|
||||
def claim_channels(self, channel_pool: list[ZigbeeChannel]) -> list[ZigbeeChannel]:
|
||||
"""Return a list of channels this rule matches + aux channels."""
|
||||
claimed = []
|
||||
if isinstance(self.channel_names, frozenset):
|
||||
|
@ -216,7 +216,7 @@ class EntityClassAndChannels:
|
|||
"""Container for entity class and corresponding channels."""
|
||||
|
||||
entity_class: CALLABLE_T
|
||||
claimed_channel: list[ChannelType]
|
||||
claimed_channel: list[ZigbeeChannel]
|
||||
|
||||
|
||||
class ZHAEntityRegistry:
|
||||
|
@ -247,9 +247,9 @@ class ZHAEntityRegistry:
|
|||
component: str,
|
||||
manufacturer: str,
|
||||
model: str,
|
||||
channels: list[ChannelType],
|
||||
channels: list[ZigbeeChannel],
|
||||
default: CALLABLE_T = None,
|
||||
) -> tuple[CALLABLE_T, list[ChannelType]]:
|
||||
) -> tuple[CALLABLE_T, list[ZigbeeChannel]]:
|
||||
"""Match a ZHA Channels to a ZHA Entity class."""
|
||||
matches = self._strict_registry[component]
|
||||
for match in sorted(matches, key=lambda x: x.weight, reverse=True):
|
||||
|
@ -263,11 +263,11 @@ class ZHAEntityRegistry:
|
|||
self,
|
||||
manufacturer: str,
|
||||
model: str,
|
||||
channels: list[ChannelType],
|
||||
) -> tuple[dict[str, list[EntityClassAndChannels]], list[ChannelType]]:
|
||||
channels: list[ZigbeeChannel],
|
||||
) -> tuple[dict[str, list[EntityClassAndChannels]], list[ZigbeeChannel]]:
|
||||
"""Match ZHA Channels to potentially multiple ZHA Entity classes."""
|
||||
result: dict[str, list[EntityClassAndChannels]] = collections.defaultdict(list)
|
||||
all_claimed: set[ChannelType] = set()
|
||||
all_claimed: set[ZigbeeChannel] = set()
|
||||
for component, stop_match_groups in self._multi_entity_registry.items():
|
||||
for stop_match_grp, matches in stop_match_groups.items():
|
||||
sorted_matches = sorted(matches, key=lambda x: x.weight, reverse=True)
|
||||
|
@ -287,11 +287,11 @@ class ZHAEntityRegistry:
|
|||
self,
|
||||
manufacturer: str,
|
||||
model: str,
|
||||
channels: list[ChannelType],
|
||||
) -> tuple[dict[str, list[EntityClassAndChannels]], list[ChannelType]]:
|
||||
channels: list[ZigbeeChannel],
|
||||
) -> tuple[dict[str, list[EntityClassAndChannels]], list[ZigbeeChannel]]:
|
||||
"""Match ZHA Channels to potentially multiple ZHA Entity classes."""
|
||||
result: dict[str, list[EntityClassAndChannels]] = collections.defaultdict(list)
|
||||
all_claimed: set[ChannelType] = set()
|
||||
all_claimed: set[ZigbeeChannel] = set()
|
||||
for (
|
||||
component,
|
||||
stop_match_groups,
|
||||
|
|
|
@ -5,7 +5,7 @@ from collections import OrderedDict
|
|||
from collections.abc import MutableMapping
|
||||
import datetime
|
||||
import time
|
||||
from typing import cast
|
||||
from typing import TYPE_CHECKING, cast
|
||||
|
||||
import attr
|
||||
|
||||
|
@ -13,7 +13,8 @@ from homeassistant.core import HomeAssistant, callback
|
|||
from homeassistant.helpers.storage import Store
|
||||
from homeassistant.loader import bind_hass
|
||||
|
||||
from .typing import ZhaDeviceType
|
||||
if TYPE_CHECKING:
|
||||
from .device import ZHADevice
|
||||
|
||||
DATA_REGISTRY = "zha_storage"
|
||||
|
||||
|
@ -42,7 +43,7 @@ class ZhaStorage:
|
|||
self._store = Store(hass, STORAGE_VERSION, STORAGE_KEY)
|
||||
|
||||
@callback
|
||||
def async_create_device(self, device: ZhaDeviceType) -> ZhaDeviceEntry:
|
||||
def async_create_device(self, device: ZHADevice) -> ZhaDeviceEntry:
|
||||
"""Create a new ZhaDeviceEntry."""
|
||||
device_entry: ZhaDeviceEntry = ZhaDeviceEntry(
|
||||
name=device.name, ieee=str(device.ieee), last_seen=device.last_seen
|
||||
|
@ -52,7 +53,7 @@ class ZhaStorage:
|
|||
return device_entry
|
||||
|
||||
@callback
|
||||
def async_get_or_create_device(self, device: ZhaDeviceType) -> ZhaDeviceEntry:
|
||||
def async_get_or_create_device(self, device: ZHADevice) -> ZhaDeviceEntry:
|
||||
"""Create a new ZhaDeviceEntry."""
|
||||
ieee_str: str = str(device.ieee)
|
||||
if ieee_str in self.devices:
|
||||
|
@ -60,14 +61,14 @@ class ZhaStorage:
|
|||
return self.async_create_device(device)
|
||||
|
||||
@callback
|
||||
def async_create_or_update_device(self, device: ZhaDeviceType) -> ZhaDeviceEntry:
|
||||
def async_create_or_update_device(self, device: ZHADevice) -> ZhaDeviceEntry:
|
||||
"""Create or update a ZhaDeviceEntry."""
|
||||
if str(device.ieee) in self.devices:
|
||||
return self.async_update_device(device)
|
||||
return self.async_create_device(device)
|
||||
|
||||
@callback
|
||||
def async_delete_device(self, device: ZhaDeviceType) -> None:
|
||||
def async_delete_device(self, device: ZHADevice) -> None:
|
||||
"""Delete ZhaDeviceEntry."""
|
||||
ieee_str: str = str(device.ieee)
|
||||
if ieee_str in self.devices:
|
||||
|
@ -75,7 +76,7 @@ class ZhaStorage:
|
|||
self.async_schedule_save()
|
||||
|
||||
@callback
|
||||
def async_update_device(self, device: ZhaDeviceType) -> ZhaDeviceEntry:
|
||||
def async_update_device(self, device: ZHADevice) -> ZhaDeviceEntry:
|
||||
"""Update name of ZhaDeviceEntry."""
|
||||
ieee_str: str = str(device.ieee)
|
||||
old = self.devices[ieee_str]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"""Typing helpers for ZHA component."""
|
||||
from collections.abc import Callable
|
||||
from typing import TYPE_CHECKING, TypeVar
|
||||
from typing import TypeVar
|
||||
|
||||
import zigpy.device
|
||||
import zigpy.endpoint
|
||||
|
@ -10,33 +10,8 @@ import zigpy.zdo
|
|||
|
||||
# pylint: disable=invalid-name
|
||||
CALLABLE_T = TypeVar("CALLABLE_T", bound=Callable)
|
||||
ChannelType = "ZigbeeChannel"
|
||||
ChannelsType = "Channels"
|
||||
ChannelPoolType = "ChannelPool"
|
||||
ClientChannelType = "ClientChannel"
|
||||
ZDOChannelType = "ZDOChannel"
|
||||
ZhaDeviceType = "ZHADevice"
|
||||
ZhaEntityType = "ZHAEntity"
|
||||
ZhaGatewayType = "ZHAGateway"
|
||||
ZhaGroupType = "ZHAGroupType"
|
||||
ZigpyClusterType = zigpy.zcl.Cluster
|
||||
ZigpyDeviceType = zigpy.device.Device
|
||||
ZigpyEndpointType = zigpy.endpoint.Endpoint
|
||||
ZigpyGroupType = zigpy.group.Group
|
||||
ZigpyZdoType = zigpy.zdo.ZDO
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import homeassistant.components.zha.entity
|
||||
|
||||
from . import channels, device, gateway, group
|
||||
from .channels import base as base_channels
|
||||
|
||||
ChannelType = base_channels.ZigbeeChannel
|
||||
ChannelsType = channels.Channels
|
||||
ChannelPoolType = channels.ChannelPool
|
||||
ClientChannelType = base_channels.ClientChannel
|
||||
ZDOChannelType = base_channels.ZDOChannel
|
||||
ZhaDeviceType = device.ZHADevice
|
||||
ZhaEntityType = homeassistant.components.zha.entity.ZhaEntity
|
||||
ZhaGatewayType = gateway.ZHAGateway
|
||||
ZhaGroupType = group.ZHAGroup
|
||||
|
|
|
@ -4,6 +4,7 @@ from __future__ import annotations
|
|||
import asyncio
|
||||
import functools
|
||||
import logging
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from zigpy.zcl.foundation import Status
|
||||
|
||||
|
@ -37,9 +38,12 @@ from .core.const import (
|
|||
SIGNAL_SET_LEVEL,
|
||||
)
|
||||
from .core.registries import ZHA_ENTITIES
|
||||
from .core.typing import ChannelType, ZhaDeviceType
|
||||
from .entity import ZhaEntity
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .core.channels.base import ZigbeeChannel
|
||||
from .core.device import ZHADevice
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
MULTI_MATCH = functools.partial(ZHA_ENTITIES.multipass_match, Platform.COVER)
|
||||
|
@ -191,8 +195,8 @@ class Shade(ZhaEntity, CoverEntity):
|
|||
def __init__(
|
||||
self,
|
||||
unique_id: str,
|
||||
zha_device: ZhaDeviceType,
|
||||
channels: list[ChannelType],
|
||||
zha_device: ZHADevice,
|
||||
channels: list[ZigbeeChannel],
|
||||
**kwargs,
|
||||
) -> None:
|
||||
"""Initialize the ZHA light."""
|
||||
|
|
|
@ -29,7 +29,7 @@ from .core.const import (
|
|||
SIGNAL_REMOVE,
|
||||
)
|
||||
from .core.helpers import LogMixin
|
||||
from .core.typing import CALLABLE_T, ChannelType, ZhaDeviceType
|
||||
from .core.typing import CALLABLE_T
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .core.channels.base import ZigbeeChannel
|
||||
|
@ -127,7 +127,11 @@ class BaseZhaEntity(LogMixin, entity.Entity):
|
|||
|
||||
@callback
|
||||
def async_accept_signal(
|
||||
self, channel: ChannelType, signal: str, func: CALLABLE_T, signal_override=False
|
||||
self,
|
||||
channel: ZigbeeChannel,
|
||||
signal: str,
|
||||
func: CALLABLE_T,
|
||||
signal_override=False,
|
||||
):
|
||||
"""Accept a signal from a channel."""
|
||||
unsub = None
|
||||
|
@ -181,8 +185,8 @@ class ZhaEntity(BaseZhaEntity, RestoreEntity):
|
|||
def create_entity(
|
||||
cls,
|
||||
unique_id: str,
|
||||
zha_device: ZhaDeviceType,
|
||||
channels: list[ChannelType],
|
||||
zha_device: ZHADevice,
|
||||
channels: list[ZigbeeChannel],
|
||||
**kwargs,
|
||||
) -> ZhaEntity | None:
|
||||
"""Entity Factory.
|
||||
|
|
|
@ -7,7 +7,7 @@ import functools
|
|||
import itertools
|
||||
import logging
|
||||
import random
|
||||
from typing import Any, cast
|
||||
from typing import TYPE_CHECKING, Any, cast
|
||||
|
||||
from zigpy.zcl.clusters.general import Identify, LevelControl, OnOff
|
||||
from zigpy.zcl.clusters.lighting import Color
|
||||
|
@ -62,9 +62,11 @@ from .core.const import (
|
|||
)
|
||||
from .core.helpers import LogMixin, async_get_zha_config_value
|
||||
from .core.registries import ZHA_ENTITIES
|
||||
from .core.typing import ZhaDeviceType
|
||||
from .entity import ZhaEntity, ZhaGroupEntity
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .core.device import ZHADevice
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CAPABILITIES_COLOR_LOOP = 0x4
|
||||
|
@ -341,7 +343,7 @@ class Light(BaseLight, ZhaEntity):
|
|||
_attr_supported_color_modes: set(ColorMode)
|
||||
_REFRESH_INTERVAL = (45, 75)
|
||||
|
||||
def __init__(self, unique_id, zha_device: ZhaDeviceType, channels, **kwargs):
|
||||
def __init__(self, unique_id, zha_device: ZHADevice, channels, **kwargs):
|
||||
"""Initialize the ZHA light."""
|
||||
super().__init__(unique_id, zha_device, channels, **kwargs)
|
||||
self._on_off_channel = self.cluster_channels.get(CHANNEL_ON_OFF)
|
||||
|
|
|
@ -4,6 +4,7 @@ from __future__ import annotations
|
|||
from enum import Enum
|
||||
import functools
|
||||
import logging
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from zigpy import types
|
||||
from zigpy.zcl.clusters.general import OnOff
|
||||
|
@ -26,9 +27,13 @@ from .core.const import (
|
|||
Strobe,
|
||||
)
|
||||
from .core.registries import ZHA_ENTITIES
|
||||
from .core.typing import ChannelType, ZhaDeviceType
|
||||
from .entity import ZhaEntity
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .core.channels.base import ZigbeeChannel
|
||||
from .core.device import ZHADevice
|
||||
|
||||
|
||||
CONFIG_DIAGNOSTIC_MATCH = functools.partial(
|
||||
ZHA_ENTITIES.config_diagnostic_match, Platform.SELECT
|
||||
)
|
||||
|
@ -64,14 +69,14 @@ class ZHAEnumSelectEntity(ZhaEntity, SelectEntity):
|
|||
def __init__(
|
||||
self,
|
||||
unique_id: str,
|
||||
zha_device: ZhaDeviceType,
|
||||
channels: list[ChannelType],
|
||||
zha_device: ZHADevice,
|
||||
channels: list[ZigbeeChannel],
|
||||
**kwargs,
|
||||
) -> None:
|
||||
"""Init this select entity."""
|
||||
self._attr_name = self._enum.__name__
|
||||
self._attr_options = [entry.name.replace("_", " ") for entry in self._enum]
|
||||
self._channel: ChannelType = channels[0]
|
||||
self._channel: ZigbeeChannel = channels[0]
|
||||
super().__init__(unique_id, zha_device, channels, **kwargs)
|
||||
|
||||
@property
|
||||
|
@ -150,8 +155,8 @@ class ZCLEnumSelectEntity(ZhaEntity, SelectEntity):
|
|||
def create_entity(
|
||||
cls,
|
||||
unique_id: str,
|
||||
zha_device: ZhaDeviceType,
|
||||
channels: list[ChannelType],
|
||||
zha_device: ZHADevice,
|
||||
channels: list[ZigbeeChannel],
|
||||
**kwargs,
|
||||
) -> ZhaEntity | None:
|
||||
"""Entity Factory.
|
||||
|
@ -175,13 +180,13 @@ class ZCLEnumSelectEntity(ZhaEntity, SelectEntity):
|
|||
def __init__(
|
||||
self,
|
||||
unique_id: str,
|
||||
zha_device: ZhaDeviceType,
|
||||
channels: list[ChannelType],
|
||||
zha_device: ZHADevice,
|
||||
channels: list[ZigbeeChannel],
|
||||
**kwargs,
|
||||
) -> None:
|
||||
"""Init this select entity."""
|
||||
self._attr_options = [entry.name.replace("_", " ") for entry in self._enum]
|
||||
self._channel: ChannelType = channels[0]
|
||||
self._channel: ZigbeeChannel = channels[0]
|
||||
super().__init__(unique_id, zha_device, channels, **kwargs)
|
||||
|
||||
@property
|
||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||
|
||||
import functools
|
||||
import numbers
|
||||
from typing import Any
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from homeassistant.components.climate.const import HVACAction
|
||||
from homeassistant.components.sensor import (
|
||||
|
@ -63,9 +63,12 @@ from .core.const import (
|
|||
SIGNAL_ATTR_UPDATED,
|
||||
)
|
||||
from .core.registries import SMARTTHINGS_HUMIDITY_CLUSTER, ZHA_ENTITIES
|
||||
from .core.typing import ChannelType, ZhaDeviceType
|
||||
from .entity import ZhaEntity
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .core.channels.base import ZigbeeChannel
|
||||
from .core.device import ZHADevice
|
||||
|
||||
PARALLEL_UPDATES = 5
|
||||
|
||||
BATTERY_SIZES = {
|
||||
|
@ -121,20 +124,20 @@ class Sensor(ZhaEntity, SensorEntity):
|
|||
def __init__(
|
||||
self,
|
||||
unique_id: str,
|
||||
zha_device: ZhaDeviceType,
|
||||
channels: list[ChannelType],
|
||||
zha_device: ZHADevice,
|
||||
channels: list[ZigbeeChannel],
|
||||
**kwargs,
|
||||
) -> None:
|
||||
"""Init this sensor."""
|
||||
super().__init__(unique_id, zha_device, channels, **kwargs)
|
||||
self._channel: ChannelType = channels[0]
|
||||
self._channel: ZigbeeChannel = channels[0]
|
||||
|
||||
@classmethod
|
||||
def create_entity(
|
||||
cls,
|
||||
unique_id: str,
|
||||
zha_device: ZhaDeviceType,
|
||||
channels: list[ChannelType],
|
||||
zha_device: ZHADevice,
|
||||
channels: list[ZigbeeChannel],
|
||||
**kwargs,
|
||||
) -> ZhaEntity | None:
|
||||
"""Entity Factory.
|
||||
|
@ -213,8 +216,8 @@ class Battery(Sensor):
|
|||
def create_entity(
|
||||
cls,
|
||||
unique_id: str,
|
||||
zha_device: ZhaDeviceType,
|
||||
channels: list[ChannelType],
|
||||
zha_device: ZHADevice,
|
||||
channels: list[ZigbeeChannel],
|
||||
**kwargs,
|
||||
) -> ZhaEntity | None:
|
||||
"""Entity Factory.
|
||||
|
@ -637,8 +640,8 @@ class ThermostatHVACAction(Sensor, id_suffix="hvac_action"):
|
|||
def create_entity(
|
||||
cls,
|
||||
unique_id: str,
|
||||
zha_device: ZhaDeviceType,
|
||||
channels: list[ChannelType],
|
||||
zha_device: ZHADevice,
|
||||
channels: list[ZigbeeChannel],
|
||||
**kwargs,
|
||||
) -> ZhaEntity | None:
|
||||
"""Entity Factory.
|
||||
|
@ -762,8 +765,8 @@ class RSSISensor(Sensor, id_suffix="rssi"):
|
|||
def create_entity(
|
||||
cls,
|
||||
unique_id: str,
|
||||
zha_device: ZhaDeviceType,
|
||||
channels: list[ChannelType],
|
||||
zha_device: ZHADevice,
|
||||
channels: list[ZigbeeChannel],
|
||||
**kwargs,
|
||||
) -> ZhaEntity | None:
|
||||
"""Entity Factory.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import functools
|
||||
from typing import Any
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from zigpy.zcl.clusters.security import IasWd as WD
|
||||
|
||||
|
@ -38,9 +38,12 @@ from .core.const import (
|
|||
Strobe,
|
||||
)
|
||||
from .core.registries import ZHA_ENTITIES
|
||||
from .core.typing import ChannelType, ZhaDeviceType
|
||||
from .entity import ZhaEntity
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .core.channels.base import ZigbeeChannel
|
||||
from .core.device import ZHADevice
|
||||
|
||||
MULTI_MATCH = functools.partial(ZHA_ENTITIES.multipass_match, Platform.SIREN)
|
||||
DEFAULT_DURATION = 5 # seconds
|
||||
|
||||
|
@ -72,8 +75,8 @@ class ZHASiren(ZhaEntity, SirenEntity):
|
|||
def __init__(
|
||||
self,
|
||||
unique_id: str,
|
||||
zha_device: ZhaDeviceType,
|
||||
channels: list[ChannelType],
|
||||
zha_device: ZHADevice,
|
||||
channels: list[ZigbeeChannel],
|
||||
**kwargs,
|
||||
) -> None:
|
||||
"""Init this siren."""
|
||||
|
|
18
mypy.ini
18
mypy.ini
|
@ -3000,9 +3000,6 @@ ignore_errors = true
|
|||
[mypy-homeassistant.components.xiaomi_miio.switch]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.zha.alarm_control_panel]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.zha.api]
|
||||
ignore_errors = true
|
||||
|
||||
|
@ -3018,9 +3015,6 @@ ignore_errors = true
|
|||
[mypy-homeassistant.components.zha.config_flow]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.zha.core.channels]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.zha.core.channels.base]
|
||||
ignore_errors = true
|
||||
|
||||
|
@ -3039,27 +3033,18 @@ ignore_errors = true
|
|||
[mypy-homeassistant.components.zha.core.channels.lighting]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.zha.core.channels.lightlink]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.zha.core.channels.manufacturerspecific]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.zha.core.channels.measurement]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.zha.core.channels.protocol]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.zha.core.channels.security]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.zha.core.channels.smartenergy]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.zha.core.decorators]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.zha.core.device]
|
||||
ignore_errors = true
|
||||
|
||||
|
@ -3081,9 +3066,6 @@ ignore_errors = true
|
|||
[mypy-homeassistant.components.zha.core.store]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.zha.core.typing]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.zha.cover]
|
||||
ignore_errors = true
|
||||
|
||||
|
|
|
@ -149,26 +149,21 @@ IGNORED_MODULES: Final[list[str]] = [
|
|||
"homeassistant.components.xiaomi_miio.light",
|
||||
"homeassistant.components.xiaomi_miio.sensor",
|
||||
"homeassistant.components.xiaomi_miio.switch",
|
||||
"homeassistant.components.zha.alarm_control_panel",
|
||||
"homeassistant.components.zha.api",
|
||||
"homeassistant.components.zha.binary_sensor",
|
||||
"homeassistant.components.zha.button",
|
||||
"homeassistant.components.zha.climate",
|
||||
"homeassistant.components.zha.config_flow",
|
||||
"homeassistant.components.zha.core.channels",
|
||||
"homeassistant.components.zha.core.channels.base",
|
||||
"homeassistant.components.zha.core.channels.closures",
|
||||
"homeassistant.components.zha.core.channels.general",
|
||||
"homeassistant.components.zha.core.channels.homeautomation",
|
||||
"homeassistant.components.zha.core.channels.hvac",
|
||||
"homeassistant.components.zha.core.channels.lighting",
|
||||
"homeassistant.components.zha.core.channels.lightlink",
|
||||
"homeassistant.components.zha.core.channels.manufacturerspecific",
|
||||
"homeassistant.components.zha.core.channels.measurement",
|
||||
"homeassistant.components.zha.core.channels.protocol",
|
||||
"homeassistant.components.zha.core.channels.security",
|
||||
"homeassistant.components.zha.core.channels.smartenergy",
|
||||
"homeassistant.components.zha.core.decorators",
|
||||
"homeassistant.components.zha.core.device",
|
||||
"homeassistant.components.zha.core.discovery",
|
||||
"homeassistant.components.zha.core.gateway",
|
||||
|
@ -176,7 +171,6 @@ IGNORED_MODULES: Final[list[str]] = [
|
|||
"homeassistant.components.zha.core.helpers",
|
||||
"homeassistant.components.zha.core.registries",
|
||||
"homeassistant.components.zha.core.store",
|
||||
"homeassistant.components.zha.core.typing",
|
||||
"homeassistant.components.zha.cover",
|
||||
"homeassistant.components.zha.device_action",
|
||||
"homeassistant.components.zha.device_tracker",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue