Fix mobile app device identifiers (#29173)
parent
665613e395
commit
4cfd24a03a
|
@ -76,14 +76,9 @@ async def async_setup_entry(hass, entry):
|
||||||
|
|
||||||
device_registry = await dr.async_get_registry(hass)
|
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(
|
device = device_registry.async_get_or_create(
|
||||||
config_entry_id=entry.entry_id,
|
config_entry_id=entry.entry_id,
|
||||||
identifiers=identifiers,
|
identifiers={(DOMAIN, registration[ATTR_DEVICE_ID])},
|
||||||
manufacturer=registration[ATTR_MANUFACTURER],
|
manufacturer=registration[ATTR_MANUFACTURER],
|
||||||
model=registration[ATTR_MODEL],
|
model=registration[ATTR_MODEL],
|
||||||
name=registration[ATTR_DEVICE_NAME],
|
name=registration[ATTR_DEVICE_NAME],
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from homeassistant.helpers import device_registry
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_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")
|
updated_entity = hass.states.get("sensor.battery_state")
|
||||||
assert updated_entity.state == "123"
|
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):
|
async def test_sensor_must_register(hass, create_registrations, webhook_client):
|
||||||
"""Test that sensors must be registered before updating."""
|
"""Test that sensors must be registered before updating."""
|
||||||
|
|
Loading…
Reference in New Issue