diff --git a/homeassistant/components/geofency/device_tracker.py b/homeassistant/components/geofency/device_tracker.py index e340272c966..0c60d5ef2ce 100644 --- a/homeassistant/components/geofency/device_tracker.py +++ b/homeassistant/components/geofency/device_tracker.py @@ -43,6 +43,7 @@ class GeofencyEntity(DeviceTrackerEntity): self._location_name = location_name self._gps = gps self._unsub_dispatcher = None + self._unique_id = device @property def device_state_attributes(self): @@ -74,6 +75,19 @@ class GeofencyEntity(DeviceTrackerEntity): """No polling needed.""" return False + @property + def unique_id(self): + """Return the unique ID.""" + return self._unique_id + + @property + def device_info(self): + """Return the device info.""" + return { + 'name': self._name, + 'identifiers': {(GF_DOMAIN, self._unique_id)}, + } + @property def source_type(self): """Return the source type, eg gps or router, of the device.""" diff --git a/tests/components/geofency/test_init.py b/tests/components/geofency/test_init.py index 718eb259db5..18f119a7539 100644 --- a/tests/components/geofency/test_init.py +++ b/tests/components/geofency/test_init.py @@ -217,6 +217,12 @@ async def test_gps_enter_and_exit_home(hass, geofency_client, webhook_id): 'device_tracker', device_name)).attributes['longitude'] assert NOT_HOME_LONGITUDE == current_longitude + dev_reg = await hass.helpers.device_registry.async_get_registry() + assert len(dev_reg.devices) == 1 + + ent_reg = await hass.helpers.entity_registry.async_get_registry() + assert len(ent_reg.entities) == 1 + async def test_beacon_enter_and_exit_home(hass, geofency_client, webhook_id): """Test iBeacon based zone enter and exit - a.k.a stationary iBeacon."""