-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix bug in derivative sensor when source sensor's state is constant #139230
Conversation
Previously, when the source sensor's state remains constant, the derivative sensor repeats its latest value indefinitely. This patch fixes this bug by consuming the state_reported event and updating the sensor's output even when the source sensor doesn't change its state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Hey there @afaucogney, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
Nice! Thanks! |
Thanks! |
…139230) Previously, when the source sensor's state remains constant, the derivative sensor repeats its latest value indefinitely. This patch fixes this bug by consuming the state_reported event and updating the sensor's output even when the source sensor doesn't change its state.
Proposed change
Previously, when the source sensor's state remains constant, the derivative sensor repeats its latest value indefinitely instead of reporting zero. See: #83496
This patch fixes this bug by consuming the state_reported event and updating the sensor's output even when the source sensor doesn't change its state. Once the derivative sensor reaches zero, it will ignore any further state_reported events.
The change was tested by running
pytest tests/components/derivative
and running it in my own HA instance for about a week.Type of change
Additional information
Checklist
ruff format homeassistant tests
)To help with the load of incoming pull requests: