diff --git a/homeassistant/components/mobile_app/__init__.py b/homeassistant/components/mobile_app/__init__.py index ca2a58d1f96..56594f3e2c3 100644 --- a/homeassistant/components/mobile_app/__init__.py +++ b/homeassistant/components/mobile_app/__init__.py @@ -76,14 +76,9 @@ async def async_setup_entry(hass, entry): device_registry = await dr.async_get_registry(hass) - identifiers = { - (ATTR_DEVICE_ID, registration[ATTR_DEVICE_ID]), - (CONF_WEBHOOK_ID, registration[CONF_WEBHOOK_ID]), - } - device = device_registry.async_get_or_create( config_entry_id=entry.entry_id, - identifiers=identifiers, + identifiers={(DOMAIN, registration[ATTR_DEVICE_ID])}, manufacturer=registration[ATTR_MANUFACTURER], model=registration[ATTR_MODEL], name=registration[ATTR_DEVICE_NAME], diff --git a/tests/components/mobile_app/test_entity.py b/tests/components/mobile_app/test_entity.py index 94a4e76ae84..0db9d42048f 100644 --- a/tests/components/mobile_app/test_entity.py +++ b/tests/components/mobile_app/test_entity.py @@ -2,6 +2,8 @@ import logging +from homeassistant.helpers import device_registry + _LOGGER = logging.getLogger(__name__) @@ -64,6 +66,9 @@ async def test_sensor(hass, create_registrations, webhook_client): updated_entity = hass.states.get("sensor.battery_state") assert updated_entity.state == "123" + dev_reg = await device_registry.async_get_registry(hass) + assert len(dev_reg.devices) == len(create_registrations) + async def test_sensor_must_register(hass, create_registrations, webhook_client): """Test that sensors must be registered before updating."""