I want to write two scripts in the same scripts.yaml file.
I wrote the first script and every things worked great.
Here is the first script:
ac_commands:
alias: AC Commands
sequence:
- service: mqtt.publish
data:
topic: cmnd/ACֹ_LivingRoom/IRsend
payload_template: '{% if is_state(''input_select.ac_switch'',''False'') %} 0,8984,4500,644,564,640,564,644,1664,644,560,648,564,640,568,640,1664,644,560,648,
1660,648,564,644,560,644,1672,640,560,644,560,648,564,640,564,644,564,644,560,
644,560,648,564,640,560,648,1664,644,568,640,564,640,568,640,620,584,564,644,
564,644,1660,644,564,644,1668,640,564,644,560,648,1660,648,564,640,19996,648,1664,
644,564,644,568,640,564,644,564,640,560,648,564,640,564,644,564,640,564,644,568,
640,560,644,568,640,568,640,564,640,568,640,624,580,564,644,564,644,564,640,568,
640,568,640,564,644,564,640,564,644,564,640,568,640,564,644,1668,640,1664,644,1668,640,564,644
{% elif is_state(''input_select.ac_switch'',''True'') and is_state(''input_select.ac_mode'',''Heat'')
and states(''input_number.ac_temperature'')|int == 16 %} 0,8984,4500,616,592,616,592,612,1696,616,1692,612,596,612,592,640,1668,640,568,
616,592,612,596,636,568,616,592,616,592,612,592,616,592,612,596,612,592,612,
596,612,596,612,592,616,592,612,1696,616,1692,612,596,612,592,616,592,616,
592,612,596,612,1696,612,592,616,1692,612,596,612,596,612,1696,612,592,616,
20032,640,1668,640,568,612,592,616,592,616,592,612,596,612,592,616,592,616,
592,612,592,616,592,612,596,612,592,616,592,616,592,612,596,612,592,616,592,
616,592,612,592,616,592,612,596,612,596,612,592,616,592,612,596,612,592,616,
592,616,592,612,1696,612,1696,612,596,612
{% elif is_state(''input_select.ac_switch'',''True'') and is_state(''input_select.ac_mode'',''Heat'')
and states(''input_number.ac_temperature'')|int == 17 %} 0,8984,4500,612,596,640,564,616,1692,616,1696,612,592,616,592,616,1692,640,568,616,1692,640,568,612,592,640,568,616,592,636,572,612,592,616,5$
{% elif is_state(''input_select.ac_switch'',''True'') and is_state(''input_select.ac_mode'',''Heat'')
and states(''input_number.ac_temperature'')|int == 18 %} 0,8984,4500,612,596,640,564,616,1692,616,1696,612,592,616,592,616,1692,640,568,
616,1692,640,568,612,592,640,568,616,592,636,572,612,592,616,592,612,592,616,
592,632,576,612,596,612,592,616,1692,640,1672,612,592,616,592,612,596,612,592,
616,592,612,1696,612,596,612,1696,612,596,636,568,616,1692,612,596,616,20028,616,
1696,612,592,616,592,612,592,616,592,616,592,612,596,636,568,616,592,612,592,616,
592,616,588,644,564,616,592,612,596,612,604,604,592,616,592,612,592,616,592,612,
592,640,568,616,592,612,592,616,592,616,592,640,576,604,592,616,1692,616,1696,612,1696,616,592,612
{% endif %}
Today I wanted to write another script that doing another thing, in the same file. So I tried to create a new script in the home assistant UI and edit it: (I don’t want to call a service in this script, I just want to check conditions in template and active an automation)
'1587080539465':
alias: Rainy weather
sequence:
- data: {}
service: cover.close_cover
data_template:
entity_id: >
{% if is_state('sun.sun','above_horizon') and (states.sensor.time.state < "14:00") and ((is_state('weather.byt','sunny') or is_state('weather.byt','cloudy') or is_state('weather.byt','partlycloudy')) %}
automation.ptykht_trysym_bbvqr
{% elif (states.sensor.time.state >= "14:00") and is_state('sun.sun','above_horizon') and ((is_state('weather.byt','sunny') or is_state('weather.byt','cloudy') or is_state('weather.byt','partlycloudy')) %}
automation.sgyrt_trysym_btshryym
{% elif is_state('sun.sun','below_horizon') and (states.sensor.time.state < "23:00") and ((is_state('weather.byt','sunny') or is_state('weather.byt','cloudy') or is_state('weather.byt','partlycloudy')) %}
automation.ptykht_trysym_khh_ts
{% elif (states.sensor.time.state >= "23:00") and is_state('sun.sun','below_horizon') and ((is_state('weather.byt','sunny') or is_state('weather.byt','cloudy') or is_state('weather.byt','partlycloudy')) %}
automation.sgyrt_trysym_blylh
{% endif %}
Now, I have an error in the configuration check:
Invalid config for [script]: invalid template (TemplateSyntaxError: unexpected '}', expected ')') for dictionary value @ data['script']['1587080539465']['sequence'][0]['data_template']['entity_id']. Got '{% if is_state(\'sun.sun\',\'above_horizon\') and (states.sensor.time.state < "14:00") and ((is_state(\'weather.byt\',\'sunny\') or is_state(\'weather.byt\',\'cloudy\') or is_state(\'weather.byt\',\'partlyclycloudy\')) %}\n automation.ptykht_trysym_bbvqr\n{% elif (states.sensor.time.state >= "14:00") and is_state(\'sun.sun\',\'above_horizon\') and ((is_state(\'weather.byt\',\'sunny\') or is_state(\'weather.byt\',\'cloudy\') or is_state(\'weather.byt\',\'partlycloudy\')) %}\n automation.... (See /home/homeassistant/.homeassistant/configuration.yaml, line 14). Please check the docs at https://home-assistant.io/components/script/
I don’t know what the problem. I want to write the two scripts in the same file
Thanks for your help.