Thank you @tom_l
I must have missed the notification for your reply. Tried it out now, but cannot seem to create a custom timer.
Anybody else in need for such a thing and might want to build it together?
Here are my /config/packages/testing/timer_test.yaml
contents (split to leave some room for explaining)
the timer itself
timer:
timer_test:
name: TEST Test Timer
duration: '00:00:05'
icon: mdi:clock
test trigger
input_boolean:
test_timer:
name: TEST Timer
initial: off
icon: mdi:clock
automation: when timer runs out, (1) send notification via telegram (just to debug that it worked) and (2) set input_boolean to ‘off’ again
automation:
- id: "testtest"
trigger:
- platform: state
entity_id: input_boolean.test_timer
to: 'on'
action:
- service: timer.start
entity_id: timer.timer_test
- id: "testtest2"
trigger:
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.timer_test
action:
- service: notify.me_test
data:
message: "Timer okay."
- service: input_boolean.turn_off
entity_id: input_boolean.test_timer
The above all works. As soon as I trigger the timer via input_boolean
, the timer will count down from 5 to 0 (in unused entities
); when this is done, it will send a test notification and set the switch back to ‘off’.
I then tried to set up an input_select
for all my switches so that I could dynamically pick an entity that I want the timer to work on; this is a work in progress… I imagine the finished result to be a card that allows you to
- pick an entity
- set an off timer (either just minutes and/or hours and minutes)
- activate the timer via
input_boolean
(or similar; I just want some dedicated trigger so that if I accidentally chose an incorrect device from the input_select
, it will not fire right away but wait until I pressed the button to do so.
I added this part, which is just to see how (or if) things work before doing templates etc.
- id: 'entitest'
trigger:
- platform: event
action:
- service: input_select.set_options
data:
entity_id: input_select.switches
options: ["arbeitszimmer_ventilator", "unknown_dingens"]
I assumed that this would create an input_select
with each value declared in options
as an option (see docs here).
The reason for naming it input_select.switches
was that I wanted to first create a timer each for lights, switches, and perhaps groups, just because they all require different services (for example, switch.turn_off for switches, light.turn_off for lights, etc.).
This entity does not show up, though.
As I said before, I was going to set up the options manually before testing templates, with templates, I thought of using expand
, then putting anything I’d want to control via this timer in a group. For example {{ expand('group.all_lights') | selectattr('friendly_name') }}
; however, while {{ expand('group.all_lights') }}
will display an overview of all entities in this group (as well as their attributes etc.), I was not able to get a list of all their entity_ids and perhaps friendly_names.
I was hoping that it’d be possible to create an input_select displaying the friendly_name value while using the entity_id value. So that I’d have a dropdown list like
- AZ Ventilator
- AZ Computer
- SZ Glotze
that would not use these values in the automation, but instead the appropriate entity_id per friendly_name, so in this case (same order as above)
- switch.arbeitszimmer_ventilator
- switch.arbeitszimmer_computer
- switch.schlafzimmer_tv
I will keep testing different things to see if I can first create a timer for manually inserted options (as entitest
above), and, if this works, automatically insert those options via template. If anybody is interested in this, please comment here, perhaps we can figure it out together (I started Home Assistant not too long ago, so I am still getting into yaml and the logic it uses).