diff --git a/custom_components/weenect/device_tracker.py b/custom_components/weenect/device_tracker.py index 070a464..7ee9f28 100644 --- a/custom_components/weenect/device_tracker.py +++ b/custom_components/weenect/device_tracker.py @@ -174,3 +174,18 @@ def location_accuracy(self): if self.id in self.coordinator.data: if self.coordinator.data[self.id]["position"]: return self.coordinator.data[self.id]["position"][0]["radius"] + + @property + def extra_state_attributes(self): + """Return device specific attributes.""" + res = self._attr_extra_state_attributes + + if self.id in self.coordinator.data: + if self.coordinator.data[self.id]["position"]: + res["speed"] = self.coordinator.data[self.id]["position"][0]["speed"] + res["course"] = self.coordinator.data[self.id]["position"][0][ + "direction" + ] + res["PDOP"] = self.coordinator.data[self.id]["position"][0]["pdop"] + + return res diff --git a/tests/test_device_tracker.py b/tests/test_device_tracker.py index f660e80..d59c8e8 100644 --- a/tests/test_device_tracker.py +++ b/tests/test_device_tracker.py @@ -34,6 +34,9 @@ async def test_device_tracker(hass): assert hass.states.get("device_tracker.test").attributes["latitude"] == 47.024191 assert hass.states.get("device_tracker.test").attributes["gps_accuracy"] == 31 assert hass.states.get("device_tracker.test").attributes["icon"] == "mdi:paw" + assert hass.states.get("device_tracker.test").attributes["speed"] == 4.8 + assert hass.states.get("device_tracker.test").attributes["course"] == 312 + assert hass.states.get("device_tracker.test").attributes["PDOP"] == 99.9 @pytest.mark.usefixtures("get_trackers_not_a_pet_tracker")