@th1234 wrote:
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,5$
{% 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,59$
{% 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,9012,4560,580,564,644,564,640,1672,636,1728,580,572,636,628,576,1672,640,624,580,568,640,1668,644,568,636,564,644,576,628,568,640,568,640,6$
{% elif is_state(’‘input_select.ac_switch’’,’‘True’’) anToday 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’,'partlyc$
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’,'part$
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’,'partl$
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’,'part$
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.
Posts: 2
Participants: 2