mirror of
https://github.com/home-assistant/core
synced 2024-07-18 12:02:20 +02:00
Fix type on known_object_ids in _entity_id_available and async_generate_entity_id (#115378)
This commit is contained in:
parent
9d7e20f9ca
commit
bbecb98927
@ -801,7 +801,7 @@ class EntityPlatform:
|
||||
get_initial_options=entity.get_initial_entity_options,
|
||||
has_entity_name=entity.has_entity_name,
|
||||
hidden_by=hidden_by,
|
||||
known_object_ids=self.entities.keys(),
|
||||
known_object_ids=self.entities,
|
||||
original_device_class=entity.device_class,
|
||||
original_icon=entity.icon,
|
||||
original_name=entity_name,
|
||||
@ -839,7 +839,7 @@ class EntityPlatform:
|
||||
if self.entity_namespace is not None:
|
||||
suggested_object_id = f"{self.entity_namespace} {suggested_object_id}"
|
||||
entity.entity_id = entity_registry.async_generate_entity_id(
|
||||
self.domain, suggested_object_id, self.entities.keys()
|
||||
self.domain, suggested_object_id, self.entities
|
||||
)
|
||||
|
||||
# Make sure it is valid in case an entity set the value themselves
|
||||
|
@ -10,7 +10,7 @@ timer.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Callable, Hashable, Iterable, KeysView, Mapping
|
||||
from collections.abc import Callable, Container, Hashable, KeysView, Mapping
|
||||
from datetime import datetime, timedelta
|
||||
from enum import StrEnum
|
||||
from functools import cached_property
|
||||
@ -714,7 +714,7 @@ class EntityRegistry(BaseRegistry):
|
||||
return list(self.entities.get_device_ids())
|
||||
|
||||
def _entity_id_available(
|
||||
self, entity_id: str, known_object_ids: Iterable[str] | None
|
||||
self, entity_id: str, known_object_ids: Container[str] | None
|
||||
) -> bool:
|
||||
"""Return True if the entity_id is available.
|
||||
|
||||
@ -740,7 +740,7 @@ class EntityRegistry(BaseRegistry):
|
||||
self,
|
||||
domain: str,
|
||||
suggested_object_id: str,
|
||||
known_object_ids: Iterable[str] | None = None,
|
||||
known_object_ids: Container[str] | None = None,
|
||||
) -> str:
|
||||
"""Generate an entity ID that does not conflict.
|
||||
|
||||
@ -753,7 +753,7 @@ class EntityRegistry(BaseRegistry):
|
||||
|
||||
test_string = preferred_string[:MAX_LENGTH_STATE_ENTITY_ID]
|
||||
if known_object_ids is None:
|
||||
known_object_ids = {}
|
||||
known_object_ids = set()
|
||||
|
||||
tries = 1
|
||||
while not self._entity_id_available(test_string, known_object_ids):
|
||||
@ -773,7 +773,7 @@ class EntityRegistry(BaseRegistry):
|
||||
unique_id: str,
|
||||
*,
|
||||
# To influence entity ID generation
|
||||
known_object_ids: Iterable[str] | None = None,
|
||||
known_object_ids: Container[str] | None = None,
|
||||
suggested_object_id: str | None = None,
|
||||
# To disable or hide an entity if it gets created
|
||||
disabled_by: RegistryEntryDisabler | None = None,
|
||||
|
Loading…
Reference in New Issue
Block a user