An automation failed this morning and when I checked the trace, I see why. The action for the door closing is not coded correctly. See below. Running 2022.3.5 on Intel NUC.
alias: Turn on radio when alarm is armed
id: 253c6df2-5405-421a-b761-3645d300b326
initial_state: true
trigger:
platform: state
entity_id: alarm_control_panel.home_alarm
to: armed_away
action:
- service: script.turn_on
entity_id: script.radio_alarm
- service_template: >-
{% if is_state('light.garage_light_main' , 'on') %} light.turn_off {%
endif %}
entity_id: light.garage_light_main
- service_template: '{% if is_state(''cover.garage'' , ''open'') %} cover.close_cover {% endif %}'
entity_id: cover.garage
Have a look though at the actual automation. Why is there a difference?
## Turn on radio in rumpus and ensuite when alarm sets ##
- alias: 'Turn on radio when alarm is armed'
id: 253c6df2-5405-421a-b761-3645d300b326
initial_state: true
trigger:
platform: state
entity_id: alarm_control_panel.home_alarm
to: 'armed_away'
## script in scripts folder [radio.yaml] ##
action:
- service: script.turn_on
entity_id: script.radio_alarm
- service_template: "{% if is_state('light.garage_light_main' , 'on')
%} light.turn_off
{% endif %}"
entity_id: light.garage_light_main
- service_template: "{% if is_state('cover.garage' , 'open')
%} cover.close_cover
{% endif %}"
entity_id: cover.garage
e.g. If the garage light is not on, there is no service available for the service_template and an error occurs and the actions stop. Likewise if the cover is not open.
Also you no longer need to use service_template just service will do.
If you do not have an else case, use the choose action instead of a template.
You may not need the templates/choose actions. Turning off a light that is already off is no issue. However closing a cover that is already closed may open it if the close and open actions are the same. So maybe this will work: