Adjust registry access in conversation (#88879)
This commit is contained in:
parent
6ab0b2751d
commit
0e4c32efe2
3 changed files with 94 additions and 68 deletions
|
@ -18,9 +18,9 @@ import yaml
|
|||
|
||||
from homeassistant import core, setup
|
||||
from homeassistant.helpers import (
|
||||
area_registry,
|
||||
device_registry,
|
||||
entity_registry,
|
||||
area_registry as ar,
|
||||
device_registry as dr,
|
||||
entity_registry as er,
|
||||
intent,
|
||||
template,
|
||||
translation,
|
||||
|
@ -95,12 +95,12 @@ class DefaultAgent(AbstractConversationAgent):
|
|||
self._config_intents = config_intents
|
||||
|
||||
self.hass.bus.async_listen(
|
||||
area_registry.EVENT_AREA_REGISTRY_UPDATED,
|
||||
ar.EVENT_AREA_REGISTRY_UPDATED,
|
||||
self._async_handle_area_registry_changed,
|
||||
run_immediately=True,
|
||||
)
|
||||
self.hass.bus.async_listen(
|
||||
entity_registry.EVENT_ENTITY_REGISTRY_UPDATED,
|
||||
er.EVENT_ENTITY_REGISTRY_UPDATED,
|
||||
self._async_handle_entity_registry_changed,
|
||||
run_immediately=True,
|
||||
)
|
||||
|
@ -471,8 +471,8 @@ class DefaultAgent(AbstractConversationAgent):
|
|||
states = [
|
||||
state for state in self.hass.states.async_all() if is_entity_exposed(state)
|
||||
]
|
||||
entities = entity_registry.async_get(self.hass)
|
||||
devices = device_registry.async_get(self.hass)
|
||||
entities = er.async_get(self.hass)
|
||||
devices = dr.async_get(self.hass)
|
||||
|
||||
# Gather exposed entity names
|
||||
entity_names = []
|
||||
|
@ -512,7 +512,7 @@ class DefaultAgent(AbstractConversationAgent):
|
|||
entity_names.append((state.name, state.name, context))
|
||||
|
||||
# Gather areas from exposed entities
|
||||
areas = area_registry.async_get(self.hass)
|
||||
areas = ar.async_get(self.hass)
|
||||
area_names = []
|
||||
for area_id in area_ids_with_entities:
|
||||
area = areas.async_get_area(area_id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue