dawnlord
(Christer)
November 19, 2018, 8:04pm
1
Hi all,
I hope this is possible but i am stuck with errors…
What i want to accomplish is to run script.1 if condition Y and script.2 if condition X
- service: script.turn_on
- condition: template
value_template: >
{% if is_state('media_player.all', 'off') %}
script.coffeedone_tts
{% else %}
script.coffeedone_notts
{% endif %}
dawnlord
(Christer)
November 19, 2018, 8:20pm
2
I have also tried editing like in this post without any luck
Excellent!!! It’s works!
Here the code with correct spacing:
tea:
alias: Tea
sequence:
- service: script.turn_on
data_template:
entity_id: >
{% if is_state('switch.Sonoff20a', 'off') %}
script.tea1
{% elif is_state('switch.Sonoff20a', 'on') %}
script.tea2
{% endif %}
tom_l
November 19, 2018, 9:30pm
3
- service: script.turn_on
data_template:
entity_id: >
{% if is_state('media_player.all', 'off') %}
script.coffeedone_tts
{% else %}
script.coffeedone_notts
{% endif %}
Or if you have no variables to pass:
- service_template: >
{% if is_state('media_player.all', 'off') %}
script.coffeedone_tts
{% else %}
script.coffeedone_notts
{% endif %}
tom_l
November 19, 2018, 10:08pm
5
Don’t you need a service for the service_template?
i.e. “script.turn_on”
dawnlord
(Christer)
November 19, 2018, 10:18pm
6
Thank you @tom_l & @pnbruckner that solved my meltdown
would you mind posting the completed working code? or did you use Tom’s exactly as is? I am thinking of changing some of my code to use a similar method. Cheers
The script name is a service. Try this:
grep registered home-assistant.log
Or just go to the Services page and you can see all your scripts are shown as services.
1 Like
tom_l
November 20, 2018, 12:12am
9
Well there you go. I learned something today. Thanks.
1 Like