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:
+78
-8
@@ -297,8 +297,8 @@
|
||||
data: {}
|
||||
mode: single
|
||||
- id: '1758383701998'
|
||||
alias: Sleep Tracking Stopped
|
||||
description: ''
|
||||
alias: Sleep Tracking Stopped - Set Awake
|
||||
description: Marks awake and stores the wake-up time; everything else builds on input_boolean.awake
|
||||
triggers:
|
||||
- trigger: state
|
||||
entity_id:
|
||||
@@ -311,6 +311,43 @@
|
||||
entity_id: person.julian
|
||||
zone: zone.home
|
||||
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
|
||||
metadata: {}
|
||||
data:
|
||||
@@ -319,7 +356,24 @@
|
||||
brightness_pct: 25
|
||||
target:
|
||||
area_id: bedroom
|
||||
- sequence:
|
||||
mode: single
|
||||
- id: '1785225600003'
|
||||
alias: Awake - Bathroom Music
|
||||
description: Weekdays only
|
||||
triggers:
|
||||
- trigger: state
|
||||
entity_id:
|
||||
- input_boolean.awake
|
||||
to: 'on'
|
||||
conditions:
|
||||
- condition: time
|
||||
weekday:
|
||||
- mon
|
||||
- tue
|
||||
- wed
|
||||
- thu
|
||||
- fri
|
||||
actions:
|
||||
- action: media_player.shuffle_set
|
||||
metadata: {}
|
||||
data:
|
||||
@@ -334,11 +388,27 @@
|
||||
- library://artist/1
|
||||
target:
|
||||
entity_id: media_player.speaker_bad_2
|
||||
- delay:
|
||||
hours: 0
|
||||
minutes: 45
|
||||
seconds: 0
|
||||
milliseconds: 0
|
||||
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: {}
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user