1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Allow UI configuration of entities exposed to voice_assistant (#91233)

* Allow UI configuration of entities exposed to voice_assistant

* Invalidate cache when settings change

* Add tests

* Expose entities to conversation by default

* Update tests
This commit is contained in:
Erik Montnemery
2023-04-12 04:39:40 +02:00
committed by GitHub
parent e40a373c4b
commit 2c9e9d0fde
8 changed files with 473 additions and 107 deletions

View File

@@ -309,6 +309,26 @@ class RegistryEntry:
hass.states.async_set(self.entity_id, STATE_UNAVAILABLE, attrs)
def async_friendly_name(self, hass: HomeAssistant) -> str | None:
"""Return the friendly name.
If self.name is not None, this returns self.name
If has_entity_name is False, self.original_name
If has_entity_name is True, this returns device.name + self.original_name
"""
if not self.has_entity_name or self.name is not None:
return self.name or self.original_name
device_registry = dr.async_get(hass)
if not (device_id := self.device_id) or not (
device_entry := device_registry.async_get(device_id)
):
return self.original_name
if not (original_name := self.original_name):
return device_entry.name_by_user or device_entry.name
return f"{device_entry.name_by_user or device_entry.name} {original_name}"
class EntityRegistryStore(storage.Store[dict[str, list[dict[str, Any]]]]):
"""Store entity registry data."""