Hey Guys,
i found this thread Alarm Clock with Sonos & Philips Hue - Share your Projects! - Home Assistant Community (home-assistant.io) to combine hue und sonos alarm which works great. The only thing i want to change is that i don’t need to use the sliders (input_numbers). I want fixed values so one alarm + hue wake up routine should turn on at 6:00, another one at 6:30 one at 7:00 and so one.
Each alarm should have an button to turn on.
So i changed the existing code from the thread:
- alias: Set Sonos Alarm
trigger:
- platform: state
entity_id: input_boolean.alarm_clock_status
to: 'on'
action:
service: media_player.sonos_update_alarm
data_template:
entity_id: media_player.bedroom
alarm_id: 4
time: '{{ states.sensor.alarm_clock_time.state }}'
enabled: true
- alias: Disable Sonos Alarm
trigger:
- platform: state
entity_id: input_boolean.alarm_clock_status
to: 'off'
action:
service: media_player.sonos_update_alarm
data_template:
entity_id: media_player.bedroom
alarm_id: 4
enabled: false
- alias: Fade in Lights in Bedroom
trigger:
platform: time
seconds: 00
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.alarm_clock_status
state: 'on'
- condition: template
value_template: '{{ (utcnow().strftime("%s") | int + states.sensor.alarm_clock_fade_in_minutes.state | int * 60) | timestamp_custom("%H:%M") == states.sensor.alarm_clock_time.state }}'
action:
service: script.bedroom_light_fade_in
to:
- alias: Alarm 7:00
trigger:
- platform: state
entity_id: input_boolean.alarm_clock_status_seven
to: 'on'
action:
service: sonos.update_alarm
data_template:
entity_id: media_player.bedroom_sonos
alarm_id: 1
time: '7:00'
enabled: true
- alias: Disable Sonos Alarm 7:00
trigger:
- platform: state
entity_id: input_boolean.alarm_clock_status_seven
to: 'off'
action:
service: sonos.update_alarm
data_template:
entity_id: media_player.bedroom_sonos
alarm_id: 1217
enabled: false
- alias: Fade in Lights in Bedroom 7:00
trigger:
platform: time_pattern
seconds: 0
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.alarm_clock_status_seven
state: 'on'
- condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
- condition: template
value_template: '{{ (utcnow().strftime("%s") | int + "10"
| int * 60) | timestamp_custom("%H:%M") == "7:00"
}}'
action:
service: script.bedroom_light_fade_in_test
I created a new entitiy for the alarm button so there is trigger to set the alarm.
Sonos Alarm works great and will be enabled and disabled.
heres the script which should run after every fade in automation:
The lights turn on when i run this script directly form HA.
bedroom_light_fade_in_test:
sequence:
- service: light.turn_on
data_template:
entity_id:
- light.licht_schlafzimmer
- light.licht_bett
profile: relax
transition: '{{ "10" | int * 60 }}'
- delay: '{{ "00:10:15" }}'
- delay: 00:10:00
- service: light.turn_off
data_template:
entity_id:
- light.licht_schlafzimmer
- light.licht_bett
mode: single
I think the condition for “Fade in Lights in Bedroom 7:00” is not working ok. I think it is the value template for the time. Anyone can help me to fix that?