mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Update bond tests to use entity & device registry fixtures (#103708)
This commit is contained in:
parent
5ee826528d
commit
b81f15725f
@ -6,7 +6,6 @@ from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, SERVICE_PRE
|
|||||||
from homeassistant.const import ATTR_ENTITY_ID
|
from homeassistant.const import ATTR_ENTITY_ID
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import entity_registry as er
|
||||||
from homeassistant.helpers.entity_registry import EntityRegistry
|
|
||||||
|
|
||||||
from .common import patch_bond_action, patch_bond_device_state, setup_platform
|
from .common import patch_bond_action, patch_bond_device_state, setup_platform
|
||||||
|
|
||||||
@ -57,7 +56,10 @@ def light(name: str):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_registry(hass: HomeAssistant) -> None:
|
async def test_entity_registry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
entity_registry: er.EntityRegistry,
|
||||||
|
) -> None:
|
||||||
"""Tests that the devices are registered in the entity registry."""
|
"""Tests that the devices are registered in the entity registry."""
|
||||||
await setup_platform(
|
await setup_platform(
|
||||||
hass,
|
hass,
|
||||||
@ -67,14 +69,13 @@ async def test_entity_registry(hass: HomeAssistant) -> None:
|
|||||||
bond_device_id="test-device-id",
|
bond_device_id="test-device-id",
|
||||||
)
|
)
|
||||||
|
|
||||||
registry: EntityRegistry = er.async_get(hass)
|
entity = entity_registry.entities["button.name_1_stop_actions"]
|
||||||
entity = registry.entities["button.name_1_stop_actions"]
|
|
||||||
assert entity.unique_id == "test-hub-id_test-device-id_stop"
|
assert entity.unique_id == "test-hub-id_test-device-id_stop"
|
||||||
entity = registry.entities["button.name_1_start_increasing_brightness"]
|
entity = entity_registry.entities["button.name_1_start_increasing_brightness"]
|
||||||
assert entity.unique_id == "test-hub-id_test-device-id_startincreasingbrightness"
|
assert entity.unique_id == "test-hub-id_test-device-id_startincreasingbrightness"
|
||||||
entity = registry.entities["button.name_1_start_decreasing_brightness"]
|
entity = entity_registry.entities["button.name_1_start_decreasing_brightness"]
|
||||||
assert entity.unique_id == "test-hub-id_test-device-id_startdecreasingbrightness"
|
assert entity.unique_id == "test-hub-id_test-device-id_startdecreasingbrightness"
|
||||||
entity = registry.entities["button.name_1_start_dimmer"]
|
entity = entity_registry.entities["button.name_1_start_dimmer"]
|
||||||
assert entity.unique_id == "test-hub-id_test-device-id_startdimmer"
|
assert entity.unique_id == "test-hub-id_test-device-id_startdimmer"
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ from homeassistant.const import (
|
|||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import entity_registry as er
|
||||||
from homeassistant.helpers.entity_registry import EntityRegistry
|
|
||||||
from homeassistant.util import utcnow
|
from homeassistant.util import utcnow
|
||||||
|
|
||||||
from .common import (
|
from .common import (
|
||||||
@ -72,7 +71,10 @@ def tilt_shades(name: str):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_registry(hass: HomeAssistant) -> None:
|
async def test_entity_registry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
entity_registry: er.EntityRegistry,
|
||||||
|
) -> None:
|
||||||
"""Tests that the devices are registered in the entity registry."""
|
"""Tests that the devices are registered in the entity registry."""
|
||||||
await setup_platform(
|
await setup_platform(
|
||||||
hass,
|
hass,
|
||||||
@ -82,8 +84,7 @@ async def test_entity_registry(hass: HomeAssistant) -> None:
|
|||||||
bond_device_id="test-device-id",
|
bond_device_id="test-device-id",
|
||||||
)
|
)
|
||||||
|
|
||||||
registry: EntityRegistry = er.async_get(hass)
|
entity = entity_registry.entities["cover.name_1"]
|
||||||
entity = registry.entities["cover.name_1"]
|
|
||||||
assert entity.unique_id == "test-hub-id_test-device-id"
|
assert entity.unique_id == "test-hub-id_test-device-id"
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@ from homeassistant.const import (
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||||
from homeassistant.helpers.entity_registry import EntityRegistry
|
|
||||||
from homeassistant.util import utcnow
|
from homeassistant.util import utcnow
|
||||||
|
|
||||||
from .common import (
|
from .common import (
|
||||||
@ -81,7 +80,11 @@ async def turn_fan_on(
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_registry(hass: HomeAssistant) -> None:
|
async def test_entity_registry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
entity_registry: er.EntityRegistry,
|
||||||
|
device_registry: dr.DeviceRegistry,
|
||||||
|
) -> None:
|
||||||
"""Tests that the devices are registered in the entity registry."""
|
"""Tests that the devices are registered in the entity registry."""
|
||||||
await setup_platform(
|
await setup_platform(
|
||||||
hass,
|
hass,
|
||||||
@ -91,11 +94,9 @@ async def test_entity_registry(hass: HomeAssistant) -> None:
|
|||||||
bond_device_id="test-device-id",
|
bond_device_id="test-device-id",
|
||||||
)
|
)
|
||||||
|
|
||||||
registry: EntityRegistry = er.async_get(hass)
|
entity = entity_registry.entities["fan.name_1"]
|
||||||
entity = registry.entities["fan.name_1"]
|
|
||||||
assert entity.unique_id == "test-hub-id_test-device-id"
|
assert entity.unique_id == "test-hub-id_test-device-id"
|
||||||
|
|
||||||
device_registry = dr.async_get(hass)
|
|
||||||
device = device_registry.async_get(entity.device_id)
|
device = device_registry.async_get(entity.device_id)
|
||||||
assert device.configuration_url == "http://some host"
|
assert device.configuration_url == "http://some host"
|
||||||
|
|
||||||
@ -476,7 +477,11 @@ async def test_fan_available(hass: HomeAssistant) -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_setup_smart_by_bond_fan(hass: HomeAssistant) -> None:
|
async def test_setup_smart_by_bond_fan(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
entity_registry: er.EntityRegistry,
|
||||||
|
device_registry: dr.DeviceRegistry,
|
||||||
|
) -> None:
|
||||||
"""Test setting up a fan without a hub."""
|
"""Test setting up a fan without a hub."""
|
||||||
config_entry = await setup_platform(
|
config_entry = await setup_platform(
|
||||||
hass,
|
hass,
|
||||||
@ -491,10 +496,8 @@ async def test_setup_smart_by_bond_fan(hass: HomeAssistant) -> None:
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert hass.states.get("fan.name_1") is not None
|
assert hass.states.get("fan.name_1") is not None
|
||||||
registry = er.async_get(hass)
|
entry = entity_registry.async_get("fan.name_1")
|
||||||
entry = registry.async_get("fan.name_1")
|
|
||||||
assert entry.device_id is not None
|
assert entry.device_id is not None
|
||||||
device_registry = dr.async_get(hass)
|
|
||||||
device = device_registry.async_get(entry.device_id)
|
device = device_registry.async_get(entry.device_id)
|
||||||
assert device is not None
|
assert device is not None
|
||||||
assert device.sw_version == "test-version"
|
assert device.sw_version == "test-version"
|
||||||
@ -505,7 +508,11 @@ async def test_setup_smart_by_bond_fan(hass: HomeAssistant) -> None:
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
|
||||||
async def test_setup_hub_template_fan(hass: HomeAssistant) -> None:
|
async def test_setup_hub_template_fan(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
entity_registry: er.EntityRegistry,
|
||||||
|
device_registry: dr.DeviceRegistry,
|
||||||
|
) -> None:
|
||||||
"""Test setting up a fan on a hub created from a template."""
|
"""Test setting up a fan on a hub created from a template."""
|
||||||
config_entry = await setup_platform(
|
config_entry = await setup_platform(
|
||||||
hass,
|
hass,
|
||||||
@ -521,10 +528,8 @@ async def test_setup_hub_template_fan(hass: HomeAssistant) -> None:
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert hass.states.get("fan.name_1") is not None
|
assert hass.states.get("fan.name_1") is not None
|
||||||
registry = er.async_get(hass)
|
entry = entity_registry.async_get("fan.name_1")
|
||||||
entry = registry.async_get("fan.name_1")
|
|
||||||
assert entry.device_id is not None
|
assert entry.device_id is not None
|
||||||
device_registry = dr.async_get(hass)
|
|
||||||
device = device_registry.async_get(entry.device_id)
|
device = device_registry.async_get(entry.device_id)
|
||||||
assert device is not None
|
assert device is not None
|
||||||
assert device.sw_version is None
|
assert device.sw_version is None
|
||||||
|
@ -12,7 +12,6 @@ from homeassistant.config_entries import ConfigEntryState
|
|||||||
from homeassistant.const import ATTR_ASSUMED_STATE, CONF_ACCESS_TOKEN, CONF_HOST
|
from homeassistant.const import ATTR_ASSUMED_STATE, CONF_ACCESS_TOKEN, CONF_HOST
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||||
from homeassistant.helpers.entity_registry import EntityRegistry
|
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from .common import (
|
from .common import (
|
||||||
@ -82,6 +81,7 @@ async def test_async_setup_raises_fails_if_auth_fails(hass: HomeAssistant) -> No
|
|||||||
|
|
||||||
async def test_async_setup_entry_sets_up_hub_and_supported_domains(
|
async def test_async_setup_entry_sets_up_hub_and_supported_domains(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
|
device_registry: dr.DeviceRegistry,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that configuring entry sets up cover domain."""
|
"""Test that configuring entry sets up cover domain."""
|
||||||
config_entry = MockConfigEntry(
|
config_entry = MockConfigEntry(
|
||||||
@ -112,7 +112,6 @@ async def test_async_setup_entry_sets_up_hub_and_supported_domains(
|
|||||||
assert config_entry.unique_id == "ZXXX12345"
|
assert config_entry.unique_id == "ZXXX12345"
|
||||||
|
|
||||||
# verify hub device is registered correctly
|
# verify hub device is registered correctly
|
||||||
device_registry = dr.async_get(hass)
|
|
||||||
hub = device_registry.async_get_device(identifiers={(DOMAIN, "ZXXX12345")})
|
hub = device_registry.async_get_device(identifiers={(DOMAIN, "ZXXX12345")})
|
||||||
assert hub.name == "bond-name"
|
assert hub.name == "bond-name"
|
||||||
assert hub.manufacturer == "Olibra"
|
assert hub.manufacturer == "Olibra"
|
||||||
@ -153,7 +152,9 @@ async def test_unload_config_entry(hass: HomeAssistant) -> None:
|
|||||||
assert config_entry.state is ConfigEntryState.NOT_LOADED
|
assert config_entry.state is ConfigEntryState.NOT_LOADED
|
||||||
|
|
||||||
|
|
||||||
async def test_old_identifiers_are_removed(hass: HomeAssistant) -> None:
|
async def test_old_identifiers_are_removed(
|
||||||
|
hass: HomeAssistant, device_registry: dr.DeviceRegistry
|
||||||
|
) -> None:
|
||||||
"""Test we remove the old non-unique identifiers."""
|
"""Test we remove the old non-unique identifiers."""
|
||||||
config_entry = MockConfigEntry(
|
config_entry = MockConfigEntry(
|
||||||
domain=DOMAIN,
|
domain=DOMAIN,
|
||||||
@ -163,7 +164,6 @@ async def test_old_identifiers_are_removed(hass: HomeAssistant) -> None:
|
|||||||
|
|
||||||
old_identifers = (DOMAIN, "device_id")
|
old_identifers = (DOMAIN, "device_id")
|
||||||
new_identifiers = (DOMAIN, "ZXXX12345", "device_id")
|
new_identifiers = (DOMAIN, "ZXXX12345", "device_id")
|
||||||
device_registry = dr.async_get(hass)
|
|
||||||
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={old_identifers},
|
identifiers={old_identifers},
|
||||||
@ -201,7 +201,9 @@ async def test_old_identifiers_are_removed(hass: HomeAssistant) -> None:
|
|||||||
assert device_registry.async_get_device(identifiers={new_identifiers}) is not None
|
assert device_registry.async_get_device(identifiers={new_identifiers}) is not None
|
||||||
|
|
||||||
|
|
||||||
async def test_smart_by_bond_device_suggested_area(hass: HomeAssistant) -> None:
|
async def test_smart_by_bond_device_suggested_area(
|
||||||
|
hass: HomeAssistant, device_registry: dr.DeviceRegistry
|
||||||
|
) -> None:
|
||||||
"""Test we can setup a smart by bond device and get the suggested area."""
|
"""Test we can setup a smart by bond device and get the suggested area."""
|
||||||
config_entry = MockConfigEntry(
|
config_entry = MockConfigEntry(
|
||||||
domain=DOMAIN,
|
domain=DOMAIN,
|
||||||
@ -238,13 +240,14 @@ async def test_smart_by_bond_device_suggested_area(hass: HomeAssistant) -> None:
|
|||||||
assert config_entry.state is ConfigEntryState.LOADED
|
assert config_entry.state is ConfigEntryState.LOADED
|
||||||
assert config_entry.unique_id == "KXXX12345"
|
assert config_entry.unique_id == "KXXX12345"
|
||||||
|
|
||||||
device_registry = dr.async_get(hass)
|
|
||||||
device = device_registry.async_get_device(identifiers={(DOMAIN, "KXXX12345")})
|
device = device_registry.async_get_device(identifiers={(DOMAIN, "KXXX12345")})
|
||||||
assert device is not None
|
assert device is not None
|
||||||
assert device.suggested_area == "Den"
|
assert device.suggested_area == "Den"
|
||||||
|
|
||||||
|
|
||||||
async def test_bridge_device_suggested_area(hass: HomeAssistant) -> None:
|
async def test_bridge_device_suggested_area(
|
||||||
|
hass: HomeAssistant, device_registry: dr.DeviceRegistry
|
||||||
|
) -> None:
|
||||||
"""Test we can setup a bridge bond device and get the suggested area."""
|
"""Test we can setup a bridge bond device and get the suggested area."""
|
||||||
config_entry = MockConfigEntry(
|
config_entry = MockConfigEntry(
|
||||||
domain=DOMAIN,
|
domain=DOMAIN,
|
||||||
@ -284,14 +287,16 @@ async def test_bridge_device_suggested_area(hass: HomeAssistant) -> None:
|
|||||||
assert config_entry.state is ConfigEntryState.LOADED
|
assert config_entry.state is ConfigEntryState.LOADED
|
||||||
assert config_entry.unique_id == "ZXXX12345"
|
assert config_entry.unique_id == "ZXXX12345"
|
||||||
|
|
||||||
device_registry = dr.async_get(hass)
|
|
||||||
device = device_registry.async_get_device(identifiers={(DOMAIN, "ZXXX12345")})
|
device = device_registry.async_get_device(identifiers={(DOMAIN, "ZXXX12345")})
|
||||||
assert device is not None
|
assert device is not None
|
||||||
assert device.suggested_area == "Office"
|
assert device.suggested_area == "Office"
|
||||||
|
|
||||||
|
|
||||||
async def test_device_remove_devices(
|
async def test_device_remove_devices(
|
||||||
hass: HomeAssistant, hass_ws_client: WebSocketGenerator
|
hass: HomeAssistant,
|
||||||
|
hass_ws_client: WebSocketGenerator,
|
||||||
|
entity_registry: er.EntityRegistry,
|
||||||
|
device_registry: dr.DeviceRegistry,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test we can only remove a device that no longer exists."""
|
"""Test we can only remove a device that no longer exists."""
|
||||||
assert await async_setup_component(hass, "config", {})
|
assert await async_setup_component(hass, "config", {})
|
||||||
@ -304,11 +309,9 @@ async def test_device_remove_devices(
|
|||||||
bond_device_id="test-device-id",
|
bond_device_id="test-device-id",
|
||||||
)
|
)
|
||||||
|
|
||||||
registry: EntityRegistry = er.async_get(hass)
|
entity = entity_registry.entities["fan.name_1"]
|
||||||
entity = registry.entities["fan.name_1"]
|
|
||||||
assert entity.unique_id == "test-hub-id_test-device-id"
|
assert entity.unique_id == "test-hub-id_test-device-id"
|
||||||
|
|
||||||
device_registry = dr.async_get(hass)
|
|
||||||
device_entry = device_registry.async_get(entity.device_id)
|
device_entry = device_registry.async_get(entity.device_id)
|
||||||
assert (
|
assert (
|
||||||
await remove_device(
|
await remove_device(
|
||||||
|
@ -32,7 +32,6 @@ from homeassistant.const import (
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import entity_registry as er
|
||||||
from homeassistant.helpers.entity_registry import EntityRegistry
|
|
||||||
from homeassistant.util import utcnow
|
from homeassistant.util import utcnow
|
||||||
|
|
||||||
from .common import (
|
from .common import (
|
||||||
@ -153,7 +152,10 @@ def light_brightness_increase_decrease_only(name: str):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async def test_fan_entity_registry(hass: HomeAssistant) -> None:
|
async def test_fan_entity_registry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
entity_registry: er.EntityRegistry,
|
||||||
|
) -> None:
|
||||||
"""Tests that fan with light devices are registered in the entity registry."""
|
"""Tests that fan with light devices are registered in the entity registry."""
|
||||||
await setup_platform(
|
await setup_platform(
|
||||||
hass,
|
hass,
|
||||||
@ -163,12 +165,14 @@ async def test_fan_entity_registry(hass: HomeAssistant) -> None:
|
|||||||
bond_device_id="test-device-id",
|
bond_device_id="test-device-id",
|
||||||
)
|
)
|
||||||
|
|
||||||
registry: EntityRegistry = er.async_get(hass)
|
entity = entity_registry.entities["light.fan_name"]
|
||||||
entity = registry.entities["light.fan_name"]
|
|
||||||
assert entity.unique_id == "test-hub-id_test-device-id"
|
assert entity.unique_id == "test-hub-id_test-device-id"
|
||||||
|
|
||||||
|
|
||||||
async def test_fan_up_light_entity_registry(hass: HomeAssistant) -> None:
|
async def test_fan_up_light_entity_registry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
entity_registry: er.EntityRegistry,
|
||||||
|
) -> None:
|
||||||
"""Tests that fan with up light devices are registered in the entity registry."""
|
"""Tests that fan with up light devices are registered in the entity registry."""
|
||||||
await setup_platform(
|
await setup_platform(
|
||||||
hass,
|
hass,
|
||||||
@ -178,12 +182,14 @@ async def test_fan_up_light_entity_registry(hass: HomeAssistant) -> None:
|
|||||||
bond_device_id="test-device-id",
|
bond_device_id="test-device-id",
|
||||||
)
|
)
|
||||||
|
|
||||||
registry: EntityRegistry = er.async_get(hass)
|
entity = entity_registry.entities["light.fan_name_up_light"]
|
||||||
entity = registry.entities["light.fan_name_up_light"]
|
|
||||||
assert entity.unique_id == "test-hub-id_test-device-id_up_light"
|
assert entity.unique_id == "test-hub-id_test-device-id_up_light"
|
||||||
|
|
||||||
|
|
||||||
async def test_fan_down_light_entity_registry(hass: HomeAssistant) -> None:
|
async def test_fan_down_light_entity_registry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
entity_registry: er.EntityRegistry,
|
||||||
|
) -> None:
|
||||||
"""Tests that fan with down light devices are registered in the entity registry."""
|
"""Tests that fan with down light devices are registered in the entity registry."""
|
||||||
await setup_platform(
|
await setup_platform(
|
||||||
hass,
|
hass,
|
||||||
@ -193,12 +199,14 @@ async def test_fan_down_light_entity_registry(hass: HomeAssistant) -> None:
|
|||||||
bond_device_id="test-device-id",
|
bond_device_id="test-device-id",
|
||||||
)
|
)
|
||||||
|
|
||||||
registry: EntityRegistry = er.async_get(hass)
|
entity = entity_registry.entities["light.fan_name_down_light"]
|
||||||
entity = registry.entities["light.fan_name_down_light"]
|
|
||||||
assert entity.unique_id == "test-hub-id_test-device-id_down_light"
|
assert entity.unique_id == "test-hub-id_test-device-id_down_light"
|
||||||
|
|
||||||
|
|
||||||
async def test_fireplace_entity_registry(hass: HomeAssistant) -> None:
|
async def test_fireplace_entity_registry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
entity_registry: er.EntityRegistry,
|
||||||
|
) -> None:
|
||||||
"""Tests that flame fireplace devices are registered in the entity registry."""
|
"""Tests that flame fireplace devices are registered in the entity registry."""
|
||||||
await setup_platform(
|
await setup_platform(
|
||||||
hass,
|
hass,
|
||||||
@ -208,12 +216,14 @@ async def test_fireplace_entity_registry(hass: HomeAssistant) -> None:
|
|||||||
bond_device_id="test-device-id",
|
bond_device_id="test-device-id",
|
||||||
)
|
)
|
||||||
|
|
||||||
registry: EntityRegistry = er.async_get(hass)
|
entity = entity_registry.entities["light.fireplace_name"]
|
||||||
entity = registry.entities["light.fireplace_name"]
|
|
||||||
assert entity.unique_id == "test-hub-id_test-device-id"
|
assert entity.unique_id == "test-hub-id_test-device-id"
|
||||||
|
|
||||||
|
|
||||||
async def test_fireplace_with_light_entity_registry(hass: HomeAssistant) -> None:
|
async def test_fireplace_with_light_entity_registry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
entity_registry: er.EntityRegistry,
|
||||||
|
) -> None:
|
||||||
"""Tests that flame+light devices are registered in the entity registry."""
|
"""Tests that flame+light devices are registered in the entity registry."""
|
||||||
await setup_platform(
|
await setup_platform(
|
||||||
hass,
|
hass,
|
||||||
@ -223,14 +233,16 @@ async def test_fireplace_with_light_entity_registry(hass: HomeAssistant) -> None
|
|||||||
bond_device_id="test-device-id",
|
bond_device_id="test-device-id",
|
||||||
)
|
)
|
||||||
|
|
||||||
registry: EntityRegistry = er.async_get(hass)
|
entity_flame = entity_registry.entities["light.fireplace_name"]
|
||||||
entity_flame = registry.entities["light.fireplace_name"]
|
|
||||||
assert entity_flame.unique_id == "test-hub-id_test-device-id"
|
assert entity_flame.unique_id == "test-hub-id_test-device-id"
|
||||||
entity_light = registry.entities["light.fireplace_name_light"]
|
entity_light = entity_registry.entities["light.fireplace_name_light"]
|
||||||
assert entity_light.unique_id == "test-hub-id_test-device-id_light"
|
assert entity_light.unique_id == "test-hub-id_test-device-id_light"
|
||||||
|
|
||||||
|
|
||||||
async def test_light_entity_registry(hass: HomeAssistant) -> None:
|
async def test_light_entity_registry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
entity_registry: er.EntityRegistry,
|
||||||
|
) -> None:
|
||||||
"""Tests lights are registered in the entity registry."""
|
"""Tests lights are registered in the entity registry."""
|
||||||
await setup_platform(
|
await setup_platform(
|
||||||
hass,
|
hass,
|
||||||
@ -240,8 +252,7 @@ async def test_light_entity_registry(hass: HomeAssistant) -> None:
|
|||||||
bond_device_id="test-device-id",
|
bond_device_id="test-device-id",
|
||||||
)
|
)
|
||||||
|
|
||||||
registry: EntityRegistry = er.async_get(hass)
|
entity = entity_registry.entities["light.light_name"]
|
||||||
entity = registry.entities["light.light_name"]
|
|
||||||
assert entity.unique_id == "test-hub-id_test-device-id"
|
assert entity.unique_id == "test-hub-id_test-device-id"
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ from homeassistant.const import ATTR_ENTITY_ID, SERVICE_TURN_OFF, SERVICE_TURN_O
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import entity_registry as er
|
||||||
from homeassistant.helpers.entity_registry import EntityRegistry
|
|
||||||
from homeassistant.util import utcnow
|
from homeassistant.util import utcnow
|
||||||
|
|
||||||
from .common import (
|
from .common import (
|
||||||
@ -33,7 +32,10 @@ def generic_device(name: str):
|
|||||||
return {"name": name, "type": DeviceType.GENERIC_DEVICE}
|
return {"name": name, "type": DeviceType.GENERIC_DEVICE}
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_registry(hass: HomeAssistant) -> None:
|
async def test_entity_registry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
entity_registry: er.EntityRegistry,
|
||||||
|
) -> None:
|
||||||
"""Tests that the devices are registered in the entity registry."""
|
"""Tests that the devices are registered in the entity registry."""
|
||||||
await setup_platform(
|
await setup_platform(
|
||||||
hass,
|
hass,
|
||||||
@ -43,8 +45,7 @@ async def test_entity_registry(hass: HomeAssistant) -> None:
|
|||||||
bond_device_id="test-device-id",
|
bond_device_id="test-device-id",
|
||||||
)
|
)
|
||||||
|
|
||||||
registry: EntityRegistry = er.async_get(hass)
|
entity = entity_registry.entities["switch.name_1"]
|
||||||
entity = registry.entities["switch.name_1"]
|
|
||||||
assert entity.unique_id == "test-hub-id_test-device-id"
|
assert entity.unique_id == "test-hub-id_test-device-id"
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user