tesla
tesla copied to clipboard
time_to_full_charge not updating with MQTT messages
Version of the custom_component
v3.12.1
Configuration
Describe the bug
Time to full charge is listed as one of the sensors that gets updated via MQTT. However I see MQTT teslamate/cars/1/time_to_full_charge messages updating that value but the sensor does not change with the message.
As a result, the time is not correct and while the car is still charging I see state of the sensor is
Debug log
Add your logs here.
If you enable debug logs while charging, do you get the MQTT logs saying its updated the sensor
The Time Charging complete sensor is a bit special by the looks of it. Its not just a straight representation of the value from the API, but instead shows the datetime of when charging should be complete. If that computed datetime is identical till the last state, then home assistant doesn't update.
If you make a sensor out of the attribute on the charge rate sensor, you'll likely see it update in realtime as it counts down
If you make a sensor out of the attribute on the charge rate sensor, you'll likely see it update in realtime as it counts down
I have a sensor from the MQTT message that gives me time to charge complete and it's how I noticed that the value in the integration wasn't being updated. I do see the MQTT messages in the debug log but is the sensor set just at the start of charging? It doesn't seem to change when the MQTT messages are received.
So if you have a look at the sensor code, you can see its not using the raw value, but instead appears to be converting it some how.
https://github.com/alandtse/tesla/blob/dbaa5c7572c90281e4580635b6c242fe43231b89/custom_components/tesla_custom/sensor.py#L577
I think thats whats causing the overall state to stay the same.
I'll try to remember to do some debugging while my car is charging today
There is a known bug where the time_to_full_charge sensor will only update if the new time is later. That could be the cause here. I have a PR to fix this bug, I just need to figure out how to write a test for it.