Return the state attributes of the last update.
return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION,
ATTR_DISTANCE: round(self._state["distance"]),
ATTR_ROUTE: self._state["route"],
}
After Change
@property
def device_state_attributes(self):
Return the state attributes of the last update.
if self._state is None:
return None
res = {ATTR_ATTRIBUTION: CONF_ATTRIBUTION}
if "duration" in self._state:
res[ATTR_DURATION] = self._state["duration"]
if "distance" in self._state:
res[ATTR_DISTANCE] = self._state["distance"]
if "route" in self._state:
res[ATTR_ROUTE] = self._state["route"]
return res
def _get_location_from_entity(self, entity_id):
Get the location from the entity_id.