Simplify labels and areas template calls (#115673)

The labels and areas are already exposed on the object
pull/115783/head
J. Nick Koston 2024-04-17 14:28:09 -05:00 committed by GitHub
parent 0aa7946208
commit 11931cdb56
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 3 deletions

View File

@ -1453,8 +1453,7 @@ def floor_areas(hass: HomeAssistant, floor_id_or_name: str) -> Iterable[str]:
def areas(hass: HomeAssistant) -> Iterable[str | None]:
"""Return all areas."""
area_reg = area_registry.async_get(hass)
return [area.id for area in area_reg.async_list_areas()]
return list(area_registry.async_get(hass).areas)
def area_id(hass: HomeAssistant, lookup_value: str) -> str | None:
@ -1580,7 +1579,7 @@ def labels(hass: HomeAssistant, lookup_value: Any = None) -> Iterable[str | None
"""Return all labels, or those from a area ID, device ID, or entity ID."""
label_reg = label_registry.async_get(hass)
if lookup_value is None:
return [label.label_id for label in label_reg.async_list_labels()]
return list(label_reg.labels)
ent_reg = entity_registry.async_get(hass)