1 """Support for the GPSLogger device tracking."""
18 from .
import DOMAIN
as GPL_DOMAIN, TRACKER_UPDATE
29 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
31 """Configure a dispatcher connection based on a config entry."""
34 def _receive_data(device, gps, battery, accuracy, attrs):
35 """Receive set location."""
36 if device
in hass.data[GPL_DOMAIN][
"devices"]:
39 hass.data[GPL_DOMAIN][
"devices"].
add(device)
43 hass.data[GPL_DOMAIN][
"unsub_device_tracker"][entry.entry_id] = (
48 dev_reg = dr.async_get(hass)
51 for device
in dev_reg.devices.get_devices_for_config_entry_id(entry.entry_id)
52 for identifier
in device.identifiers
58 for dev_id
in dev_ids:
59 hass.data[GPL_DOMAIN][
"devices"].
add(dev_id)
61 entities.append(entity)
67 """Represent a tracked device."""
69 _attr_has_entity_name =
True
72 def __init__(self, device, location, battery, accuracy, attributes):
73 """Set up GPSLogger entity."""
84 identifiers={(GPL_DOMAIN, device)},
90 """Return battery value of the device."""
94 """Register state update callback."""
101 if self.latitude
is not None:
111 ATTR_DIRECTION:
None,
118 attr = state.attributes
123 ATTR_ALTITUDE: attr.get(ATTR_ALTITUDE),
124 ATTR_ACTIVITY: attr.get(ATTR_ACTIVITY),
125 ATTR_DIRECTION: attr.get(ATTR_DIRECTION),
126 ATTR_PROVIDER: attr.get(ATTR_PROVIDER),
127 ATTR_SPEED: attr.get(ATTR_SPEED),
129 self.
_battery_battery = attr.get(ATTR_BATTERY_LEVEL)
132 """Clean up after entity before removal."""
138 """Mark the device as seen."""
139 if device != self.
_name_name:
_attr_extra_state_attributes
None async_added_to_hass(self)
None async_will_remove_from_hass(self)
def _async_receive_data(self, device, location, battery, accuracy, attributes)
def __init__(self, device, location, battery, accuracy, attributes)
None async_write_ha_state(self)
State|None async_get_last_state(self)
bool add(self, _T matcher)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)
IssData update(pyiss.ISS iss)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)