@pploume wrote:
Hi,
Still trying to understand templating …
I’ve read the Jinja docs but … I misunderstand how the use of namespace(var=val), or may be it’s the scope.
The assignment ’ set ns = namespace(…’ is OK, no error
But when trying to use in -service:rest_command, the error ‘ns undefined’ raise !What I want to do is :
set/define a variable and be able to use it later, in another service (same trigger …)
How to do that ?I guess I also misunderstand the ‘embebdment’ and interactions of/between differents items like service: , action: …
Any ‘for the noob’ docs on this subject ? Thanks for a link I would be able to understand …alias: 'rhasspy SetLight' trigger: platform: event event_type: rhasspy_SetLight #event_data: # piece2: piece action: - service_template: > {% set action = trigger.event.data.action %} {% set niveau = trigger.event.data.niveau %} {% set ns=namespace(test="test") %} {% if action == 'allume' %} light.turn_on {% elif action == 'éteint' %} light.turn_off {% else %} chabada {% endif %} data_template: entity_id: light.bureau - service: rest_command.tts data_template: payload: > {% set piece = trigger.event.data.piece %} {% set action = trigger.event.data.action %} j'{{action}} la lumière de {{piece}} et {{ns.test}}
Thanks for help !
p
Posts: 3
Participants: 3