Skip to content

Commit

Permalink
Move get_custom_ids_by_entity_keys to device (#1518)
Browse files Browse the repository at this point in the history
  • Loading branch information
SukramJ authored Apr 19, 2024
1 parent cf886f5 commit 364a2b9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
17 changes: 0 additions & 17 deletions hahomematic/central/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,23 +616,6 @@ def get_readable_generic_entities(
)
)

def get_custom_ids_by_entity_keys(self, entity_keys: set[ENTITY_KEY]) -> set[str]:
"""Return the custom ids by entity keys."""
return {
entity.custom_id
for entity in self.get_entities(exclude_no_create=False, registered=True)
if (
(
(isinstance(entity, BaseParameterEntity) and entity.entity_key in entity_keys)
or (
isinstance(entity, CustomEntity)
and entity.has_entity_key(entity_keys=entity_keys)
)
)
and entity.custom_id is not None
)
}

def _get_primary_client(self) -> hmcl.Client | None:
"""Return the client by interface_id or the first with a virtual remote."""
client: hmcl.Client | None = None
Expand Down
17 changes: 17 additions & 0 deletions hahomematic/platforms/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,23 @@ def get_sub_device_channel(self, channel_no: int) -> int | None:
"""Return the sub device channel."""
return self._sub_device_channels.get(channel_no)

def get_custom_ids_by_entity_keys(self, entity_keys: set[ENTITY_KEY]) -> set[str]:
"""Return the custom ids by entity keys."""
return {
entity.custom_id
for entity in self.get_entities(exclude_no_create=False, registered=True)
if (
(
(isinstance(entity, BaseParameterEntity) and entity.entity_key in entity_keys)
or (
isinstance(entity, hmce.CustomEntity)
and entity.has_entity_key(entity_keys=entity_keys)
)
)
and entity.custom_id is not None
)
}

def add_entity(self, entity: CallbackEntity) -> None:
"""Add a hm entity to a device."""
if isinstance(entity, BaseParameterEntity):
Expand Down

0 comments on commit 364a2b9

Please sign in to comment.