Fix mobile app device identifiers (#29173)

pull/29182/head
Paulus Schoutsen 2019-11-27 20:27:22 -08:00 committed by GitHub
parent 665613e395
commit 4cfd24a03a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -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],

View File

@ -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."""