Use Timers to build Reliable Automations in Home Assistant

Use Timers to build Reliable Automations in Home Assistant

SlackerLabs

1 год назад

70,944 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Tinly
Tinly - 26.10.2022 23:36

This is not functionally replacing the for function. The for function triggers, when something holds a specific state for some time (i.e. 20 minutes). This on the other hand triggers 20 minutes after the thing changed to the new state even if it does not hold the new state for 20 minutes. If that is fine for your use case - great. But it's not equivalent. Also It's not that easy to fix. You could check for the new state after the timer finished again but that would not tell you if the thing holder the state for the whole 20 minutes but instead it now tells you if the device was in the state 20 minutes ago and now. You don't know what's been between those two points in time. Again: if that's sufficient for your use case that's great but it's not the same as the for attribute does.

Ответить
xelemorf
xelemorf - 03.11.2023 16:47

It's more effective to do these with time pattern as trigger
and with conditions instead.

Ответить
Dusty Ward
Dusty Ward - 14.10.2023 21:08

Why use motion sensors as a prime example to use timers, then show how you use it for a air freshener?

Ответить
Derek
Derek - 14.09.2023 06:04

For years, I've used Node-RED as my automation platform. I started using it before there was an automation UI in HA and just never ventured into it because my automations in NR worked just fine. Recently, I wanted to move some of the automations from NR to HA in order to incorporate some extra details into my dashboard.
Right off the bat, I struggled to get some sort of script-like capability from the automation. Four things could happen which each would need to be handled differently: light turns on, light turns off, motion detected (with IF light is on or off), and timer expired. The trigger_id was the key to getting everything to mesh properly (along with Choose which I was already trying to utilized.)
Thanks for the video that set me on the right path.

Ответить
dudefromkeene
dudefromkeene - 13.09.2023 05:36

Thanks for this, I used the timer helper along with a count helper to override a thermostat auto shut off when the windows are open by turning it on 3 times within 5 min, in which event the the automation is turned off and your are free to use the thermostat as usual.

Ответить
D
D - 16.08.2023 03:46

Slightly cleaner for the "on" logic is to check if the timer is idle. If not cancel it. Not sure what timer.start produces if the timer is already running. A manual off could also cancel the timer.

Ответить
notureaveragemiss
notureaveragemiss - 14.08.2023 08:13

It kinda seems like you are combining two automations together to me. Maybe I'm missing something

Ответить
Wowbagger Da Infinite
Wowbagger Da Infinite - 26.07.2023 16:54

Thanks for the information! I'm just about to get HA up and running on a NUC and this is timely information. I like the timer idea, but I'm very attention deficit and always take longer to do something than I estimate. Wonder if there is a way to configure HA so that at the end of the timer it will perhaps send a popup via phone and ask for you to confirm turnoff?

Ответить
MK KM
MK KM - 15.07.2023 19:36

Brilliant. I automated my wife's closet door (door open = light on, closed = light off) but she leaves it open too often, so I just added a 5 minute timer as protection against forgetfulness. Sweet!

Ответить
Eli Johnson
Eli Johnson - 11.07.2023 03:23

Setting this up is ridiculously tedious and sad...this type of thing is one of the many reasons people dislike HA. The fact that the "For" option cannot handle this says it all. Even Google finally figured out how to handle delays and far better than HA no less. I know it took Google 10 years to finally implement delays but at least when they did, it worked without feeling like you are trying to program your way out of the rabbit hole. The "For" option in HA really should have been all the user needs to fill in to make delayed actions persistent and reliable.

Ответить
Schrödingers Mechanic
Schrödingers Mechanic - 01.07.2023 16:49

For my light automations I tie them in with door sensors. If motion is detected and the relevant door is closed the room is obviously occupied. For motion only activation I set the delay to 2.5 times the reset time of the sensor. These two techniques work extremely well for me.

Ответить
Paul Bacon
Paul Bacon - 06.05.2023 23:30

Great tutorial with shades of the Karate Kid 🤣

Ответить
tld8102
tld8102 - 03.05.2023 07:30

is there a sunrise and sunset time condition in home assistant?

Ответить
cor
cor - 30.04.2023 10:24

bad, complex tutorial

Ответить
L. Davis
L. Davis - 25.04.2023 18:49

On HA's timer page, it has the following note:

Timers will be restored to their correct state and time on Home Assistant startup and restarts when configured with the restore option.
However, automations using the timer.finished event will not trigger if the timer expires when Home Assistant is not running.

The second sentence caught my attention. Does this suggest that if your timer "would have finished" at the time HA is being restarted (i.e. not running) that any associated actions will never be called?

Ответить
L. Davis
L. Davis - 30.03.2023 19:52

Maybe HA could add a "persistent" tick box to the FOR option and it will allow the FOR timer to persist across a restart, making all this relative automation complexity moot. However this is a great review of how a timer might be used.

Ответить
Edgard Mello
Edgard Mello - 25.03.2023 17:55

Congratulations on making such a great video! It was very informative and helpful. Thank you for sharing your knowledge with us.👏

Ответить
Morrison Reid
Morrison Reid - 18.03.2023 14:58

Ive changed all my motion activated lights to using timers to switch off after x minutes.. Its made a huge difference to my patience. Now the lights stay on in the specific room while motion is being detected. The lights only switch off after x minutes one I have left the room.

Ответить
Sandro Munoz
Sandro Munoz - 16.03.2023 20:54

This is a good intro into using timer helpers. While I would only use this for my more important automations, setting this up on a few lights was really good practice. It would be great to get a more in-depth tutorial on the Choose action. There are a lot of good use cases for Choose, but not many people know about it or what it does. I was super confused by it when I first tried to use it. I think Choose is great for programming buttons on a light switch (I programmed my Philips Hue switches with it).

Ответить
Archie Johnson
Archie Johnson - 24.02.2023 17:22

Good tutorial and this really demonstrate the power of Helpers and fixes the problem you point out with using the "for" option in the automation. I always wondered why one of my lights would stay on after the conditional end time and this explains that. So using this "Helper" timer will allow the light switch to toggle off at the end of the timer, vs remain on because the conditional end happens first. Hope I explained that correct. One question I do have. In your example was there an action to turn on the "studio air freshner" ?
I have an automation which is based on motion being detected from "off to on" and the action is to switch on the light. I've already been using trigger Id's, with choose. So do I have 3 choose options ? 1) Switch turn on; 1) timer turn on and 1) for switch turn off ?

Thank you again for your Layman's terms explaination!

Ответить