Repository navigation
Docs: state triggers only fire when a value changes (#864) - #914
Merged
craigbarratt merged 2 commits intoNov 21, 2026
Merged
craigbarratt merged 2 commits into
craigbarratt merged 2 commits into
Conversation
@state_trigger and its watch= argument only evaluate when a watched value or attribute changes, so a sensor that repeats the same value (for example with force_update) never fires them. The docs read as if every update did. Say so, and show watching the last_updated attribute to trigger on every update. Refs custom-components#864. Signed-off-by: Sean Stoube <[email protected]>
craigbarratt
approved these changes
Nov 21, 2026
craigbarratt
left a comment
Member
There was a problem hiding this comment.
Thanks @HoneyBearTech, this is accurate.
One small wording suggestion: "to trigger on every update" works for force_update: true sensors, since HA then fires state_changed with a new last_updated. A sensor without force_update that repeats the same state and attributes only changes last_reported. HA then fires state_reported, which pyscript doesn't listen to, so nothing triggers. Maybe "to trigger on every forced update"? Fine to merge either way.
Signed-off-by: Sean Stoube <[email protected]>
Contributor
Author
|
@craigbarratt thanks! Changed it to "every forced update". |
Member
|
Thanks! |
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.
Refs #864
What was missing
@state_triggerand itswatch=argument only evaluate when a watched value actually changes (ident_any_values_changedcompares the old and new values). So a sensor that reports the same value again, for example withforce_update: true, never fires them. The docs didn't say so.What I changed
A short note in the
watchdescription indocs/reference.rst. It shows watching thelast_updatedattribute to trigger on every update, as found in the issue:@state_trigger("True", watch=["sensor.my_sensor.last_updated"])This covers option 1 of the issue (document the behaviour). It doesn't add a new argument.
Testing
sphinx-build -Wbuilds the docs with no warnings, and codespell is clean.