1
0
ansible-home-assistant/configuration/automations/alarm-clock.yaml
2021-05-31 23:34:16 +02:00

68 lines
2.0 KiB
YAML

- id: alarm-automation
alias: '[Alarm] Wakeup automation'
description: ''
trigger:
- platform: time
at: input_datetime.alarm
action:
- service: cover.open_cover
target:
entity_id: cover.bedroom_blinds
- service: cover.open_cover
target:
entity_id: cover.computer_cave_blinds
- delay: '15'
- service: media_player.volume_set
data:
volume_level: 0.1
entity_id: media_player.bedroom_speaker
- delay: 0:30:00
- service: media_player.volume_set
data:
volume_level: 0.05
entity_id: media_player.bedroom
- service: media_player.play_media
data:
media_content_id: media-source://media_source/local/wake-the-f-up-samurai-we-have-a-city-to-burn.mp3
media_content_type: music
entity_id: media_player.bedroom_speaker
- delay: '15'
- service: media_player.play_media
data:
entity_id: media_player.bedroom
media_content_id: 'https://open.spotify.com/playlist/3Qu9kE0ivJIkn76pxTLMFe'
media_content_type: music
- repeat:
while:
- condition: numeric_state
entity_id: media_player.bedroom
attribute: volume_level
below: 0.10
sequence:
- delay: '30'
- service: media_player.volume_up
entity_id: media_player.bedroom
mode: single
- id: alarm-update-time
alias: '[Alarm] Update alarm time'
mode: single
trigger:
- platform: state
entity_id: sensor.sm_g965f_next_alarm
condition:
- condition: not
conditions:
- condition: state
entity_id: sensor.sm_g965f_next_alarm
state: unknown
- condition: state
entity_id: sensor.sm_g965f_next_alarm
state: 'com.urbandroid.sleep'
attribute: Package
action:
- service: input_datetime.set_datetime
entity_id: input_datetime.alarm
data:
datetime: "{{ (((state_attr('sensor.sm_g965f_next_alarm', 'Time in Milliseconds') | int / 1000) - 30*60 ) | timestamp_custom('%Y-%m-%d %H:%M:%S')) }}"