Guard against bad states in Mobile App/OwnTracks (#24292)
parent
14c0ada9ac
commit
8b4ef3bbdd
|
@ -145,9 +145,9 @@ class MobileAppEntity(DeviceTrackerEntity, RestoreEntity):
|
|||
|
||||
attr = state.attributes
|
||||
data = {
|
||||
ATTR_GPS: (attr[ATTR_LATITUDE], attr[ATTR_LONGITUDE]),
|
||||
ATTR_GPS_ACCURACY: attr[ATTR_GPS_ACCURACY],
|
||||
ATTR_BATTERY: attr[ATTR_BATTERY_LEVEL],
|
||||
ATTR_GPS: (attr.get(ATTR_LATITUDE), attr.get(ATTR_LONGITUDE)),
|
||||
ATTR_GPS_ACCURACY: attr.get(ATTR_GPS_ACCURACY),
|
||||
ATTR_BATTERY: attr.get(ATTR_BATTERY_LEVEL),
|
||||
}
|
||||
data.update({key: attr[key] for key in attr if key in ATTR_KEYS})
|
||||
self._data = data
|
||||
|
|
|
@ -153,10 +153,10 @@ class OwnTracksEntity(DeviceTrackerEntity, RestoreEntity):
|
|||
attr = state.attributes
|
||||
self._data = {
|
||||
'host_name': state.name,
|
||||
'gps': (attr[ATTR_LATITUDE], attr[ATTR_LONGITUDE]),
|
||||
'gps_accuracy': attr[ATTR_GPS_ACCURACY],
|
||||
'battery': attr[ATTR_BATTERY_LEVEL],
|
||||
'source_type': attr[ATTR_SOURCE_TYPE],
|
||||
'gps': (attr.get(ATTR_LATITUDE), attr.get(ATTR_LONGITUDE)),
|
||||
'gps_accuracy': attr.get(ATTR_GPS_ACCURACY),
|
||||
'battery': attr.get(ATTR_BATTERY_LEVEL),
|
||||
'source_type': attr.get(ATTR_SOURCE_TYPE),
|
||||
}
|
||||
|
||||
@callback
|
||||
|
|
Loading…
Reference in New Issue