I’ve created a timer and a slider, via helpers (see screenshot). I want the starting time of the timer to be updated by the value of the slider.
Ultimately, I’d like to use it to make an automation that will turn off the kids gaming devices in x minutes, where x is whatever I define on the slider.
Any advice out there on how to go about this?
1 Like
I would something very similar, did you make any progress? Willing to share the code ?
Thanks in advance
I did figure this out. I found a relevant thread, titled Put together a sleep timer slider, and was able to modify it to work for my purposes.
The basic procedure is:
- The trigger is a sensor template you add to the config file. I copied and pasted his, adapting for my specific input entities. The 2 entities are an input boolean and an input timer.
- Use the input boolean (toggle) as a condition. So, when it’s on, the timer works.
- For the action, turn off the devices and your input boolean.
I created a helper that can be presented as a slider in lovelace running from 0 to 60:
input_number:
irrigation_popup:
name: "irrigation popup"
min: 0
max: 60
step: 5
icon: mdi:sprinkler
mode: slider
unit_of_measurement: Minutes
and an automation that if this helper goes above 0 it will repetitively decrease with 1 and wait 1 minute until 0 after which it switches of a tasmota device:
- id: '1654877730085'
alias: irrigatie popup
description: irrigatie via popup
trigger:
- platform: numeric_state
entity_id: input_number.irrigation_popup
above: '0'
condition: []
- repeat:
until:
- condition: numeric_state
entity_id: input_number.irrigation_popup
below: '1'
sequence:
- delay:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
- service: input_number.set_value
data:
value: '{{ (states("input_number.irrigation_popup") |int ) - 1 }}'
target:
entity_id: input_number.irrigation_popup
- service: switch.turn_off
data: {}
target:
entity_id:
- switch.tasmota99_4
mode: single
2 Likes
This is what the final product looks like for mine:
I am trying to make this work but it the automation keeps giving me this message
"Message malformed: Expected a dictionary @ data['condition'][0]"
Would you have any suggestion ?.
Thanks in advance
No, I don’t have a suggestion other than that HA is extremely picky with indents. I found the Studio Code Server add-on very useful in finding these errors.