Hi,
I’m new to H.A. and still struggling to learn H.A yaml and jinja2 syntaxes because of the horrible documentation…
So, what I’m trying to do.
I have a script to execute the open/stop/close commands for my curtains thru RF control.
I’m trying to use some template/code logic to keep it smaller.
Here I wrote a test script, which only send to me a notification with the result, to check if it works.
The jinja2 code works, tested on the template developers page.
However, the variable of the script do not integrate with the variable inside of the template.
First thing is: Where I should run this templating? Since it is a code to set some logic . The wait_template does not appear to be the right place for my objective.
Second: why the variable “persiana_device” wasn’t set when I call this script setting the “persiana” variable with a valid value.
Here is the script.
teste_script:
alias: teste script
variables:
persiana: persiana
comando: ono
persiana_device: onoono
sequence:
- choose:
- conditions: []
sequence:
- wait_template: >
{% set persiana_device = {
"persiana_quarto_visita" : "Persiana Quarto visita",
"persiana_quarto_augusto" : "Persiana Quarto Augusto",
"persiana_direita_quarto_suite_master" : "Persiana Direita Quarto Suite Master",
"persiana_esquerda_quarto_suite_master" : "Persiana Esquerda Quarto Suite Master",
"persiana_quarto_inf_rampa" : "Persiana Quarto inf Rampa",
"persiana_quarto_inf_casinha_gas" : "Persiana Quarto inf Casinha Gas"}[persiana] | default("ono")
%}
{{ persiana_device != "ono" }}
continue_on_timeout: true
- service: notify.mobile_app_sm_a725m
data:
message: 'teste comando: {{ persiana }} = {{ persiana_device }} comando
{{ comando }}'
mode: single
icon: mdi:blinds
Here is how I call it :
- service: script.teste_script
data:
persiana: persiana_quarto_inf_rampa
comando: abrir
Checking the trace.
Here they just show the step was completed as true, where I deduce this mean the variable persiana_device was set correctly.
However on the next step, to send me the notification, I see it set with the default value from the script.
What I’m missing here?
I tried a lot of ways , all without success…
Please, if have any documentation to refer where explain how to do this I really like to know.
Thanks!