fix(hass): don't fire on-off automations when a device reconnects
CI Images / Plan (pull_request) Failing after 2s
CI Images / Build ${{ matrix.key }} (pull_request) Skipped

The Bedroom Light HS200 dropped off Wi-Fi for 5 s at 03:01 and came back
reporting "on"; the Bedroom On device trigger treated unavailable -> on as
someone flipping the switch and lit the bedroom Hue lamps at 100%.

Bedroom On/Off and TV On/Off now use state triggers with not_from
unavailable/unknown, so reconnects and HA restarts no longer count as a
flip. The driveway's switch-reconnect catch-up is dropped for the same
reason (it would undo a manual off); the HA-restart catch-up stays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Bastian de Byl
2026-09-28 11:32:24 -04:00
co-authored by Claude Opus 5.5
parent fd985e014c
commit f674f61b8d
@@ -195,11 +195,12 @@
description: TV mode on; once it's dark, dim the living room and turn off the description: TV mode on; once it's dark, dim the living room and turn off the
lights that glare on the TV lights that glare on the TV
triggers: triggers:
- type: turned_on - trigger: state
device_id: 18a9bb7a2a32be4371da447767ef50a9 entity_id: remote.samsung_tv
entity_id: c05688f2610e27e2d86380e2945ceae5 to: 'on'
domain: remote not_from:
trigger: device - unavailable
- unknown
conditions: [] conditions: []
actions: actions:
- action: input_boolean.turn_on - action: input_boolean.turn_on
@@ -232,11 +233,12 @@
scheduled level; late night (23:30 to sunrise) only turns off the TV glow; scheduled level; late night (23:30 to sunrise) only turns off the TV glow;
daytime leaves the lights alone daytime leaves the lights alone
triggers: triggers:
- type: turned_off - trigger: state
device_id: 18a9bb7a2a32be4371da447767ef50a9 entity_id: remote.samsung_tv
entity_id: c05688f2610e27e2d86380e2945ceae5 to: 'off'
domain: remote not_from:
trigger: device - unavailable
- unknown
conditions: [] conditions: []
actions: actions:
- action: input_boolean.turn_off - action: input_boolean.turn_off
@@ -268,7 +270,7 @@
- id: driveway_lights_on - id: driveway_lights_on
alias: Driveway String Lights On alias: Driveway String Lights On
description: On 1 hour before sunset whether or not the TV is on. Also catches description: On 1 hour before sunset whether or not the TV is on. Also catches
up if Home Assistant restarts or the switch reconnects before the 23:00 off up if Home Assistant restarts before the 23:00 off
triggers: triggers:
- trigger: sun - trigger: sun
event: sunset event: sunset
@@ -276,10 +278,6 @@
id: sunset id: sunset
- trigger: homeassistant - trigger: homeassistant
event: start event: start
- trigger: state
entity_id: switch.driveway_string_lights
from: unavailable
to: 'off'
conditions: conditions:
- condition: state - condition: state
entity_id: switch.driveway_string_lights entity_id: switch.driveway_string_lights
@@ -399,11 +397,12 @@
alias: Bedroom On alias: Bedroom On
description: '' description: ''
triggers: triggers:
- type: turned_on - trigger: state
device_id: afb9734fe9b187ab6881a64d24e1c2f5 entity_id: switch.bedroom_light
entity_id: 27efa149b9ebb388e7c21ba89e671b42 to: 'on'
domain: switch not_from:
trigger: device - unavailable
- unknown
conditions: [] conditions: []
actions: actions:
- action: light.turn_on - action: light.turn_on
@@ -417,11 +416,12 @@
alias: Bedroom Off alias: Bedroom Off
description: '' description: ''
triggers: triggers:
- type: turned_off - trigger: state
device_id: afb9734fe9b187ab6881a64d24e1c2f5 entity_id: switch.bedroom_light
entity_id: 27efa149b9ebb388e7c21ba89e671b42 to: 'off'
domain: switch not_from:
trigger: device - unavailable
- unknown
conditions: [] conditions: []
actions: actions:
- action: light.turn_off - action: light.turn_off