GeoFency unique ID and device info (#24232)

pull/24305/head
Paulus Schoutsen 2019-05-31 22:59:44 -07:00
parent dc8d4ac8e4
commit 362f23a950
2 changed files with 20 additions and 0 deletions

View File

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

View File

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