- alias: Disable Sonos Alarm
trigger:
- platform: state
entity_id: input_boolean.alarm_clock_six
to: 'off'
id: six_am
- platform: state
entity_id: input_boolean.alarm_clock_eight
to: 'off'
id: eight_am
action:
- choose:
# At 6 AM
- conditions: "{{ trigger.id == 'six_am' }}"
sequence:
- service: sonos.update_alarm
data:
entity_id: media_player.bedroom_sonos
alarm_id: 1129
enabled: false
# At 8 AM
default:
- service: sonos.update_alarm
data:
entity_id: media_player.bedroom_sonos
alarm_id: 1233
enabled: false
You should also go through your config and do a search and replace for all instances of data_template and replace with just data and for service_template replace with just service.
The automation is not working. So the alarm for 6am and 8am are not disabled.
i dont get specific errors but the alarms stay enabled.
i tested this by disabling my previous automations and enabled yours but after changing the state of input_boolean.alarm_clock_eight oder input_boolean.alarm_clock_six nothing happens
Ok one more thing im struggeling with. This is a bit different from my first question because conditions are different.
also i think trigger should be swapped the condition (input_boolean). This was one of my first automations so i don’t know what happened there
So when i togglethe switch the lights should slowly fade in 15 minutes before the time the alarm should go off. So platform time is 7:45 for the 8:00 alarm.
It always starts the same script but based on a different sonos alarm which starts the lights 15 minutes before the alarm.
- alias: Fade in Lights in Bedroom 8:00
trigger:
- platform: time
at: 07:45:00
condition:
- condition: state
entity_id: input_boolean.alarm_clock_eight
state: 'on'
- condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
action:
service: script.bedroom_light_fade_in
id: db3028c01f1a41fa8b8238508649757d
and
- alias: Fade in Lights in Bedroom 6:00
trigger:
- platform: time
at: 05:45:00
condition:
- condition: state
entity_id: input_boolean.alarm_clock_six
state: 'on'
- condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
action:
service: script.bedroom_light_fade_in
id: 1cf9c5ed596c4eb18b3fd8edcb624ed7
You can only use templates under data:, service:, or target: and in some rare configuration options specifically defined in the documentation.
You can do it like this:
condition:
- condition: or
conditions:
- condition: and
conditions:
- condition: state
entity_id: input_boolean.alarm_clock_six
state: 'on'
- condition: trigger
id: "six"
- condition: and
conditions:
- condition: state
entity_id: input_boolean.alarm_clock_eight
state: 'on'
- condition: trigger
id: "test"
Or considerably more compact:
condition:
- condition: or
conditions:
- "{{ states('input_boolean.alarm_clock_six', 'on') and trigger.id == 'six' }}"
- "{{ states('input_boolean.alarm_clock_eight', 'on') and trigger.id == 'test' }}"
This uses a specific shorthand for template conditions introduced a few updates ago. Using traditional longhand template conditions it would look like this:
condition:
- condition: or
conditions:
- condition: template
value_template: "{{ states('input_boolean.alarm_clock_six', 'on') and trigger.id == 'six' }}"
- condition: template
value_template: "{{ states('input_boolean.alarm_clock_eight', 'on') and trigger.id == 'test' }}"
- id: Fade in Lights Bedroom Test
trigger:
- platform: time
at: 05:45:00
id: six
- platform: time
at: 14:30:00
id: test
condition:
- condition: or
conditions:
- "{{ states('input_boolean.alarm_clock_six', 'on') and trigger.id == 'six' }}"
- "{{ states('input_boolean.alarm_clock_eight', 'on') and trigger.id == 'test' }}"
- condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
action:
- service: script.bedroom_light_fade_in
mode: single
and it gives me this error:
Invalid config for [automation]: Expected HH:MM, HH:MM:SS or Entity ID with domain ‘input_datetime’ or ‘sensor’ @ data[‘at’][0]. Got None. (See /config/configuration.yaml, line 12).
- id: Fade in Lights Bedroom Test
trigger:
- platform: time
at: 05:45:00
id: six
- platform: time
at: 14:30:00
id: test
condition:
- condition: or
conditions:
- "{{ is_state('input_boolean.alarm_clock_six', 'on') and trigger.id == 'six' }}"
- "{{ is_state('input_boolean.alarm_clock_eight', 'on') and trigger.id == 'test' }}"
- "{{ now().isoweekday() <= 5 }}"
action:
- service: script.bedroom_light_fade_in
mode: single
gives me the same error: Invalid config for [automation]: Expected HH:MM, HH:MM:SS or Entity ID with domain ‘input_datetime’ or ‘sensor’ @ data[‘at’][0]. Got None.