Use device registry CONNECTION_* constants (#49923)

This commit is contained in:
Ville Skyttä 2021-05-01 00:58:50 +03:00 committed by GitHub
parent 7ead482082
commit 77d5244577
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 195 additions and 84 deletions

View file

@ -14,7 +14,7 @@ from homeassistant.const import (
CONF_WEBHOOK_ID, CONF_WEBHOOK_ID,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv, device_registry
from homeassistant.helpers.dispatcher import ( from homeassistant.helpers.dispatcher import (
async_dispatcher_connect, async_dispatcher_connect,
async_dispatcher_send, async_dispatcher_send,
@ -307,7 +307,9 @@ class MinutPointEntity(Entity):
"""Return a device description for device registry.""" """Return a device description for device registry."""
device = self.device.device device = self.device.device
return { return {
"connections": {("mac", device["device_mac"])}, "connections": {
(device_registry.CONNECTION_NETWORK_MAC, device["device_mac"])
},
"identifieres": device["device_id"], "identifieres": device["device_id"],
"manufacturer": "Minut", "manufacturer": "Minut",
"model": f"Point v{device['hardware_version']}", "model": f"Point v{device['hardware_version']}",

View file

@ -13,6 +13,7 @@ from hatasmota.discovery import (
import homeassistant.components.sensor as sensor import homeassistant.components.sensor as sensor
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dev_reg
from homeassistant.helpers.dispatcher import async_dispatcher_send from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.entity_registry import async_entries_for_device from homeassistant.helpers.entity_registry import async_entries_for_device
@ -136,7 +137,9 @@ async def async_start(
device_registry = await hass.helpers.device_registry.async_get_registry() device_registry = await hass.helpers.device_registry.async_get_registry()
entity_registry = await hass.helpers.entity_registry.async_get_registry() entity_registry = await hass.helpers.entity_registry.async_get_registry()
device = device_registry.async_get_device(set(), {("mac", mac)}) device = device_registry.async_get_device(
set(), {(dev_reg.CONNECTION_NETWORK_MAC, mac)}
)
if device is None: if device is None:
_LOGGER.warning("Got sensors for unknown device mac: %s", mac) _LOGGER.warning("Got sensors for unknown device mac: %s", mac)

View file

@ -322,7 +322,8 @@ async def test_remove_orphaned_entries_service(hass, aioclient_mock):
device_registry = dr.async_get(hass) device_registry = dr.async_get(hass)
device = device_registry.async_get_or_create( device = device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id, identifiers={("mac", "123")} config_entry_id=config_entry.entry_id,
connections={(dr.CONNECTION_NETWORK_MAC, "123")},
) )
assert ( assert (

View file

@ -24,7 +24,7 @@ DEFAULT_CONFIG_DEVICE_INFO_ID = {
} }
DEFAULT_CONFIG_DEVICE_INFO_MAC = { DEFAULT_CONFIG_DEVICE_INFO_MAC = {
"connections": [["mac", "02:5b:26:a8:dc:12"]], "connections": [[dr.CONNECTION_NETWORK_MAC, "02:5b:26:a8:dc:12"]],
"manufacturer": "Whatever", "manufacturer": "Whatever",
"name": "Beer", "name": "Beer",
"model": "Glass", "model": "Glass",
@ -760,9 +760,11 @@ async def help_test_entity_device_info_with_connection(hass, mqtt_mock, domain,
async_fire_mqtt_message(hass, f"homeassistant/{domain}/bla/config", data) async_fire_mqtt_message(hass, f"homeassistant/{domain}/bla/config", data)
await hass.async_block_till_done() await hass.async_block_till_done()
device = registry.async_get_device(set(), {("mac", "02:5b:26:a8:dc:12")}) device = registry.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, "02:5b:26:a8:dc:12")}
)
assert device is not None assert device is not None
assert device.connections == {("mac", "02:5b:26:a8:dc:12")} assert device.connections == {(dr.CONNECTION_NETWORK_MAC, "02:5b:26:a8:dc:12")}
assert device.manufacturer == "Whatever" assert device.manufacturer == "Whatever"
assert device.name == "Beer" assert device.name == "Beer"
assert device.model == "Glass" assert device.model == "Glass"

View file

@ -846,7 +846,7 @@ async def test_entity_device_info_with_connection(hass, mqtt_mock):
"type": "foo", "type": "foo",
"subtype": "bar", "subtype": "bar",
"device": { "device": {
"connections": [["mac", "02:5b:26:a8:dc:12"]], "connections": [[dr.CONNECTION_NETWORK_MAC, "02:5b:26:a8:dc:12"]],
"manufacturer": "Whatever", "manufacturer": "Whatever",
"name": "Beer", "name": "Beer",
"model": "Glass", "model": "Glass",
@ -857,9 +857,11 @@ async def test_entity_device_info_with_connection(hass, mqtt_mock):
async_fire_mqtt_message(hass, "homeassistant/device_automation/bla/config", data) async_fire_mqtt_message(hass, "homeassistant/device_automation/bla/config", data)
await hass.async_block_till_done() await hass.async_block_till_done()
device = registry.async_get_device(set(), {("mac", "02:5b:26:a8:dc:12")}) device = registry.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, "02:5b:26:a8:dc:12")}
)
assert device is not None assert device is not None
assert device.connections == {("mac", "02:5b:26:a8:dc:12")} assert device.connections == {(dr.CONNECTION_NETWORK_MAC, "02:5b:26:a8:dc:12")}
assert device.manufacturer == "Whatever" assert device.manufacturer == "Whatever"
assert device.name == "Beer" assert device.name == "Beer"
assert device.model == "Glass" assert device.model == "Glass"
@ -908,7 +910,7 @@ async def test_entity_device_info_update(hass, mqtt_mock):
"subtype": "bar", "subtype": "bar",
"device": { "device": {
"identifiers": ["helloworld"], "identifiers": ["helloworld"],
"connections": [["mac", "02:5b:26:a8:dc:12"]], "connections": [[dr.CONNECTION_NETWORK_MAC, "02:5b:26:a8:dc:12"]],
"manufacturer": "Whatever", "manufacturer": "Whatever",
"name": "Beer", "name": "Beer",
"model": "Glass", "model": "Glass",
@ -1169,7 +1171,7 @@ async def test_trigger_debug_info(hass, mqtt_mock):
"type": "foo", "type": "foo",
"subtype": "bar", "subtype": "bar",
"device": { "device": {
"connections": [["mac", "02:5b:26:a8:dc:12"]], "connections": [[dr.CONNECTION_NETWORK_MAC, "02:5b:26:a8:dc:12"]],
"manufacturer": "Whatever", "manufacturer": "Whatever",
"name": "Beer", "name": "Beer",
"model": "Glass", "model": "Glass",
@ -1180,7 +1182,9 @@ async def test_trigger_debug_info(hass, mqtt_mock):
async_fire_mqtt_message(hass, "homeassistant/device_automation/bla/config", data) async_fire_mqtt_message(hass, "homeassistant/device_automation/bla/config", data)
await hass.async_block_till_done() await hass.async_block_till_done()
device = registry.async_get_device(set(), {("mac", "02:5b:26:a8:dc:12")}) device = registry.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, "02:5b:26:a8:dc:12")}
)
assert device is not None assert device is not None
debug_info_data = await debug_info.info_for_device(hass, device.id) debug_info_data = await debug_info.info_for_device(hass, device.id)

View file

@ -245,12 +245,17 @@ def test_entity_device_info_schema():
MQTT_ENTITY_DEVICE_INFO_SCHEMA({"identifiers": ["abcd"]}) MQTT_ENTITY_DEVICE_INFO_SCHEMA({"identifiers": ["abcd"]})
MQTT_ENTITY_DEVICE_INFO_SCHEMA({"identifiers": "abcd"}) MQTT_ENTITY_DEVICE_INFO_SCHEMA({"identifiers": "abcd"})
# just connection # just connection
MQTT_ENTITY_DEVICE_INFO_SCHEMA({"connections": [["mac", "02:5b:26:a8:dc:12"]]}) MQTT_ENTITY_DEVICE_INFO_SCHEMA(
{"connections": [[dr.CONNECTION_NETWORK_MAC, "02:5b:26:a8:dc:12"]]}
)
# full device info # full device info
MQTT_ENTITY_DEVICE_INFO_SCHEMA( MQTT_ENTITY_DEVICE_INFO_SCHEMA(
{ {
"identifiers": ["helloworld", "hello"], "identifiers": ["helloworld", "hello"],
"connections": [["mac", "02:5b:26:a8:dc:12"], ["zigbee", "zigbee_id"]], "connections": [
[dr.CONNECTION_NETWORK_MAC, "02:5b:26:a8:dc:12"],
[dr.CONNECTION_ZIGBEE, "zigbee_id"],
],
"manufacturer": "Whatever", "manufacturer": "Whatever",
"name": "Beer", "name": "Beer",
"model": "Glass", "model": "Glass",
@ -261,7 +266,10 @@ def test_entity_device_info_schema():
MQTT_ENTITY_DEVICE_INFO_SCHEMA( MQTT_ENTITY_DEVICE_INFO_SCHEMA(
{ {
"identifiers": ["helloworld", "hello"], "identifiers": ["helloworld", "hello"],
"connections": [["mac", "02:5b:26:a8:dc:12"], ["zigbee", "zigbee_id"]], "connections": [
[dr.CONNECTION_NETWORK_MAC, "02:5b:26:a8:dc:12"],
[dr.CONNECTION_ZIGBEE, "zigbee_id"],
],
"manufacturer": "Whatever", "manufacturer": "Whatever",
"name": "Beer", "name": "Beer",
"model": "Glass", "model": "Glass",

View file

@ -386,7 +386,7 @@ async def test_entity_device_info_with_connection(hass, mqtt_mock):
{ {
"topic": "test-topic", "topic": "test-topic",
"device": { "device": {
"connections": [["mac", "02:5b:26:a8:dc:12"]], "connections": [[dr.CONNECTION_NETWORK_MAC, "02:5b:26:a8:dc:12"]],
"manufacturer": "Whatever", "manufacturer": "Whatever",
"name": "Beer", "name": "Beer",
"model": "Glass", "model": "Glass",
@ -397,9 +397,11 @@ async def test_entity_device_info_with_connection(hass, mqtt_mock):
async_fire_mqtt_message(hass, "homeassistant/tag/bla/config", data) async_fire_mqtt_message(hass, "homeassistant/tag/bla/config", data)
await hass.async_block_till_done() await hass.async_block_till_done()
device = registry.async_get_device(set(), {("mac", "02:5b:26:a8:dc:12")}) device = registry.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, "02:5b:26:a8:dc:12")}
)
assert device is not None assert device is not None
assert device.connections == {("mac", "02:5b:26:a8:dc:12")} assert device.connections == {(dr.CONNECTION_NETWORK_MAC, "02:5b:26:a8:dc:12")}
assert device.manufacturer == "Whatever" assert device.manufacturer == "Whatever"
assert device.name == "Beer" assert device.name == "Beer"
assert device.model == "Glass" assert device.model == "Glass"
@ -442,7 +444,7 @@ async def test_entity_device_info_update(hass, mqtt_mock):
"topic": "test-topic", "topic": "test-topic",
"device": { "device": {
"identifiers": ["helloworld"], "identifiers": ["helloworld"],
"connections": [["mac", "02:5b:26:a8:dc:12"]], "connections": [[dr.CONNECTION_NETWORK_MAC, "02:5b:26:a8:dc:12"]],
"manufacturer": "Whatever", "manufacturer": "Whatever",
"name": "Beer", "name": "Beer",
"model": "Glass", "model": "Glass",

View file

@ -58,7 +58,7 @@ async def test_device_registry(hass, config_entry, config, soco):
) )
assert reg_device.model == "Model Name" assert reg_device.model == "Model Name"
assert reg_device.sw_version == "49.2-64250" assert reg_device.sw_version == "49.2-64250"
assert reg_device.connections == {("mac", "00:11:22:33:44:55")} assert reg_device.connections == {(dr.CONNECTION_NETWORK_MAC, "00:11:22:33:44:55")}
assert reg_device.manufacturer == "Sonos" assert reg_device.manufacturer == "Sonos"
assert reg_device.suggested_area == "Zone A" assert reg_device.suggested_area == "Zone A"
assert reg_device.name == "Zone A" assert reg_device.name == "Zone A"

View file

@ -382,7 +382,9 @@ async def help_test_discovery_removal(
await hass.async_block_till_done() await hass.async_block_till_done()
# Verify device and entity registry entries are created # Verify device and entity registry entries are created
device_entry = device_reg.async_get_device(set(), {("mac", config1[CONF_MAC])}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, config1[CONF_MAC])}
)
assert device_entry is not None assert device_entry is not None
entity_entry = entity_reg.async_get(f"{domain}.{entity_id}") entity_entry = entity_reg.async_get(f"{domain}.{entity_id}")
assert entity_entry is not None assert entity_entry is not None
@ -403,7 +405,9 @@ async def help_test_discovery_removal(
await hass.async_block_till_done() await hass.async_block_till_done()
# Verify entity registry entries are cleared # Verify entity registry entries are cleared
device_entry = device_reg.async_get_device(set(), {("mac", config2[CONF_MAC])}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, config2[CONF_MAC])}
)
assert device_entry is not None assert device_entry is not None
entity_entry = entity_reg.async_get(f"{domain}.{entity_id}") entity_entry = entity_reg.async_get(f"{domain}.{entity_id}")
assert entity_entry is None assert entity_entry is None
@ -487,14 +491,18 @@ async def help_test_discovery_device_remove(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
device = device_reg.async_get_device(set(), {("mac", config[CONF_MAC])}) device = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, config[CONF_MAC])}
)
assert device is not None assert device is not None
assert entity_reg.async_get_entity_id(domain, "tasmota", unique_id) assert entity_reg.async_get_entity_id(domain, "tasmota", unique_id)
async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{config[CONF_MAC]}/config", "") async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{config[CONF_MAC]}/config", "")
await hass.async_block_till_done() await hass.async_block_till_done()
device = device_reg.async_get_device(set(), {("mac", config[CONF_MAC])}) device = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, config[CONF_MAC])}
)
assert device is None assert device is None
assert not entity_reg.async_get_entity_id(domain, "tasmota", unique_id) assert not entity_reg.async_get_entity_id(domain, "tasmota", unique_id)

View file

@ -9,6 +9,7 @@ import pytest
import homeassistant.components.automation as automation import homeassistant.components.automation as automation
from homeassistant.components.tasmota.const import DEFAULT_PREFIX, DOMAIN from homeassistant.components.tasmota.const import DEFAULT_PREFIX, DOMAIN
from homeassistant.components.tasmota.device_trigger import async_attach_trigger from homeassistant.components.tasmota.device_trigger import async_attach_trigger
from homeassistant.helpers import device_registry as dr
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from .test_common import DEFAULT_CONFIG from .test_common import DEFAULT_CONFIG
@ -33,7 +34,9 @@ async def test_get_triggers_btn(hass, device_reg, entity_reg, mqtt_mock, setup_t
async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config)) async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config))
await hass.async_block_till_done() await hass.async_block_till_done()
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
expected_triggers = [ expected_triggers = [
{ {
"platform": "device", "platform": "device",
@ -65,7 +68,9 @@ async def test_get_triggers_swc(hass, device_reg, entity_reg, mqtt_mock, setup_t
async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config)) async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config))
await hass.async_block_till_done() await hass.async_block_till_done()
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
expected_triggers = [ expected_triggers = [
{ {
"platform": "device", "platform": "device",
@ -92,7 +97,9 @@ async def test_get_unknown_triggers(
async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config)) async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config))
await hass.async_block_till_done() await hass.async_block_till_done()
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
assert await async_setup_component( assert await async_setup_component(
hass, hass,
@ -133,7 +140,9 @@ async def test_get_non_existing_triggers(
async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config1)) async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config1))
await hass.async_block_till_done() await hass.async_block_till_done()
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
triggers = await async_get_device_automations(hass, "trigger", device_entry.id) triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
assert_lists_same(triggers, []) assert_lists_same(triggers, [])
@ -157,7 +166,9 @@ async def test_discover_bad_triggers(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
triggers = await async_get_device_automations(hass, "trigger", device_entry.id) triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
assert_lists_same(triggers, []) assert_lists_same(triggers, [])
@ -189,7 +200,9 @@ async def test_discover_bad_triggers(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
triggers = await async_get_device_automations(hass, "trigger", device_entry.id) triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
assert_lists_same(triggers, []) assert_lists_same(triggers, [])
@ -231,7 +244,9 @@ async def test_update_remove_triggers(
async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config1)) async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config1))
await hass.async_block_till_done() await hass.async_block_till_done()
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
expected_triggers1 = [ expected_triggers1 = [
{ {
@ -287,7 +302,9 @@ async def test_if_fires_on_mqtt_message_btn(
async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config)) async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config))
await hass.async_block_till_done() await hass.async_block_till_done()
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
assert await async_setup_component( assert await async_setup_component(
hass, hass,
@ -357,7 +374,9 @@ async def test_if_fires_on_mqtt_message_swc(
async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config)) async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config))
await hass.async_block_till_done() await hass.async_block_till_done()
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
assert await async_setup_component( assert await async_setup_component(
hass, hass,
@ -453,7 +472,9 @@ async def test_if_fires_on_mqtt_message_late_discover(
async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config1)) async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config1))
await hass.async_block_till_done() await hass.async_block_till_done()
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
assert await async_setup_component( assert await async_setup_component(
hass, hass,
@ -527,7 +548,9 @@ async def test_if_fires_on_mqtt_message_after_update(
async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config1)) async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config1))
await hass.async_block_till_done() await hass.async_block_till_done()
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
assert await async_setup_component( assert await async_setup_component(
hass, hass,
@ -604,7 +627,9 @@ async def test_no_resubscribe_same_topic(hass, device_reg, mqtt_mock, setup_tasm
async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config)) async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config))
await hass.async_block_till_done() await hass.async_block_till_done()
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
assert await async_setup_component( assert await async_setup_component(
hass, hass,
@ -650,7 +675,9 @@ async def test_not_fires_on_mqtt_message_after_remove_by_mqtt(
async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config)) async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config))
await hass.async_block_till_done() await hass.async_block_till_done()
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
assert await async_setup_component( assert await async_setup_component(
hass, hass,
@ -719,7 +746,9 @@ async def test_not_fires_on_mqtt_message_after_remove_from_registry(
async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config)) async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config))
await hass.async_block_till_done() await hass.async_block_till_done()
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
assert await async_setup_component( assert await async_setup_component(
hass, hass,
@ -774,7 +803,9 @@ async def test_attach_remove(hass, device_reg, mqtt_mock, setup_tasmota):
async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config)) async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config))
await hass.async_block_till_done() await hass.async_block_till_done()
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
calls = [] calls = []
@ -829,7 +860,9 @@ async def test_attach_remove_late(hass, device_reg, mqtt_mock, setup_tasmota):
async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config1)) async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config1))
await hass.async_block_till_done() await hass.async_block_till_done()
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
calls = [] calls = []
@ -894,7 +927,9 @@ async def test_attach_remove_late2(hass, device_reg, mqtt_mock, setup_tasmota):
async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config1)) async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config1))
await hass.async_block_till_done() await hass.async_block_till_done()
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
calls = [] calls = []
@ -940,7 +975,9 @@ async def test_attach_remove_unknown1(hass, device_reg, mqtt_mock, setup_tasmota
async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config1)) async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config1))
await hass.async_block_till_done() await hass.async_block_till_done()
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
remove = await async_attach_trigger( remove = await async_attach_trigger(
hass, hass,
@ -982,7 +1019,9 @@ async def test_attach_unknown_remove_device_from_registry(
async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config1)) async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config1))
await hass.async_block_till_done() await hass.async_block_till_done()
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
await async_attach_trigger( await async_attach_trigger(
hass, hass,
@ -1015,7 +1054,9 @@ async def test_attach_remove_config_entry(hass, device_reg, mqtt_mock, setup_tas
async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config)) async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config))
await hass.async_block_till_done() await hass.async_block_till_done()
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
calls = [] calls = []

