hello
i explore variables in scripts
i have a test one like this:
triggered by change in input_text.it_start an automation passes it_n to the script
it does :
- shows the fact the script is launched
- shows the input param === it_n
- shows a (little) action on the param received
- passes the same param to another script for testing:
script:
param_test_01:
# attend la variable it_n
alias: param_test_01
variables:
it_n_2_pass:
sequence:
- service: input_text.set_value
data:
value: script 01 action active [{{it_n}}]
target:
entity_id:
- input_text.it_info
- service: input_text.set_value
data:
value: paramtre entré dans script 01 [{{it_n}}]
target:
entity_id:
- input_text.it_01_in
- service: input_text.set_value
data:
value: sortie de script 01 [{{it_n|upper}}]
target:
entity_id:
- input_text.it_01_out
- service: script.param_test_02
data:
it_n02: "{{it_n|upper}}" # avec data: cad en direct ok 2022-11-04_18-19 mais pas de transmission
mode: single
it works!
BUT i cannot manage to have much more complex actions on the input param
so HOW TO use the input parameter in template and make the result the output of the script
EG (this sequence works in template WUI , it cleans string):
{% set it_nn = it_n
|lower
|regex_replace(find='[àáâãäå]', replace='a', ignorecase=False)
|regex_replace(find='[éèêë]', replace='e', ignorecase=False)
|regex_replace(find='[ïî]', replace='i', ignorecase=False)
|regex_replace(find='[ùµûû]', replace='u', ignorecase=False)
|regex_replace(find='[^\w]', replace='_', ignorecase=False)
|regex_replace(find='[_]+', replace='_', ignorecase=False)
|regex_replace(find='[_]$', replace='', ignorecase=False)
|regex_replace(find='^_', replace='', ignorecase=False)
-%}
{{it_nn}}
How to achieve that ?
PS: i have tested data_template…with no succes