From 4cfd24a03a87f4326a634974e9b5b75692c7d349 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Wed, 27 Nov 2019 20:27:22 -0800 Subject: [PATCH] Fix mobile app device identifiers (#29173) --- homeassistant/components/mobile_app/__init__.py | 7 +------ tests/components/mobile_app/test_entity.py | 5 +++++ 2 files changed, 6 insertions(+), 6 deletions(-) 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."""