Hi everybody,
I am trying to create a card that will let me chose from a list of entities, then allow me to set an amount of time, then shut down that entity.
Previously I had used a card that had two hard-coded entities, each with a hard-coded timer and input_select, but that was very limited; I’d have to create an options
entry in input_select
for each entity, as well as to create an individual input_select for (pre-defined) times for each entity.
Here is my new attempt, but I am already stuck…
group:
to_shut_off:
name: "timer test"
entities:
- switch.office_fan
- switch.bedroom_tv
- switch.livingroom_tv
input_select:
off_timer:
options:
- dummy option 1
- dummy option 2
automation:
- id: ".."
alias: ".."
trigger:
- platform: time_pattern
seconds: 10
action:
- service: input_select.set_options
data_template:
entity_id: input_select.off_timer
options: |
{% for each in expand('group.to_shut_off') %}
{{ each.entity_id }}
{% endfor %}
I expected this to create an input_select
containing all entity_id
s in the to_shut_off
group. When I run the template from options
in templates, it will do this.
(there is probably a much better way than doing this via time_pattern
, but for testing purposes I thought this would be a quick way to check whether or not the automation worked at all; it didn’t, input_select
kept the two dummy options)
Currently there are three main issues on my mind:
- how do I successfully create this
input_select
field that will let me pick one of the entities in the group? - how do I create a timer (or instead of “counting down” just calculate the value, for example, if I set a timer for 30 minutes, don’t count down from 00:03:00, but rather just set a shutdown variable to
now + 00:03:00
; hope I explained this okay) - how do I assure that multiple of these can run at the same time? For example, I’d like to be able to set a timer for entity 1 in 30 minutes, start it, and (perhaps 20 minutes later) set another timer for entity 2 for 90 minutes without the first timer to stop/disappear, so that entity 1 will shut of (in this case) ten minutes after I set the second timer and entity 2 will shut of 80 minutes after entity 1 (because when entity 1 turned off, 10 of those 90 minutes will have passed)
Thank you for your ideas