From ae4e042c289d7631998d27e231f0af0170a870e6 Mon Sep 17 00:00:00 2001 From: Ovidiu Nitan Date: Sun, 9 Jun 2024 12:51:38 +0300 Subject: [PATCH 1/2] Convert unique IDs returned by agent_manager.async_get_agent_info to agent IDs --- .../fallback_conversation/__init__.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/custom_components/fallback_conversation/__init__.py b/custom_components/fallback_conversation/__init__.py index 5d2e12b..0a689c8 100644 --- a/custom_components/fallback_conversation/__init__.py +++ b/custom_components/fallback_conversation/__init__.py @@ -146,12 +146,16 @@ async def _async_process_agent( return result - def _convert_agent_info_to_dict(self, agents: list[conversation.AgentInfo]) -> dict[str, str]: + def _convert_agent_info_to_dict(self, agents_info: list[conversation.AgentInfo]) -> dict[str, str]: """Takes a list of AgentInfo and makes it a dict of ID -> Name.""" - r = {} - for agent in agents: - r[agent.id] = agent.name - - return r + agent_manager = conversation.get_agent_manager(self.hass) + r = {} + for agent_info in agents_info: + agent = agent_manager.async_get_agent(agent_info.id) + agent_id = None + if hasattr(agent, "registry_entry"): + agent_id = agent.entity_id + r[agent_id] = agent_info.name + return r From b3f4f783e5aa5218fff7545d27e4f3b056063d7d Mon Sep 17 00:00:00 2001 From: Ovidiu Nitan Date: Wed, 12 Jun 2024 15:41:44 +0300 Subject: [PATCH 2/2] Get entity_id from registry_entry --- custom_components/fallback_conversation/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/fallback_conversation/__init__.py b/custom_components/fallback_conversation/__init__.py index 0a689c8..38f703e 100644 --- a/custom_components/fallback_conversation/__init__.py +++ b/custom_components/fallback_conversation/__init__.py @@ -156,6 +156,6 @@ def _convert_agent_info_to_dict(self, agents_info: list[conversation.AgentInfo]) agent = agent_manager.async_get_agent(agent_info.id) agent_id = None if hasattr(agent, "registry_entry"): - agent_id = agent.entity_id + agent_id = agent.registry_entry.entity_id r[agent_id] = agent_info.name return r