Skip to content
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

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions custom_components/myskoda/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ async def _on_operation_event(self, event: EventOperation) -> None:

async def _on_charging_event(self, event: EventCharging):
vehicle = self.data.vehicle
if vehicle.status and (timestamp := event.event.timestamp):
vehicle.status.car_captured_timestamp = timestamp

data = event.event.data

if vehicle.charging is None or vehicle.charging.status is None:
Expand Down Expand Up @@ -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()
Copy link
Member

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.


async def _on_air_conditioning_event(self, event: EventAirConditioning):
if self.data.vehicle.status and (timestamp := event.event.timestamp):
self.data.vehicle.status.car_captured_timestamp = timestamp
await self.update_air_conditioning()

async def _on_departure_event(self, event: EventDeparture):
if self.data.vehicle.status and (timestamp := event.event.timestamp):
self.data.vehicle.status.car_captured_timestamp = timestamp
await self.update_positions()

def _unsub_refresh(self):
Expand Down
Loading