How can i do this template to work

Hello
I would like to know if i can use this type of template format i tried different types of this and never worked, it’s supposed to return the state of the data_xxx sensor but i got an error formating:

'{{ states.sensor.data_{{ states.input_select.chooser.state }}.state }}'

This is my error message:
Error rendering template: TemplateSyntaxError: expected token ‘end of print statement’, got ‘{’
Thanks

You can’t have a template inside a template. But you can do what you want this way:

"{% set e = 'sensor.data_' ~ states('input_select.chooser') %}{{ states(e) }}"

Thanks Will try it
Cheers

Worked Charm!! thanks

1 Like