I want to create a card in lovelace that can configure and start a timer. For context: When the timer finishes, I want to turn off my bedroom lights.
I found the timer integration, but when I create one without duration, the corresponding entity card in lovelace doesn’t let me set a time.
My idea was to use an input for the duration (either input number or input datetime). But how would I then create a card in lovecard that allows me to set the input and then start the timer? When the timer is running, the input shouldn’t be editable (or maybe not shown at all?) but I’d like to see the remaining time. After the timer finished, it would be great if the last input would be remembered so I could start the timer with the same duration again (or change it).
There is a way to accomplish what you want but it will require a bunch of pieces.
like you said you can use an input number for minutes (and another for hours if necessary) to set the duration of the timer.
Then you can create an automation to start the timer based on you turning on an input boolean, which you also need to create.
Then as for the lovelace card you can use a conditional card to only show the input number(s) if the timer is not active (which is the state of a running timer). As long as you don’t set an “initial” valiue once you set the input number(s) they won’t change unless you change them so that won’t be an issue.
Then you could add the timer and boolean to an entities card (or include the entities card and the conditional card in a vertical stack to keep them all in “the same” card) so you always have the ability to see the remaining time and, if your timer control automation is set up correctly, both start and stop the timer.
automation, triggered by numeric states of the input number above 0, delay input number, turn off action, set the numeric state to 0 (via calling a service).
this means when I change the slider, an event is triggered.
alias: Turn OF Timer for AC Parents
description: ''
trigger:
- platform: numeric_state
entity_id: input_number.ac_timer_minutes
above: '0'
condition: []
action:
- delay:
minutes: '{{ states(''input_number.ac_timer_minutes'') | int }}'
- device_id: xxxxxxxxxx
domain: climate
entity_id: climate.parents_ac
type: set_hvac_mode
hvac_mode: 'off'
- service: input_number.set_value
target:
entity_id: input_number.ac_timer_minutes
data:
value: 0
mode: single