View file

@ -5,6 +5,7 @@ from unittest.mock import patch
from homeassistant.components.tasmota.const import DEFAULT_PREFIX from homeassistant.components.tasmota.const import DEFAULT_PREFIX
from homeassistant.components.tasmota.discovery import ALREADY_DISCOVERED from homeassistant.components.tasmota.discovery import ALREADY_DISCOVERED
from homeassistant.helpers import device_registry as dr
from .conftest import setup_tasmota_helper from .conftest import setup_tasmota_helper
from .test_common import DEFAULT_CONFIG, DEFAULT_CONFIG_9_0_0_3 from .test_common import DEFAULT_CONFIG, DEFAULT_CONFIG_9_0_0_3
@ -116,7 +117,9 @@ async def test_correct_config_discovery(
await hass.async_block_till_done() await hass.async_block_till_done()
# Verify device and registry entries are created # Verify device and registry entries are created
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
assert device_entry is not None assert device_entry is not None
entity_entry = entity_reg.async_get("switch.test") entity_entry = entity_reg.async_get("switch.test")
assert entity_entry is not None assert entity_entry is not None
@ -143,7 +146,9 @@ async def test_device_discover(
await hass.async_block_till_done() await hass.async_block_till_done()
# Verify device and registry entries are created # Verify device and registry entries are created
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
assert device_entry is not None assert device_entry is not None
assert device_entry.manufacturer == "Tasmota" assert device_entry.manufacturer == "Tasmota"
assert device_entry.model == config["md"] assert device_entry.model == config["md"]
@ -166,7 +171,9 @@ async def test_device_discover_deprecated(
await hass.async_block_till_done() await hass.async_block_till_done()
# Verify device and registry entries are created # Verify device and registry entries are created
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
assert device_entry is not None assert device_entry is not None
assert device_entry.manufacturer == "Tasmota" assert device_entry.manufacturer == "Tasmota"
assert device_entry.model == config["md"] assert device_entry.model == config["md"]
@ -192,7 +199,9 @@ async def test_device_update(
await hass.async_block_till_done() await hass.async_block_till_done()
# Verify device entry is created # Verify device entry is created
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
assert device_entry is not None assert device_entry is not None
# Update device parameters # Update device parameters
@ -208,7 +217,9 @@ async def test_device_update(
await hass.async_block_till_done() await hass.async_block_till_done()
# Verify device entry is updated # Verify device entry is updated
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
assert device_entry is not None assert device_entry is not None
assert device_entry.model == "Another model" assert device_entry.model == "Another model"
assert device_entry.name == "Another name" assert device_entry.name == "Another name"
@ -230,7 +241,9 @@ async def test_device_remove(
await hass.async_block_till_done() await hass.async_block_till_done()
# Verify device entry is created # Verify device entry is created
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
assert device_entry is not None assert device_entry is not None
async_fire_mqtt_message( async_fire_mqtt_message(
@ -241,7 +254,9 @@ async def test_device_remove(
await hass.async_block_till_done() await hass.async_block_till_done()
# Verify device entry is removed # Verify device entry is removed
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
assert device_entry is None assert device_entry is None
@ -254,18 +269,22 @@ async def test_device_remove_stale(hass, mqtt_mock, caplog, device_reg, setup_ta
# Create a device # Create a device
device_reg.async_get_or_create( device_reg.async_get_or_create(
config_entry_id=config_entry.entry_id, config_entry_id=config_entry.entry_id,
connections={("mac", mac)}, connections={(dr.CONNECTION_NETWORK_MAC, mac)},
) )
# Verify device entry was created # Verify device entry was created
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
assert device_entry is not None assert device_entry is not None
# Remove the device # Remove the device
device_reg.async_remove_device(device_entry.id) device_reg.async_remove_device(device_entry.id)
# Verify device entry is removed # Verify device entry is removed
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
assert device_entry is None assert device_entry is None
@ -284,7 +303,9 @@ async def test_device_rediscover(
await hass.async_block_till_done() await hass.async_block_till_done()
# Verify device entry is created # Verify device entry is created
device_entry1 = device_reg.async_get_device(set(), {("mac", mac)}) device_entry1 = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
assert device_entry1 is not None assert device_entry1 is not None
async_fire_mqtt_message( async_fire_mqtt_message(
@ -295,7 +316,9 @@ async def test_device_rediscover(
await hass.async_block_till_done() await hass.async_block_till_done()
# Verify device entry is removed # Verify device entry is removed
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
assert device_entry is None assert device_entry is None
async_fire_mqtt_message( async_fire_mqtt_message(
@ -306,7 +329,9 @@ async def test_device_rediscover(
await hass.async_block_till_done() await hass.async_block_till_done()
# Verify device entry is created, and id is reused # Verify device entry is created, and id is reused
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
assert device_entry is not None assert device_entry is not None
assert device_entry1.id == device_entry.id assert device_entry1.id == device_entry.id

View file

@ -5,6 +5,7 @@ from unittest.mock import call
from homeassistant.components import websocket_api from homeassistant.components import websocket_api
from homeassistant.components.tasmota.const import DEFAULT_PREFIX from homeassistant.components.tasmota.const import DEFAULT_PREFIX
from homeassistant.helpers import device_registry as dr
from .test_common import DEFAULT_CONFIG from .test_common import DEFAULT_CONFIG
@ -22,14 +23,18 @@ async def test_device_remove(
await hass.async_block_till_done() await hass.async_block_till_done()
# Verify device entry is created # Verify device entry is created
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
assert device_entry is not None assert device_entry is not None
device_reg.async_remove_device(device_entry.id) device_reg.async_remove_device(device_entry.id)
await hass.async_block_till_done() await hass.async_block_till_done()
# Verify device entry is removed # Verify device entry is removed
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
assert device_entry is None assert device_entry is None
# Verify retained discovery topic has been cleared # Verify retained discovery topic has been cleared
@ -52,7 +57,7 @@ async def test_device_remove_non_tasmota_device(
mac = "12:34:56:AB:CD:EF" mac = "12:34:56:AB:CD:EF"
device_entry = device_reg.async_get_or_create( device_entry = device_reg.async_get_or_create(
config_entry_id=config_entry.entry_id, config_entry_id=config_entry.entry_id,
connections={("mac", mac)}, connections={(dr.CONNECTION_NETWORK_MAC, mac)},
) )
assert device_entry is not None assert device_entry is not None
@ -60,7 +65,9 @@ async def test_device_remove_non_tasmota_device(
await hass.async_block_till_done() await hass.async_block_till_done()
# Verify device entry is removed # Verify device entry is removed
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
assert device_entry is None assert device_entry is None
# Verify no Tasmota discovery message was sent # Verify no Tasmota discovery message was sent
@ -76,7 +83,7 @@ async def test_device_remove_stale_tasmota_device(
mac = "12:34:56:AB:CD:EF" mac = "12:34:56:AB:CD:EF"
device_entry = device_reg.async_get_or_create( device_entry = device_reg.async_get_or_create(
config_entry_id=config_entry.entry_id, config_entry_id=config_entry.entry_id,
connections={("mac", mac)}, connections={(dr.CONNECTION_NETWORK_MAC, mac)},
) )
assert device_entry is not None assert device_entry is not None
@ -84,7 +91,9 @@ async def test_device_remove_stale_tasmota_device(
await hass.async_block_till_done() await hass.async_block_till_done()
# Verify device entry is removed # Verify device entry is removed
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
assert device_entry is None assert device_entry is None
# Verify retained discovery topic has been cleared # Verify retained discovery topic has been cleared
@ -109,7 +118,9 @@ async def test_tasmota_ws_remove_discovered_device(
await hass.async_block_till_done() await hass.async_block_till_done()
# Verify device entry is created # Verify device entry is created
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
assert device_entry is not None assert device_entry is not None
client = await hass_ws_client(hass) client = await hass_ws_client(hass)
@ -120,7 +131,9 @@ async def test_tasmota_ws_remove_discovered_device(
assert response["success"] assert response["success"]
# Verify device entry is cleared # Verify device entry is cleared
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
assert device_entry is None assert device_entry is None
@ -135,7 +148,9 @@ async def test_tasmota_ws_remove_discovered_device_twice(
await hass.async_block_till_done() await hass.async_block_till_done()
# Verify device entry is created # Verify device entry is created
device_entry = device_reg.async_get_device(set(), {("mac", mac)}) device_entry = device_reg.async_get_device(
set(), {(dr.CONNECTION_NETWORK_MAC, mac)}
)
assert device_entry is not None assert device_entry is not None
client = await hass_ws_client(hass) client = await hass_ws_client(hass)
@ -163,7 +178,7 @@ async def test_tasmota_ws_remove_non_tasmota_device(
device_entry = device_reg.async_get_or_create( device_entry = device_reg.async_get_or_create(
config_entry_id=config_entry.entry_id, config_entry_id=config_entry.entry_id,
connections={("mac", "12:34:56:AB:CD:EF")}, connections={(dr.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
) )
assert device_entry is not None assert device_entry is not None

View file

@ -1222,11 +1222,11 @@ async def test_disable_config_entry_disables_devices(hass, registry):
entry1 = registry.async_get_or_create( entry1 = registry.async_get_or_create(
config_entry_id=config_entry.entry_id, config_entry_id=config_entry.entry_id,
connections={("mac", "12:34:56:AB:CD:EF")}, connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
) )
entry2 = registry.async_get_or_create( entry2 = registry.async_get_or_create(
config_entry_id=config_entry.entry_id, config_entry_id=config_entry.entry_id,
connections={("mac", "34:56:AB:CD:EF:12")}, connections={(device_registry.CONNECTION_NETWORK_MAC, "34:56:AB:CD:EF:12")},
disabled_by=device_registry.DISABLED_USER, disabled_by=device_registry.DISABLED_USER,
) )

View file

@ -821,7 +821,7 @@ async def test_device_info_called(hass):
unique_id="qwer", unique_id="qwer",
device_info={ device_info={
"identifiers": {("hue", "1234")}, "identifiers": {("hue", "1234")},
"connections": {("mac", "abcd")}, "connections": {(dr.CONNECTION_NETWORK_MAC, "abcd")},
"manufacturer": "test-manuf", "manufacturer": "test-manuf",
"model": "test-model", "model": "test-model",
"name": "test-name", "name": "test-name",
@ -849,7 +849,7 @@ async def test_device_info_called(hass):
device = registry.async_get_device({("hue", "1234")}) device = registry.async_get_device({("hue", "1234")})
assert device is not None assert device is not None
assert device.identifiers == {("hue", "1234")} assert device.identifiers == {("hue", "1234")}
assert device.connections == {("mac", "abcd")} assert device.connections == {(dr.CONNECTION_NETWORK_MAC, "abcd")}
assert device.manufacturer == "test-manuf" assert device.manufacturer == "test-manuf"
assert device.model == "test-model" assert device.model == "test-model"
assert device.name == "test-name" assert device.name == "test-name"
@ -864,7 +864,7 @@ async def test_device_info_not_overrides(hass):
registry = dr.async_get(hass) registry = dr.async_get(hass)
device = registry.async_get_or_create( device = registry.async_get_or_create(
config_entry_id="bla", config_entry_id="bla",
connections={("mac", "abcd")}, connections={(dr.CONNECTION_NETWORK_MAC, "abcd")},
manufacturer="test-manufacturer", manufacturer="test-manufacturer",
model="test-model", model="test-model",
) )
@ -879,7 +879,7 @@ async def test_device_info_not_overrides(hass):
MockEntity( MockEntity(
unique_id="qwer", unique_id="qwer",
device_info={ device_info={
"connections": {("mac", "abcd")}, "connections": {(dr.CONNECTION_NETWORK_MAC, "abcd")},
"default_name": "default name 1", "default_name": "default name 1",
"default_model": "default model 1", "default_model": "default model 1",
"default_manufacturer": "default manufacturer 1", "default_manufacturer": "default manufacturer 1",
@ -898,7 +898,7 @@ async def test_device_info_not_overrides(hass):
assert await entity_platform.async_setup_entry(config_entry) assert await entity_platform.async_setup_entry(config_entry)
await hass.async_block_till_done() await hass.async_block_till_done()
device2 = registry.async_get_device(set(), {("mac", "abcd")}) device2 = registry.async_get_device(set(), {(dr.CONNECTION_NETWORK_MAC, "abcd")})
assert device2 is not None assert device2 is not None
assert device.id == device2.id assert device.id == device2.id
assert device2.manufacturer == "test-manufacturer" assert device2.manufacturer == "test-manufacturer"

View file

@ -6,7 +6,7 @@ import pytest
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.const import EVENT_HOMEASSISTANT_START, STATE_UNAVAILABLE from homeassistant.const import EVENT_HOMEASSISTANT_START, STATE_UNAVAILABLE
from homeassistant.core import CoreState, callback, valid_entity_id from homeassistant.core import CoreState, callback, valid_entity_id
from homeassistant.helpers import entity_registry as er from homeassistant.helpers import device_registry as dr, entity_registry as er
from tests.common import ( from tests.common import (
MockConfigEntry, MockConfigEntry,
@ -686,7 +686,7 @@ async def test_remove_device_removes_entities(hass, registry):
device_entry = device_registry.async_get_or_create( device_entry = device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id, config_entry_id=config_entry.entry_id,
connections={("mac", "12:34:56:AB:CD:EF")}, connections={(dr.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
) )
entry = registry.async_get_or_create( entry = registry.async_get_or_create(
@ -713,13 +713,13 @@ async def test_update_device_race(hass, registry):
# Create device # Create device
device_entry = device_registry.async_get_or_create( device_entry = device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id, config_entry_id=config_entry.entry_id,
connections={("mac", "12:34:56:AB:CD:EF")}, connections={(dr.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
) )
# Update it # Update it
device_registry.async_get_or_create( device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id, config_entry_id=config_entry.entry_id,
identifiers={("bridgeid", "0123")}, identifiers={("bridgeid", "0123")},
connections={("mac", "12:34:56:AB:CD:EF")}, connections={(dr.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
) )
# Add entity to the device # Add entity to the device
entry = registry.async_get_or_create( entry = registry.async_get_or_create(
@ -746,7 +746,7 @@ async def test_disable_device_disables_entities(hass, registry):
device_entry = device_registry.async_get_or_create( device_entry = device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id, config_entry_id=config_entry.entry_id,
connections={("mac", "12:34:56:AB:CD:EF")}, connections={(dr.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
) )
entry1 = registry.async_get_or_create( entry1 = registry.async_get_or_create(
@ -811,7 +811,7 @@ async def test_disable_config_entry_disables_entities(hass, registry):
device_entry = device_registry.async_get_or_create( device_entry = device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id, config_entry_id=config_entry.entry_id,
connections={("mac", "12:34:56:AB:CD:EF")}, connections={(dr.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
) )
entry1 = registry.async_get_or_create( entry1 = registry.async_get_or_create(
@ -877,7 +877,7 @@ async def test_disabled_entities_excluded_from_entity_list(hass, registry):
device_entry = device_registry.async_get_or_create( device_entry = device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id, config_entry_id=config_entry.entry_id,
connections={("mac", "12:34:56:AB:CD:EF")}, connections={(dr.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
) )
entry1 = registry.async_get_or_create( entry1 = registry.async_get_or_create(

View file

@ -19,7 +19,7 @@ from homeassistant.const import (
VOLUME_LITERS, VOLUME_LITERS,
) )
from homeassistant.exceptions import TemplateError from homeassistant.exceptions import TemplateError
from homeassistant.helpers import template from homeassistant.helpers import device_registry as dr, template
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
from homeassistant.util.unit_system import UnitSystem from homeassistant.util.unit_system import UnitSystem
@ -1504,7 +1504,7 @@ async def test_device_entities(hass):
# Test device without entities # Test device without entities
device_entry = device_registry.async_get_or_create( device_entry = device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id, config_entry_id=config_entry.entry_id,
connections={("mac", "12:34:56:AB:CD:EF")}, connections={(dr.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
) )
info = render_to_info(hass, f"{{{{ device_entities('{device_entry.id}') }}}}") info = render_to_info(hass, f"{{{{ device_entities('{device_entry.id}') }}}}")
assert_result_info(info, []) assert_result_info(info, [])