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

Allow passing area/device/entity IDs to floor_id and floor_name (#114748)

This commit is contained in:
Robert Resch
2024-04-03 16:33:58 +02:00
committed by GitHub
parent f91994d788
commit 7adced6876
2 changed files with 115 additions and 26 deletions

View File

@@ -1408,6 +1408,12 @@ def floor_id(hass: HomeAssistant, lookup_value: Any) -> str | None:
floor_registry = fr.async_get(hass)
if floor := floor_registry.async_get_floor_by_name(str(lookup_value)):
return floor.floor_id
if aid := area_id(hass, lookup_value):
area_reg = area_registry.async_get(hass)
if area := area_reg.async_get_area(aid):
return area.floor_id
return None
@@ -1416,6 +1422,16 @@ def floor_name(hass: HomeAssistant, lookup_value: str) -> str | None:
floor_registry = fr.async_get(hass)
if floor := floor_registry.async_get_floor(lookup_value):
return floor.name
if aid := area_id(hass, lookup_value):
area_reg = area_registry.async_get(hass)
if (
(area := area_reg.async_get_area(aid))
and area.floor_id
and (floor := floor_registry.async_get_floor(area.floor_id))
):
return floor.name
return None