tesla icon indicating copy to clipboard operation
tesla copied to clipboard

time_to_full_charge not updating with MQTT messages

Open drjjr2 opened this issue 1 year ago • 4 comments

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 image

Debug log


Add your logs here.

drjjr2 avatar Apr 30 '23 23:04 drjjr2

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

Megabytemb avatar May 01 '23 08:05 Megabytemb

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.

drjjr2 avatar May 01 '23 12:05 drjjr2

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

Megabytemb avatar May 01 '23 22:05 Megabytemb

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.

InTheDaylight14 avatar May 03 '23 19:05 InTheDaylight14