Skip to content

fix(state-machine): catch-all block_timer_expires -> idle to prevent stuck-in-blocked - #336

Open
pluskal wants to merge 1 commit into
danobot:masterfrom
pluskal:fix/block-timer-catch-all
Open

fix(state-machine): catch-all block_timer_expires -> idle to prevent stuck-in-blocked#336
pluskal wants to merge 1 commit into
danobot:masterfrom
pluskal:fix/block-timer-catch-all

Conversation

@pluskal

@pluskal pluskal commented Jul 24, 2026

Copy link
Copy Markdown

Problem

When block_timer_expires fires, danobot only defines conditional blocked-source transitions (all requiring is_state_entities_on, going to active or idle). If none match, the controller stays stuck in blocked indefinitely past its block_timeout. Two real cases hit this:

  1. State entities are still reported on (slow cloud/gateway feedback from integrations like Overkiz/Tahoma) while the trigger sensor has already turned off — no conditional transition matches.
  2. State entities are already off — again nothing 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 -> idle transition, 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 leaves blocked when the timer fires.

Testing

Deployed on a setup with an Overkiz/Somfy gateway that returns stale on feedback at sunrise; controllers previously stuck in blocked until an HA restart now return to idle when the block timer expires.

…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.
Copilot AI review requested due to automatic review settings July 24, 2026 07:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 blockedidle transition on block_timer_expires as 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",
)
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.

2 participants