Closed longzheng closed 2 weeks ago
Thanks for reporting, nice catch.
- the healthy state should not be
false
if streaming data is available (as it was in my scenario)- the Home Assistant MQTT sensors should not use
healthy
topic as an availabillity source since it may be misleading
I do agree to both
Is there an alternative to "healthy" that can be used for the MQTT sensor availability?
What do we want "healthy" to indicate?
Maybe a car that drives into and out of a mobile black spot should still be considered healthy?
What if the car drives into a black spot and parks there overnight?
Could be tricky. How do we distinguish a problem that should be ignored vs one that should not be ignored?
By no means I'm a Home Assistant expert, but I do wonder if the sensor "availability" is sort of misleading here since there's no correlation between sensor values/states like "location" and "speed" with "healthy" or "not healthy".
The way I'm thinking about it, the "location" or "speed" sensor only updates if there is a new value pushed from MQTT. If there is no value, the last value/state is persisted in Home Assistant with a timestamp of when it was set. So if the car is offline/unreachable, then the MQTT topic will not have any new values and the sensor will not update, then the last value is the last known value for that sensor.
I believe that's also what Teslamate's own dashboard would show as well, the last known location and speed if the car suddenly became unreachable. There is a "car is unhealthy" indicator but it doesn't hide/stop all the other values from being shown.
Since there is in fact a "Healthy" sensor tied to the healthy
topic, if anyone/anything was concerned with the current "health" of the connection, then they can use that sensor value directly.
However for certain sensors like the "Active route", here the "availability" topic is meaningful because if the car is not actively routing, then the "Active route" should not be the last set state because that's not reflective of the actual state, so the "Unavailable" state has meaning here.
@t3hk0d3 I saw that you added the sensor availability
attributes in https://github.com/teslamate-org/teslamate/pull/3344
Do you have any opinions or suggestions as to whether they can be removed?
@JakobLichterfeld since I haven't heard back from anyone about this, my opinion is that the availability
attribute should removed from most sensors (excluding the active route ones). I'll open a PR for this.
@JakobLichterfeld since I haven't heard back from anyone about this, my opinion is that the
availability
attribute should removed from most sensors (excluding the active route ones).
Agree.
I'll open a PR for this.
Ty!
Is there an existing issue for this?
What happened?
I've noticed that my Home Assistant MQTT sensors sometimes report "unavailable" even though data is actually available and logged in Teslamate.
For example there was no "speed" data between 6:51am and 6:56am.
But looking at Teslamate's trip, speed was logged for the whole strip including the portion before 6:56am. I suspect this data came from the "Streaming API" which I have enabled.
Looking at some of the other sensors, I then realised that the sensor state was "unavailable" at the same time
Looking at the Home Assistant MQTT sensors documentation I then realised that all of the sensors have an
availability
tied to theteslamate/cars/X/healthy
topicFrom the container logs I can verify that my vehicle became "unhealthy" around the same time due to consequtive
408
errors from the Owners API.I'm not familiar enough with the "healthy" state/topic, so I'm not sure if the problem is either
false
if streaming data is available (as it was in my scenario)healthy
topic as an availabillity source since it may be misleadingExpected Behavior
Home Assistant sensors to have data if data is available
Steps To Reproduce
No response
Relevant log output
Screenshots
No response
Additional data
No response
Type of installation
Docker
Version
v1.31.1