Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial restructuring #3

Merged
merged 1 commit into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 0 additions & 115 deletions zha/api.py

This file was deleted.

Empty file added zha/application/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions zha/core/discovery.py → zha/application/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
from .helpers import get_zha_data, get_zha_gateway

if TYPE_CHECKING:
from ..entity import ZhaEntity
from ..application.entity import ZhaEntity
from .device import ZHADevice
from .endpoint import Endpoint
from .group import ZHAGroup
Expand Down Expand Up @@ -292,9 +292,9 @@ def discover_quirks_v2_entities(self, device: ZHADevice) -> None:
not in cluster_handler.ZCL_INIT_ATTRS
):
init_attrs = cluster_handler.ZCL_INIT_ATTRS.copy()
init_attrs[
quirk_metadata.entity_metadata.attribute_name
] = quirk_metadata.attribute_initialized_from_cache
init_attrs[quirk_metadata.entity_metadata.attribute_name] = (
quirk_metadata.attribute_initialized_from_cache
)
cluster_handler.__dict__[zha_const.ZCL_INIT_ATTRS] = init_attrs

endpoint.async_new_entity(
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions zha/core/gateway.py → zha/application/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
if TYPE_CHECKING:
from logging import Filter, LogRecord

from ..entity import ZhaEntity
from ..application.entity import ZhaEntity
from .cluster_handlers import ClusterHandler

_LogFilterType = Filter | Callable[[LogRecord], bool]
Expand Down Expand Up @@ -132,9 +132,9 @@ def __init__(
self._groups: dict[int, ZHAGroup] = {}
self.application_controller: ControllerApplication = None
self.coordinator_zha_device: ZHADevice = None # type: ignore[assignment]
self._device_registry: collections.defaultdict[
EUI64, list[EntityReference]
] = collections.defaultdict(list)
self._device_registry: collections.defaultdict[EUI64, list[EntityReference]] = (
collections.defaultdict(list)
)
self._log_levels: dict[str, dict[str, int]] = {
DEBUG_LEVEL_ORIGINAL: async_capture_log_levels(),
DEBUG_LEVEL_CURRENT: async_capture_log_levels(),
Expand Down
File renamed without changes.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
38 changes: 19 additions & 19 deletions zha/core/registries.py → zha/application/registries.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from .decorators import DictRegistry, NestedDictRegistry, SetRegistry

if TYPE_CHECKING:
from ..entity import ZhaEntity, ZhaGroupEntity
from ..application.entity import ZhaEntity, ZhaGroupEntity
from .cluster_handlers import ClientClusterHandler, ClusterHandler


Expand Down Expand Up @@ -107,12 +107,12 @@
DEVICE_CLASS = collections.defaultdict(dict, DEVICE_CLASS)

CLUSTER_HANDLER_ONLY_CLUSTERS = SetRegistry()
CLIENT_CLUSTER_HANDLER_REGISTRY: DictRegistry[
type[ClientClusterHandler]
] = DictRegistry()
ZIGBEE_CLUSTER_HANDLER_REGISTRY: NestedDictRegistry[
type[ClusterHandler]
] = NestedDictRegistry()
CLIENT_CLUSTER_HANDLER_REGISTRY: DictRegistry[type[ClientClusterHandler]] = (
DictRegistry()
)
ZIGBEE_CLUSTER_HANDLER_REGISTRY: NestedDictRegistry[type[ClusterHandler]] = (
NestedDictRegistry()
)

WEIGHT_ATTR = attrgetter("weight")

Expand Down Expand Up @@ -277,9 +277,9 @@ class ZHAEntityRegistry:

def __init__(self) -> None:
"""Initialize Registry instance."""
self._strict_registry: dict[
Platform, dict[MatchRule, type[ZhaEntity]]
] = collections.defaultdict(dict)
self._strict_registry: dict[Platform, dict[MatchRule, type[ZhaEntity]]] = (
collections.defaultdict(dict)
)
self._multi_entity_registry: dict[
Platform, dict[int | str | None, dict[MatchRule, list[type[ZhaEntity]]]]
] = collections.defaultdict(
Expand All @@ -291,9 +291,9 @@ def __init__(self) -> None:
lambda: collections.defaultdict(lambda: collections.defaultdict(list))
)
self._group_registry: dict[str, type[ZhaGroupEntity]] = {}
self.single_device_matches: dict[
Platform, dict[EUI64, list[str]]
] = collections.defaultdict(lambda: collections.defaultdict(list))
self.single_device_matches: dict[Platform, dict[EUI64, list[str]]] = (
collections.defaultdict(lambda: collections.defaultdict(list))
)

def get_entity(
self,
Expand Down Expand Up @@ -323,9 +323,9 @@ def get_multi_entity(
dict[Platform, list[EntityClassAndClusterHandlers]], list[ClusterHandler]
]:
"""Match ZHA cluster handlers to potentially multiple ZHA Entity classes."""
result: dict[
Platform, list[EntityClassAndClusterHandlers]
] = collections.defaultdict(list)
result: dict[Platform, list[EntityClassAndClusterHandlers]] = (
collections.defaultdict(list)
)
all_claimed: set[ClusterHandler] = set()
for component, stop_match_groups in self._multi_entity_registry.items():
for stop_match_grp, matches in stop_match_groups.items():
Expand Down Expand Up @@ -356,9 +356,9 @@ def get_config_diagnostic_entity(
dict[Platform, list[EntityClassAndClusterHandlers]], list[ClusterHandler]
]:
"""Match ZHA cluster handlers to potentially multiple ZHA Entity classes."""
result: dict[
Platform, list[EntityClassAndClusterHandlers]
] = collections.defaultdict(list)
result: dict[Platform, list[EntityClassAndClusterHandlers]] = (
collections.defaultdict(list)
)
all_claimed: set[ClusterHandler] = set()
for (
component,
Expand Down
21 changes: 0 additions & 21 deletions zha/backup.py

This file was deleted.

Loading
Loading