Skip to content

Always fire update callbacks even when sensor value is unchanged#332

Open
mayerwin wants to merge 1 commit intohome-assistant-libs:mainfrom
mayerwin:patch-1
Open

Always fire update callbacks even when sensor value is unchanged#332
mayerwin wants to merge 1 commit intohome-assistant-libs:mainfrom
mayerwin:patch-1

Conversation

@mayerwin
Copy link
Copy Markdown

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant