Hi, I need a global function which provides directly a result as text or number.
The function should have a return_type: text or number
My case:
I would like to fill an input_text or variable with a name of day in german.
The day should be calculated out of now().isoweekday().
But sometimes I need the value of now().isoweekday() - 1 or -2 or +5 as an example.
Yes, I could write a script, handover the determination parameter and write the result into a variable.
In my special case, it might work. But having more of these requirements would cause to a number of variables only for function results. The other way round, create one variable only for function results could lead into timing problems because I don’t know if the script execution is a closed transaction.
Example usage:
- service: input_text.set_value
data_template:
entity_id: input_text.last_irrigation_weekday
value_template: >
{% if condition 1 %}
{{ get_name_of_day( now().isoweekday()) }}
{% else %}
{{ get_name_of_day( now().isoweekday() - 1) }}
{% endif %}