for a futur blueprint i need templating something like that but i don’t find the syntax
{% set today2 = now().strftime('%A') | lower %}
{{ today2 }}
{% set saturday_morning_time = states('input_datetime.saturday_morning_time') %}
saturday morning time : {{ saturday_morning_time }}
{% set morningtime = {{ today2~'_morning_time' }} %}
morningtime : {{ morningtime }}
I don’t find the syntax for having the value of "morningtime" which is the state of the concat with the day.
Also the same of the variable saturday_morning_time
I try brackets, simple quote, curly brackets, double quote, parenthesis…
Is anybody have an idea please ?
Thanks a lot
The idea is to have sunday_morning_time and compare in a template using today2
I don’t want this.
this give me the string if the value of today2 is saturday for exemple, the result is saturday_morning_time
What i want is the value of saturday_morning_time in the variable morningtime concat by today2~_morning_time
that’s why i put the curly brackets. around today2~_morning_time
{% set morningtime = {{ today2~'_morning_time' }} %}
Anyway, you definitely cannot nest one template in another.
It’s not entirely clear to me what exactly you are attempting to achieve. It appears you are trying to evaluate this template first:
{{ today2~'_morning_time' }}
To produce a string like saturday_morning_time.
That string represents the name of an existing variable and you want to assign its value to a new variable called morningtime.
In other words, you are trying to do this:
{% set morningtime = saturday_morning_time %}
Except you don’t know the name of the variable on the right hand side, you are trying to create it dynamically with today2~'_morning_time'. Is that correct?
If my understanding of what you are trying to do is correct, I don’t believe it’s possible. You’re looking for the ability to dynamically create a variable’s name and then get its value. That would require something like python’s eval function but it isn’t available here.
Thanks a lot. I will search but at this moment i dont know how to do with the blueprint in whic is declare like
saturday_morning_time:
name: 'Heure de début de la période : "SAMEDI MATIN"'
description: Heure du début de la période du "SAMEDI matin".
default: "06:00:00"
selector:
time: