Template in Template

Hi everybody !

I try to combined template without success. The aim is to use a state of an input_select to search a sensor state…
I have no idea if it’s possible or not…


{{ states.sensor.{{states.input_select.town_notifications_william.state}}_rain_chance.state }}

Did you already try it ?

thank you !

As mentioned, you cannot nest templates.

Try this:

{% set rc = 'sensor.' ~ states('input_select.town_notifications_william') ~ '_rain_chance' %}
{{ states(rc) }}

It can be reduced to a single line:

{{ states('sensor.' ~ states('input_select.town_notifications_william') ~ '_rain_chance') }}
1 Like

Whoua, it works like a charm !
Thank you so for the answer really clear and fast !!

1 Like