fix: Update source timestamp in echo to prevent component timeout#34
fix: Update source timestamp in echo to prevent component timeout#34dbl-0 wants to merge 3 commits intomuart-group:devfrom
Conversation
When echo_interval is configured, the echo mechanism now updates the temperature source timestamp to prevent the component's timeout logic from triggering while valid data is being echoed. The echo was correctly sending temperature to the heat pump but not updating temperature_reports_[].timestamp, causing the component to timeout after ~8 minutes even when actively echoing valid temperature data. This resulted in oscillation between internal and remote temperature sensing. Also fixes isnan() check that was incorrectly applied to uint32_t timestamp instead of the float temperature value.
Good catch, that's definitely not supposed to behave that way. Rather than update the last reported timestamp though (since that would hide the actual last report from that sensor), I've rearranged the logic a bit so we shouldn't get to the timeout/switch-to-internal code until after the echo has completed. I'm unfortunately not in a position to test this at the moment though, so if you're able to confirm this change also resolves the issue you're seeing that would be great.
Doh! 🤦♂️ |
|
I did test your version and I do not think it addressed the issue in the same way, and I still saw the behaviour. I've rolled back to my branch for the moment. |
|
What do you have the timeout set to in your config, and ~ how long is it taking before it times out. We do need to fix this, I just don't want to break the last-received value in doing so. Edit: (hopefully I might get some time to test locally and figure things out before too long too) |
fix: Prevent temperature flicker by using cached remote temperature
|
Thanks for the fix attempt! After testing, the timeout toggling actually is resolved (internal_sensor stays stable... or seems to), but I discovered a second related issue: brief temperature flickers. Problem: When the echo sends the remote temperature, there's a timing window before the heat pump processes it. If update() queries get_current_temp during this window, the heat pump reports its internal sensor (~18-20°C) instead of the remote temp (~23°C). This causes 6-12 second flickers visible in Home Assistant climate object. This kicks in heat, when the room doesnt need it. Evidence:
Fix: In process_packet(CurrentTempGetResponsePacket), prefer the cached remote temperature when in remote mode with valid data, rather than trusting the heat pump's response during the timing gap: if (selected_temperature_source_ != TEMPERATURE_SOURCE_INTERNAL && This is separate from the timestamp fix - it addresses the race condition in how current_temperature is populated. |
Oh good! 🎉
We've seen this behavior before, but that isn't quite an accurate representation of the cause. The heat pump itself determines whether or not to turn on the heat based on its current temperature. The flicker you are seeing is not an artifact of the MITP update logic, the heat pump actually thinks it's that temperature (probably because it has timed out). What's likely happening is that the heat pump is timing out slightly before the 60s echo arrives (either because there's packet congestion causing a delay or because it has a timeout of less than 60s). "Current temperature" reflects this, but then after the next echo the great pump's temperature is updated and then "current temperature" matches the external sensor. Rather than the last commit, the solution is to lower the echo interval (maybe to ~50s) so the echo arrives before the timeout. |
When echo_interval is configured, the echo mechanism now updates the temperature source timestamp to prevent the component's timeout logic from triggering while valid data is being echoed.
The echo was correctly sending temperature to the heat pump but not updating temperature_reports_[].timestamp, causing the component to timeout after ~8 minutes even when actively echoing valid temperature data. This resulted in oscillation between internal and remote temperature sensing.
Also fixes isnan() check that was incorrectly applied to uint32_t timestamp instead of the float temperature value.