Split wake-up automation around restart-proof awake flag

Replace the monolithic Sleep Tracking Stopped automation with an
input_boolean.awake flag plus input_datetime.woke_up timestamp.
Bedroom light and bathroom music trigger on the flag, music now runs
weekdays only, and the 45-minute music stop uses a template trigger
against the stored timestamp instead of a delay so it survives
Home Assistant restarts.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-26 16:04:23 +02:00
parent d195de3400
commit 67e33f1723
2 changed files with 108 additions and 27 deletions
+97 -27
View File
@@ -297,8 +297,8 @@
data: {} data: {}
mode: single mode: single
- id: '1758383701998' - id: '1758383701998'
alias: Sleep Tracking Stopped alias: Sleep Tracking Stopped - Set Awake
description: '' description: Marks awake and stores the wake-up time; everything else builds on input_boolean.awake
triggers: triggers:
- trigger: state - trigger: state
entity_id: entity_id:
@@ -311,6 +311,43 @@
entity_id: person.julian entity_id: person.julian
zone: zone.home zone: zone.home
actions: actions:
- action: input_datetime.set_datetime
target:
entity_id: input_datetime.woke_up
data:
datetime: '{{ now().strftime(''%Y-%m-%d %H:%M:%S'') }}'
- action: input_boolean.turn_on
target:
entity_id: input_boolean.awake
data: {}
mode: single
- id: '1785225600001'
alias: Sleep Tracking Started - Reset Awake
description: ''
triggers:
- trigger: state
entity_id:
- event.sleep_as_android_sleep_tracking_2
attribute: event_type
to:
- started
conditions: []
actions:
- action: input_boolean.turn_off
target:
entity_id: input_boolean.awake
data: {}
mode: single
- id: '1785225600002'
alias: Awake - Bedroom Light
description: ''
triggers:
- trigger: state
entity_id:
- input_boolean.awake
to: 'on'
conditions: []
actions:
- action: light.turn_on - action: light.turn_on
metadata: {} metadata: {}
data: data:
@@ -319,31 +356,64 @@
brightness_pct: 25 brightness_pct: 25
target: target:
area_id: bedroom area_id: bedroom
- sequence: mode: single
- action: media_player.shuffle_set - id: '1785225600003'
metadata: {} alias: Awake - Bathroom Music
data: description: Weekdays only
shuffle: true triggers:
target: - trigger: state
entity_id: media_player.speaker_bad_2 entity_id:
- action: music_assistant.play_media - input_boolean.awake
metadata: {} to: 'on'
data: conditions:
enqueue: replace - condition: time
media_id: weekday:
- library://artist/1 - mon
target: - tue
entity_id: media_player.speaker_bad_2 - wed
- delay: - thu
hours: 0 - fri
minutes: 45 actions:
seconds: 0 - action: media_player.shuffle_set
milliseconds: 0 metadata: {}
- action: media_player.media_stop data:
metadata: {} shuffle: true
data: {} target:
target: entity_id: media_player.speaker_bad_2
entity_id: media_player.speaker_bad_2 - action: music_assistant.play_media
metadata: {}
data:
enqueue: replace
media_id:
- library://artist/1
target:
entity_id: media_player.speaker_bad_2
mode: single
- id: '1785225600004'
alias: Awake - Stop Bathroom Music
description: Stops the wake-up music 45 minutes after waking; template trigger survives HA restarts
triggers:
- trigger: template
value_template: '{{ is_state(''input_boolean.awake'', ''on'') and state_attr(''input_datetime.woke_up'',
''timestamp'') is not none and now().timestamp() - state_attr(''input_datetime.woke_up'',
''timestamp'') > 45 * 60 }}'
conditions:
- condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
- condition: state
entity_id: media_player.speaker_bad_2
state: playing
actions:
- action: media_player.media_stop
metadata: {}
data: {}
target:
entity_id: media_player.speaker_bad_2
mode: single mode: single
- id: '1758737029692' - id: '1758737029692'
alias: Schreibtisch scan Licht alias: Schreibtisch scan Licht
+11
View File
@@ -0,0 +1,11 @@
input_boolean:
awake:
name: Awake
icon: mdi:weather-sunny
input_datetime:
woke_up:
name: Woke up
has_date: true
has_time: true
icon: mdi:alarm-check