fra
(francesco)
January 8, 2024, 8:32pm
1
Dear all,
i have the following scenario:
input select 1: hours from 10:00 to 15:00 (step 15min: 10:15…10:30…11:00)
input select 2: hours from 10:00 to 15:00 (step 15min: 10:15…10:30…11:00)
i’m trying to achieve this goal:
if i select 12:00 in input_select_1 then in input_select_2 automatically i have to show only hours bigger then the value selected in input_select_1 (ex from 12:15 to 15:00)
Thanks a lot!
If you want dynamic options, you need a Template Select for #2 , not an Input Select.
There is an previous thread where I have posted a number of examples of Template Selects:
I totally agree that they are under-documented and confusing, partly because they are very open-ended. I have a suspicion that they may be of little practical value to most users.
The basic function of state-based Template selects seems to be to make it so you do not have to create separate input select helpers and automations. If you want a single functional unit, they can be used like mini-automations with State triggers.
Semi-Practical Examples
Example 1: Proxy/Translate an Existing Sele…
fra
(francesco)
January 8, 2024, 10:37pm
3
Thanks a lot man!
I’m going to study the topic!!!
Your options
template could be:
{%- set input_1 = states('input_select.EXAMPLE') %}
{% set time_limit = today_at(input_1) %}
{%- set opt = state_attr(input_1, 'options') %}
{%- set ns = namespace(options=[]) %}
{%- for t in opt %}
{%- set ns.options = ns.options + [t] if time_limit < today_at(t) else ns.options %}
{%- endfor %}
{{ ns.options }}
1 Like