fix(state-machine): catch-all block_timer_expires -> idle to prevent stuck-in-blocked - #336
Open
pluskal wants to merge 1 commit into
Open
fix(state-machine): catch-all block_timer_expires -> idle to prevent stuck-in-blocked#336pluskal wants to merge 1 commit into
pluskal wants to merge 1 commit into
Conversation
…stuck-in-blocked When block_timer_expires fires and none of the conditional blocked-source transitions match, the controller stays in `blocked` indefinitely past its block_timeout. Two real cases hit this: state entities still report `on` (slow cloud/gateway feedback, e.g. Overkiz/Tahoma) while the trigger sensor is already off; or state entities are off but no earlier rule applies (the unconditional blocked->idle transition is present only as a commented-out line today). Add an unconditional blocked -> idle fallback, ordered after the conditional "go to active" transitions so those still win when they match.
There was a problem hiding this comment.
Pull request overview
This PR prevents the entity_controller state machine from getting stuck in blocked indefinitely by adding a catch-all transition that always returns to idle when block_timer_expires fires and no conditional transition matches.
Changes:
- Add an unconditional
blocked→idletransition onblock_timer_expiresas a fallback after the existing conditional transitions. - Document the rationale and ordering requirement for the fallback transition.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+333
to
+339
| # Catch-all: block_timer_expires -> idle for every case the conditional | ||
| # transitions above do not handle. Without it the controller stays stuck in | ||
| # `blocked` past its block_timeout when the timer fires and state entities | ||
| # are still reported as on (e.g. slow cloud/gateway feedback from | ||
| # integrations like Overkiz/Tahoma) while the trigger sensor is already off, | ||
| # or when state entities are off but no earlier transition matches. Added | ||
| # last so the conditional "go to active" rules are evaluated first. |
Comment on lines
+340
to
+344
| machine.add_transition( | ||
| trigger="block_timer_expires", | ||
| source="blocked", | ||
| dest="idle", | ||
| ) |
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.
Problem
When
block_timer_expiresfires, danobot only defines conditionalblocked-source transitions (all requiringis_state_entities_on, going toactiveoridle). If none match, the controller stays stuck inblockedindefinitely past itsblock_timeout. Two real cases hit this:on(slow cloud/gateway feedback from integrations like Overkiz/Tahoma) while the trigger sensor has already turned off — no conditional transition matches.Note the file already carries a commented-out unconditional transition (
# machine.add_transition(trigger='block_timer_expires', source='blocked', dest='idle')), i.e. this fallback was intended but disabled.Fix
Re-add the unconditional
blocked -> idletransition, placed after the conditional "go to active" transitions so those still win when their conditions hold. It acts as a guaranteed fallback for every other case, so the controller always leavesblockedwhen the timer fires.Testing
Deployed on a setup with an Overkiz/Somfy gateway that returns stale
onfeedback at sunrise; controllers previously stuck inblockeduntil an HA restart now return toidlewhen the block timer expires.