The issue is that there is nothing in the “action” part of an automation , to exit of the blocking action in order that the automation continue , in such case.
I may have missed existing solution for this , but is there at least an existing workaround ?
One of the actions is to activate the surveillance station in my Synoly NAS using the switch “switch.ds418_home_mode” to activate the cameras in Surveillance Station , as described in the DSM integration … Synology DSM - Home Assistant
This automation used to work flawless but the state of the “switch.ds418_home_mode” became “unavailable” during the night due to a short power failure because the NAS is set to restart by WoL only.
=> The action “switch.turn_on” did not execute and the automation did not complete
How do you want the automation’s action to behave if the state of switch.ds418_home_mode is unavailable? Do you want it to simply skip the switch.turn_on action and continue to the next action?
...
- service: media_player.media_stop
target:
entity_id: media_player.sonos_salon
- choose:
- conditions: "{{ states('switch.ds418_home_mode') != 'unavailable' }}"
sequence:
- service: switch.turn_on
target:
entity_id: switch.ds418_home_mode
default:
- service: notify.persistent_notification
data:
title: 'Warning - Problem with switch'
message: 'Could not turn on switch.ds418_home_mode because it is unavailable.'
- service: light.turn_off
target:
entity_id: light.ikea_tradfri_driver_30w
...
OK then implement the suggested changes in my previous post. If the switch’s state is notunavailable it will be turned on. If it isunavailable it will report it via a persistent notification and then continue to the next action. The “choose/default” serves as an “if/else”.
Yes for sure the “choose/default” solution will work for this automation when generated outside blueprint but in my case this is an automation generated by blueprint :
So this has to be changed a bit for compatibility to the blueprint ( not sure and not tested ):
# add variables from input selector :
switch_name: !input "switches_on"
# action part for all switches to turn on
- choose:
- conditions: "{{ states('switch_name') != 'unavailable' }}"
sequence:
- service: switch.turn_on
target:
entity_id: !input "switches_on"
default:
- service: notify.persistent_notification
data:
title: 'Warning - Problem with switch'
message: 'Could not turn on {{ switch_name }} because it is unavailable.