Always fire update callbacks even when sensor value is unchanged#332
Open
mayerwin wants to merge 1 commit intohome-assistant-libs:mainfrom
Open
Always fire update callbacks even when sensor value is unchanged#332mayerwin wants to merge 1 commit intohome-assistant-libs:mainfrom
mayerwin wants to merge 1 commit intohome-assistant-libs:mainfrom
Conversation
Currently, EcoWittSensor update callbacks only fire when the sensor value changes. This means HA entities don't call async_write_ha_state() for sensors with stable values (e.g., rain rate = 0.0 when not raining), causing `last_reported` to go stale even though the gateway is pushing data every 60 seconds. This makes it impossible to reliably detect whether a sensor has stopped communicating, which is the entire purpose of `last_reported` (introduced in HA 2024.3). Fix: Remove the early-return guard in EcoWittSensor.value setter so callbacks always fire when data is received from the gateway, regardless of whether the value changed. HA already has logic in place to not create duplicate records (but only update `last_reported`) if the data hasn't changed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, EcoWittSensor update callbacks only fire when the sensor value changes. This means HA entities don't call async_write_ha_state() for sensors with stable values (e.g., rain rate = 0.0 when not raining), causing
last_reportedto go stale even though the gateway is pushing data every 60 seconds.This makes it impossible to reliably detect whether a sensor has stopped communicating, which is the entire purpose of
last_reported(introduced in HA 2024.3).Fix: Remove the early-return guard in EcoWittSensor.value setter so callbacks always fire when data is received from the gateway, regardless of whether the value changed. HA already has logic in place to not create duplicate records (but only update
last_reported) if the data hasn't changed.