From eb10d9195c1451920adf17f5e68a94580762b67b Mon Sep 17 00:00:00 2001 From: Martin Eberhardt Date: Wed, 25 Sep 2024 22:43:26 +0200 Subject: [PATCH] Add Last Captured attribute to device tracker Shows the approximate time the car was parked. --- .../volkswagen_we_connect_id/device_tracker.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/custom_components/volkswagen_we_connect_id/device_tracker.py b/custom_components/volkswagen_we_connect_id/device_tracker.py index 6333a51..3778787 100644 --- a/custom_components/volkswagen_we_connect_id/device_tracker.py +++ b/custom_components/volkswagen_we_connect_id/device_tracker.py @@ -88,3 +88,17 @@ def source_type(self): def icon(self): """Return the icon.""" return "mdi:car" + + @property + def extra_state_attributes(self): + """Return timestamp of when the data was captured.""" + try: + return { + "last_captured": get_object_value( + self.data.domains["parking"][ + "parkingPosition" + ].carCapturedTimestamp.value + ) + } + except KeyError: + return None