taddeuz
(Philip Taddey)
January 3, 2019, 10:16am
1
Hey,
I would like to add a timer to my frontend, but it should be startable via an input boolean. So, when I switch the input boolean to active, the timer starts and I see the remaining time. When I turn it off, it will stop.
I will also send a notification to my phone when the timer ends (I already implemented notifications, should be no problem).
My wife would like to have some timers, for example to see when the washing machine is done. Therefore, I am going to define multiple timers (for all important programs of the machine).
I already found this solution: An example of a countdown timer, and some related questions But is there an easier way?
1 Like
You could get a little bit fancy and really impress the Mrs with dedicated washing machine sensor.
This is a guest post by Home Assistant user and contributor Nolan Gilley .
Today I’ll show you how I used Home Assistant, a NodeMCU (ESP8266), and a couple of accelerometers to automate our laundry room. This is a rewrite of an old post where I did the same thing using a Moteino & Raspberry Pi. This version only requires a NodeMCU.
We have an older washer and dryer which doesn’t have any form of notification when cycles complete. Home Assistant was the obvious solution, I just needed to create…
I did similar but used ESPeasy instead of the code provided.
taddeuz
(Philip Taddey)
January 3, 2019, 1:14pm
3
That would be really nice but I think thats a project for the future with some time.
For now, a manual timer would be nice.
bigfuz
January 3, 2019, 8:25pm
4
Sleep timer for my TV, i just wrote. Just started using Home Assistant. Any tips or improvement are welcome!
input_number:
sleep:
name: sleep
initial: 45
min: 15
max: 120
step: 15
mode: slider
input_boolean:
sleep:
name: sleep
initial: off
timer:
sleep:
name: sleep
automation:
- alias: Timer start
trigger:
platform: state
entity_id: input_boolean.sleep
to: 'on'
action:
service: timer.start
entity_id: timer.sleep
data_template:
duration: "{{ states('input_number.sleep') | int * 60 }}"
- alias: Timer cancel
trigger:
platform: state
entity_id: input_boolean.sleep
to: 'off'
action:
service: timer.cancel
entity_id: timer.sleep
- alias: Timer stop
trigger:
platform: event
event_type: timer.finished
event_data:
entity_id: timer.sleep
action:
- service: input_boolean.turn_off
data:
entity_id: input_boolean.sleep
- service: remote.turn_off
entity_id: remote.livingroom
16 Likes
taddeuz
(Philip Taddey)
January 3, 2019, 10:10pm
5
Great, thank you.
Is there a way to see the remaining time in the fronted (as sensor or something else)?
You should be able to do this using a template sensor.
Using your timer in the template.
{{states.timer.your_timer.state}}
taddeuz
(Philip Taddey)
January 4, 2019, 9:12am
7
I already tried that but with no effct.
When I add the template sensor {{states.timer.mytimer.state}} I get only “Idle”.
taddeuz
(Philip Taddey)
January 4, 2019, 2:49pm
8
I found a solution, just adding the entity to my lovelace ui:
type: entities
title: Washing!
show_header_toggle: false
entities:
timer.washing displays the remaining time. No other code needed.
1 Like
Hello
can be used with any entity?
thanks
Hello everyone,
He added a configuration to my configuration.yaml and in entities he selected this, but he won’t get the counter operated, could he help me?
Hello, i try the same but don’t manage to get it work.
Automatisation:
alias: Arrosage
trigger:
- entity_id: input_boolean.test
platform: state
condition: []
action:
- data:
entity_id: timer.arrosage
service: timer.start
data_template:
duration: '{{states.input_number.duree_arrosage | int }}'
Can anyone please help me?
You may have solved this by now but, you need to delete - data:
from the action. You could use File editor to access the automations.yaml.
I search all the week, try everithing but not this , thanks men, you rock!!
The solution:
Automatisation:
alias: Arrosage
trigger:
- entity_id: input_boolean.test
platform: state
condition: []
action:
- data_template:
duration: '{{states.input_number.duree_arrosage | int }}'
entity_id: timer.arrosage
service: timer.start
I talk to early, it don’t take the duration of the input number.
I think it should be '{{states.input_number.duree_arrosage.state | int }}'
note the addition of .state
Thanks a lot. It work perfectly this time
Automatisation:
alias: Arrosage
trigger:
- entity_id: input_boolean.test
platform: state
condition: []
action:
- data_template:
duration: '{{states.input_number.duree_arrosage.state | int }}'
entity_id: timer.arrosage
service: timer.start
I try to improve it with input_datetime, but the timer get immediatly in idle position
- data_template:
duration: "{{states.input_datetime.arrosage_manuel.state | int| timestamp_custom('%HH:%MM', False) }}"
Here’s a topic that could resolve your problem: -
Hello All,
I have an automation that works how I want for the most part but I would love to be able to edit the timer length from love lace. I can’t seem to get the right formatting to make the lovelace input work for my automation.
For this action:
action:
- data: {}
entity_id: timer.garagelight
service: timer.start
I would like to reference the input_datetime input I made for love lace.
I have tried the following with no luck:
entity_id: timer.garagelight
duration: {{ states…
It appears you just need to use {{states.input_datetime.arrosage_manuel.state}}
.
just for my OCD (and YAML’s) you should work on a 2xspace principle as well, so
- data_template:
duration: "{{states.input_datetime.arrosage_manuel.state}}"
should be
- data_template:
duration: "{{states.input_datetime.arrosage_manuel.state}}"
An alternative solution is to use an input_datetime as your trigger i.e. set the time for when your timer should end.
trigger:
- platform: template
value_template: '{{ states(''sensor.time'') == (state_attr(''input_datetime.arrosage_manuel'',
''timestamp'') | int | timestamp_custom(''%H:%M'', False)) }}'
Your input_boolean (or the state change of the input_datetime) could just turn the automation on. You could add an action at the end to turn the automation off again, so it doesn’t trigger daily.
This has the added bonus that a restart of Home Assistant won’t affect this working. If Home Assitant is just counting down a duration and Home Assistant restarts then the duration will be forgotten.
It work.
Thanks for your time.
Thanks! This works great!