1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-25 05:26:47 +00:00

Fix area_id and area_name template functions (#55470)

This commit is contained in:
Raman Gupta
2021-08-30 16:09:41 -04:00
committed by GitHub
parent 1c01ff401f
commit 1d1b5ab345
2 changed files with 38 additions and 5 deletions

View File

@@ -1828,6 +1828,16 @@ async def test_area_id(hass):
assert_result_info(info, area_entry_entity_id.id)
assert info.rate_limit is None
# Make sure that when entity doesn't have an area but its device does, that's what
# gets returned
entity_entry = entity_registry.async_update_entity(
entity_entry.entity_id, area_id=area_entry_entity_id.id
)
info = render_to_info(hass, f"{{{{ area_id('{entity_entry.entity_id}') }}}}")
assert_result_info(info, area_entry_entity_id.id)
assert info.rate_limit is None
async def test_area_name(hass):
"""Test area_name function."""
@@ -1897,6 +1907,16 @@ async def test_area_name(hass):
assert_result_info(info, area_entry.name)
assert info.rate_limit is None
# Make sure that when entity doesn't have an area but its device does, that's what
# gets returned
entity_entry = entity_registry.async_update_entity(
entity_entry.entity_id, area_id=None
)
info = render_to_info(hass, f"{{{{ area_name('{entity_entry.entity_id}') }}}}")
assert_result_info(info, area_entry.name)
assert info.rate_limit is None
def test_closest_function_to_coord(hass):
"""Test closest function to coord."""