Skip to content

Add disable_events and enable_events scheduler triggers#10

Merged
majamassarini merged 4 commits intodevfrom
trigger_enabled_disabled_events
Mar 2, 2026
Merged

Add disable_events and enable_events scheduler triggers#10
majamassarini merged 4 commits intodevfrom
trigger_enabled_disabled_events

Conversation

@majamassarini
Copy link
Owner

Introduce two new scheduler trigger types to allow disabling and re-enabling specific events in the appliance state machine:

  • state.entering.disable_events.Trigger: fires immediately when the appliance enters a specified state and calls appliance.disable() for each of its events, preventing those events from being processed by
    the state machine until explicitly re-enabled.

  • state.entering.delay.enable_events.Trigger: fires after a configurable timeout following state entry and calls appliance.enable() for each of
    its events, restoring normal event processing.

  • date.enable_events.Trigger: the resettable date trigger forked by the delay variant, recognised by process._run() via isinstance to call appliance.enable().

process._run() is updated to dispatch on isinstance rather than calling performer.notify() when either new trigger type is dequeued.

Builder classes and YAML tags are registered for both new trigger types (state.entering.disable_events.Trigger and state.entering.delay.enable_events.Trigger).

A unit test verifies the full cycle: forced.Event.Off is disabled when the sound player enters Fade In, and re-enabled after the timeout.

Assisted-By: Claude Sonnet 4.6 noreply@anthropic.com

Introduce two new scheduler trigger types to allow disabling and
re-enabling specific events in the appliance state machine:

- state.entering.disable_events.Trigger: fires immediately when the
  appliance enters a specified state and calls appliance.disable() for
  each of its events, preventing those events from being processed by
  the state machine until explicitly re-enabled.

- state.entering.delay.enable_events.Trigger: fires after a configurable
  timeout following state entry and calls appliance.enable() for each of
  its events, restoring normal event processing.

- date.enable_events.Trigger: the resettable date trigger forked by the
  delay variant, recognised by process._run() via isinstance to call
  appliance.enable().

process._run() is updated to dispatch on isinstance rather than calling
performer.notify() when either new trigger type is dequeued.

Builder classes and YAML tags are registered for both new trigger types
(state.entering.disable_events.Trigger and
state.entering.delay.enable_events.Trigger).

A unit test verifies the full cycle: forced.Event.Off is disabled when
the sound player enters Fade In, and re-enabled after the timeout.

Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When Fade In transitions to Off upon receiving elapsed.Event.On, the new
Off state was carrying elapsed.Event.On forward (via get_new_state), which
blocked the next morning's Off -> Fade In transition whose guard requires
elapsed.Event.On to be absent.

Explicitly call next(elapsed.Event.Off) on the new Off state so the elapsed
event is always reset before the player settles back into Off.

Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The "will send" messages were at info level causing noise in the logs.
Lower them to debug and include the state transition (old -> new) for
more context alongside the outgoing messages. Also include the state
transition in the "Appliance updated by redis" debug message.

Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Generic task names "Appliance updated by redis" and "Performer updated
by redis" made it impossible to identify which entity was involved when
asyncio logged task-related messages. Include the specific name.

Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@majamassarini majamassarini merged commit d3a80c5 into dev Mar 2, 2026
1 check passed
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