Fall back to domain for conversation agents without title (#92014)

This commit is contained in:
Erik Montnemery 2023-04-25 22:14:44 +02:00 committed by GitHub
parent 78a49ecbce
commit 18f7b92438
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 1 deletions

View file

@ -442,7 +442,7 @@ class AgentManager:
agents.append(
AgentInfo(
id=agent_id,
name=config_entry.title,
name=config_entry.title or config_entry.domain,
)
)
return agents

View file

@ -17,6 +17,12 @@
'name': 'Mock Title',
})
# ---
# name: test_get_agent_info.3
dict({
'id': 'mock-entry',
'name': 'test',
})
# ---
# name: test_get_agent_list
dict({
'agents': list([

View file

@ -1642,6 +1642,13 @@ async def test_get_agent_info(
assert conversation.async_get_agent_info(hass, mock_agent.agent_id) == snapshot
assert conversation.async_get_agent_info(hass, "not exist") is None
# Test the name when config entry title is empty
agent_entry = hass.config_entries.async_get_entry("mock-entry")
hass.config_entries.async_update_entry(agent_entry, title="")
agent_info = conversation.async_get_agent_info(hass)
assert agent_info == snapshot
async def test_ws_get_agent_info(
hass: HomeAssistant,