mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 04:37:06 +00:00
GeoFency unique ID and device info (#24232)
This commit is contained in:
parent
3edc58a04e
commit
e6a54013dc
@ -43,6 +43,7 @@ class GeofencyEntity(DeviceTrackerEntity):
|
|||||||
self._location_name = location_name
|
self._location_name = location_name
|
||||||
self._gps = gps
|
self._gps = gps
|
||||||
self._unsub_dispatcher = None
|
self._unsub_dispatcher = None
|
||||||
|
self._unique_id = device
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
@ -74,6 +75,19 @@ class GeofencyEntity(DeviceTrackerEntity):
|
|||||||
"""No polling needed."""
|
"""No polling needed."""
|
||||||
return False
|
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
|
@property
|
||||||
def source_type(self):
|
def source_type(self):
|
||||||
"""Return the source type, eg gps or router, of the device."""
|
"""Return the source type, eg gps or router, of the device."""
|
||||||
|
@ -217,6 +217,12 @@ async def test_gps_enter_and_exit_home(hass, geofency_client, webhook_id):
|
|||||||
'device_tracker', device_name)).attributes['longitude']
|
'device_tracker', device_name)).attributes['longitude']
|
||||||
assert NOT_HOME_LONGITUDE == current_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):
|
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."""
|
"""Test iBeacon based zone enter and exit - a.k.a stationary iBeacon."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user