The automation action below works for the “turn_on” service but gives following error for the “turn_off” service, how do I specify extra data for the “turn_on” service but not the “turn_off” service?
Error when the “turn_off” service is called.
Stopped because an error was encountered at April 4, 2022, 10:40:43 AM (runtime: 1.23 seconds)
I would typically approach this using a choose action with two options. The first has the following condition, {{ is_state('media_player.living_room','playing') }} and then performs the turn_on with effect.
The second option would have an opposite condition, eg {{ not is_state('media_player.living_room','playing') }} (or equivalent) and then performs the turn_off with no extra data.
When using a choose action, you place your conditions in each “choose option”. These will not appear until you select the choose action in the automations GUI editor. Leave the primary ‘condition block’ of the automation blank for now.
Once you have your two “choose options”, yes, the automation will select the first “branch” that meets the condition specified.
I bet once you see it in the GUI you’ll have a better understanding as your automations can branch off different scenarios.
Wasn’t aware this was an option, didn’t see any reference of it in the docs, either way I have no idea where to start or how to apply it to my automation.