Skip to content

Add turnOffCooldownPeriod to SensorsTriggerLights#9

Merged
dansimau merged 1 commit into
mainfrom
dansimau/west-monroe
May 20, 2026
Merged

Add turnOffCooldownPeriod to SensorsTriggerLights#9
dansimau merged 1 commit into
mainfrom
dansimau/west-monroe

Conversation

@dansimau

Copy link
Copy Markdown
Owner

Summary

Add a configurable cooldown period to SensorsTriggerLights that prevents motion sensors from re-triggering for a window after a human manually turns the lights off. Default is 10s; set to 0 to disable. This prevents the lights from flashing back on when someone enters a room and flips the switch off just as the motion sensor would have re-triggered.

The cooldown only applies to human-initiated turn-offs, not the automation's own timer. It arms in handleLightStateChanged, which only runs for external state changes (guaranteed by connection-level filtering at connection.go:292).

Tests

  • TestSensorTurnOffCooldown verifies the cooldown blocks sensor re-triggers and releases after it elapses.
  • TestSensorTurnOffCooldownDisabled confirms setting the period to 0 disables the feature.
  • All existing sensor automation tests pass with the 10s default in place.

🤖 Generated with Claude Code

When a human manually turns off the lights, prevent motion sensors from
re-triggering for a configurable cooldown period (default 10s). This
prevents rapid light flashing when someone enters a room and flips the
switch off moments before motion would have turned the lights back on.

The cooldown only applies to human-initiated turn-offs, not to the
automation's own timer-driven turn-offs. It's armed in handleLightStateChanged,
which only fires for external state changes (guarded at the connection level).

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@dansimau
dansimau merged commit cebdff7 into main May 20, 2026
1 check passed
@dansimau
dansimau deleted the dansimau/west-monroe branch May 20, 2026 20:26
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