1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 04:50:05 +00:00

Add the ability to bind the template helper entity to a device (#117753)

This commit is contained in:
dougiteixeira
2024-06-22 07:45:06 -03:00
committed by GitHub
parent f258034f9c
commit 6e32a96ff3
11 changed files with 472 additions and 9 deletions

View File

@@ -6,6 +6,7 @@ import voluptuous as vol
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr, entity_registry as er
from homeassistant.helpers.device import (
async_device_info_to_link_from_device_id,
async_device_info_to_link_from_entity,
async_entity_id_to_device_id,
async_remove_stale_devices_links_keep_current_device,
@@ -90,12 +91,26 @@ async def test_device_info_to_link(
"connections": {("mac", "30:31:32:33:34:00")},
}
result = async_device_info_to_link_from_device_id(hass, device_id=device.id)
assert result == {
"identifiers": {("test", "my_device")},
"connections": {("mac", "30:31:32:33:34:00")},
}
# With a non-existent entity id
result = async_device_info_to_link_from_entity(
hass, entity_id_or_uuid="sensor.invalid"
)
assert result is None
# With a non-existent device id
result = async_device_info_to_link_from_device_id(hass, device_id="abcdefghi")
assert result is None
# With a None device id
result = async_device_info_to_link_from_device_id(hass, device_id=None)
assert result is None
async def test_remove_stale_device_links_keep_entity_device(
hass: HomeAssistant,