diff --git a/homeassistant/components/bond/entity.py b/homeassistant/components/bond/entity.py index aa5a7564b3f..716f121f1a1 100644 --- a/homeassistant/components/bond/entity.py +++ b/homeassistant/components/bond/entity.py @@ -27,7 +27,9 @@ class BondEntity(Entity): @property def unique_id(self) -> Optional[str]: """Get unique ID for the entity.""" - return self._device.device_id + hub_id = self._hub.bond_id + device_id = self._device.device_id + return f"{hub_id}_{device_id}" @property def name(self) -> Optional[str]: diff --git a/tests/components/bond/common.py b/tests/components/bond/common.py index bb3329b6a2d..31308746555 100644 --- a/tests/components/bond/common.py +++ b/tests/components/bond/common.py @@ -58,7 +58,7 @@ async def setup_platform( """Set up the specified Bond platform.""" mock_entry = MockConfigEntry( domain=BOND_DOMAIN, - data={CONF_HOST: "1.1.1.1", CONF_ACCESS_TOKEN: "test-token"}, + data={CONF_HOST: "some host", CONF_ACCESS_TOKEN: "test-token"}, ) mock_entry.add_to_hass(hass) diff --git a/tests/components/bond/test_cover.py b/tests/components/bond/test_cover.py index a9d55ce593c..a9083a900e6 100644 --- a/tests/components/bond/test_cover.py +++ b/tests/components/bond/test_cover.py @@ -34,10 +34,17 @@ def shades(name: str): async def test_entity_registry(hass: core.HomeAssistant): """Tests that the devices are registered in the entity registry.""" - await setup_platform(hass, COVER_DOMAIN, shades("name-1")) + await setup_platform( + hass, + COVER_DOMAIN, + shades("name-1"), + bond_version={"bondid": "test-hub-id"}, + bond_device_id="test-device-id", + ) registry: EntityRegistry = await hass.helpers.entity_registry.async_get_registry() - assert [key for key in registry.entities] == ["cover.name_1"] + entity = registry.entities["cover.name_1"] + assert entity.unique_id == "test-hub-id_test-device-id" async def test_open_cover(hass: core.HomeAssistant): diff --git a/tests/components/bond/test_fan.py b/tests/components/bond/test_fan.py index 91f0c21e77a..fa7e59e30e6 100644 --- a/tests/components/bond/test_fan.py +++ b/tests/components/bond/test_fan.py @@ -52,10 +52,17 @@ async def turn_fan_on( async def test_entity_registry(hass: core.HomeAssistant): """Tests that the devices are registered in the entity registry.""" - await setup_platform(hass, FAN_DOMAIN, ceiling_fan("name-1")) + await setup_platform( + hass, + FAN_DOMAIN, + ceiling_fan("name-1"), + bond_version={"bondid": "test-hub-id"}, + bond_device_id="test-device-id", + ) registry: EntityRegistry = await hass.helpers.entity_registry.async_get_registry() - assert [key for key in registry.entities] == ["fan.name_1"] + entity = registry.entities["fan.name_1"] + assert entity.unique_id == "test-hub-id_test-device-id" async def test_non_standard_speed_list(hass: core.HomeAssistant): diff --git a/tests/components/bond/test_light.py b/tests/components/bond/test_light.py index e1167eac107..57ea859240a 100644 --- a/tests/components/bond/test_light.py +++ b/tests/components/bond/test_light.py @@ -57,10 +57,17 @@ def fireplace(name: str): async def test_entity_registry(hass: core.HomeAssistant): """Tests that the devices are registered in the entity registry.""" - await setup_platform(hass, LIGHT_DOMAIN, ceiling_fan("name-1")) + await setup_platform( + hass, + LIGHT_DOMAIN, + ceiling_fan("name-1"), + bond_version={"bondid": "test-hub-id"}, + bond_device_id="test-device-id", + ) registry: EntityRegistry = await hass.helpers.entity_registry.async_get_registry() - assert [key for key in registry.entities] == ["light.name_1"] + entity = registry.entities["light.name_1"] + assert entity.unique_id == "test-hub-id_test-device-id" async def test_sbb_trust_state(hass: core.HomeAssistant): diff --git a/tests/components/bond/test_switch.py b/tests/components/bond/test_switch.py index 8a5803d4eee..2755a491a86 100644 --- a/tests/components/bond/test_switch.py +++ b/tests/components/bond/test_switch.py @@ -29,10 +29,17 @@ def generic_device(name: str): async def test_entity_registry(hass: core.HomeAssistant): """Tests that the devices are registered in the entity registry.""" - await setup_platform(hass, SWITCH_DOMAIN, generic_device("name-1")) + await setup_platform( + hass, + SWITCH_DOMAIN, + generic_device("name-1"), + bond_version={"bondid": "test-hub-id"}, + bond_device_id="test-device-id", + ) registry: EntityRegistry = await hass.helpers.entity_registry.async_get_registry() - assert [key for key in registry.entities] == ["switch.name_1"] + entity = registry.entities["switch.name_1"] + assert entity.unique_id == "test-hub-id_test-device-id" async def test_turn_on_switch(hass: core.HomeAssistant):