-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update LastUpdated sensor value on service events #416
Update LastUpdated sensor value on service events #416
Conversation
As discussed in skodaconnect#359, the car_captured_timestamp can be updated with timestamp value available from service events.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for following up👍
Since there is no garuantee that a received event has a more recent timestamp than what we have in memory, can you add a check to see if the timestamp is more current than what we have in memory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this comes down to the question what do we actually want to represent with car_captured_timestamp
?
Is it "the last time we got a full update of the car data" or is it "any data". Individual entities already report when they last changed value so I'm not sure if we really want/need a partial update (e.g. just a few charging entities after a charge event) to also update car_captured_timestamp
. But I'm not against it either.
@@ -228,12 +231,18 @@ async def _on_charging_event(self, event: EventCharging): | |||
self.set_updated_vehicle(vehicle) | |||
|
|||
async def _on_access_event(self, event: EventAccess): | |||
if self.data.vehicle.status and (timestamp := event.event.timestamp): | |||
self.data.vehicle.status.car_captured_timestamp = timestamp | |||
await self.update_vehicle() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't update_vehicle
already update this? For an access event a least the timestamp on the event isn't really representative of the car_capture_timestamp
. That is, the event itself didn't really provide any updated data.
Yes, this comes down to getting same behavior as in the application or we will have own meaning for the sensor. As far as I see, if I go to the individual pages in the app, then I see different "updated" timestamp values there, meaning they display e.g. charging updated timestamp on the charging page, while the first overview page might have different time. |
Looking at the responses we're seeing, there seems to be a difference in timestamps representing data obtained from the car and timestamps related to events. Maybe it's a better idea to not use the same sensor for both events, but create a new sensor that represents the timestamp of latest event occurred, as opposed to last poll occurred, which i guess resembles |
I like this idea. We already have this for all events related to operations, through the I would then leave For individual entities HA already reports the last change and last updated timestamps. Edit: if that sounds good maybe just close this PR and open an issue to implement a generic |
Thanks for the feedback. That is fine to me. |
As discussed in #359, the car_captured_timestamp can be updated with timestamp value available from service events.