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

Periodic updates are deferred when charging is in progress #608

Closed
fursov opened this issue Feb 4, 2025 · 5 comments · Fixed by #610
Closed

Periodic updates are deferred when charging is in progress #608

fursov opened this issue Feb 4, 2025 · 5 comments · Fixed by #610
Labels
bug Something isn't working

Comments

@fursov
Copy link
Contributor

fursov commented Feb 4, 2025

I would like to report one misbehaviour. The scenario is following:

  • in my setup the integration has polling period of 10 minutes
  • the car is Superb iV 2020, quite old model. It reports charging events always without data, so those basically are informative that something has happened and if we need to fetch the additional info, then we have to call the update manually.

I noticed, that at some point I started to get regular "Unknown" state for the battery percentage, this mainly happens when the car in in charging state:
Image

I checked the logs. So what happens is that while charging the car sends regular updates about charging by the event charging-status-changed, the event comes in about 9 minutes (less than polling interval). On this event the integration calls function self.set_updated_vehicle(vehicle) which is visible in the logs as Manually updated myskoda data. And it seems, that after this the periodic update is not called because the HA considers that vehicle received the manual update and periodic poll is not needed.

So why then the state becomes "Unknown". This has started to happen after this update skodaconnect/myskoda#338. All charging events are now coming as ServiceEventWithChargingData where missing fields are none so for my car this means the charging state is none that turns to "Unknown" on battery sensors.

I attach the logs from this night charging (periodic update responses payload are removed to simplify anonymizing, they are not relevant for the issue). The updates are coming regularly until 2025-02-04 04:02:00, when script starts charging. After that the server sends charging-status-changed regularly and there is no periodic updates anymore until 2025-02-04 06:15:49 just because when charge level is closer to 100%, the charging event updates are coming with slower rate from the car (longer than 9 minutes).
I also inserted few debug prints for myself that start with CHARGING DEBUG.

So, I think, there are couple of issues:

  • the Add support for mqtt charging-error message myskoda#338 should have a followup/fix to continue sending events without data as ServiceEventData, not as ServiceEventChargingData
  • it is not clear for me, what should be done to enable periodic updates even if we call self.set_updated_vehicle(vehicle) because even if it is called when we receive e.g. charging info update with data, it does not mean we updated all other sensors.

Please, share your opinion.

charging.log

@fursov fursov added the bug Something isn't working label Feb 4, 2025
@WebSpider
Copy link
Contributor

Thank you very much for debugging this issue, this has been discussed in #484 and I have not had enough data to see what's going on. Your report looks actionable, and I will look into the details later this week.

If you have suggestions for a fix, feel free to submit a PR in the mean time.

@WebSpider
Copy link
Contributor

It is by design from HomeAssistant that a regular poll gets deferred when there is a manual update. This is not something we are looking to change.

We should make sure that the values in the update are not None when we in-fact got a value from the API.
Expected behaviour here is:

  1. Sensor has a value
    2a) Update with new sensor value from event arrives: We update the internal data and HA then updates the sensor
    2b) Update with no sensor value from event arrives: We update the internal data and HA turns the sensor Unknown
    2c) Update with no value at all from event arrives: We do not update the internal data since we learned nothing new

@fursov
Copy link
Contributor Author

fursov commented Feb 4, 2025

If you have suggestions for a fix, feel free to submit a PR in the mean time.

I can have a look into ServiceEventData vs. ServiceEventChargingData since I have ben fixing these ones some time ago.

@prvakt
Copy link
Collaborator

prvakt commented Feb 4, 2025

its because _on_charging_event is blindly setting soc from event_data without checking if there is soc available or not
status.battery.state_of_charge_in_percent = event_data.soc

I will fix it

@fursov
Copy link
Contributor Author

fursov commented Feb 4, 2025

In any case, the ServiceEventData vs. ServiceEventChargingData in the myskoda library should be refactored somehow. I'll take a look on that also.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants