Use Timers to build Reliable Automations in Home Assistant

Поділитися
Вставка
  • Опубліковано 25 жов 2022
  • If you want to build reliable automations, and especially for critical automations, you should use a timer instead of the for Attribute.
    And in this video I am going to tell you why as well as show you how to use them in place of that For Attribute,
    Who am I?
    My Name is Jeff. I am an DIY-er and Automator of boring things. And, of course, a huge Home Assistant fan. Oh, I also live in a house that tweets.
    Follow Me:
    Github - github.com/thejeffreystone
    Twitter - / thejeffreystone / / slackerlabs
    On the Web - slacker-labs.com/
    Discord - / discord
    And if you like this video you could always fuel my automation habit -
    Grab SlackerLabs Merch: slackerlabsmerch.square.site
    One Time Donation:
    Paypal: www.paypal.com/paypalme/Slack...
    Cash App: $slackerlabs
    Buy me a coffee: www.buymeacoffee.com/icE6DeBut
    .
    Or use my Amazon affiliate link which provides a small commission on things you buy without additional cost to you - www.amazon.com/s/ref=as_li_ss...
    Video Gear:
    Canon m50: amzn.to/3ftldPH
    Desk Mic: amzn.to/3wkum40
    Camera Mic: amzn.to/3tXk1cp
    Newer 660: amzn.to/3fwwejd
    Dazzne D50: amzn.to/3oGBK5y
    Audio Interface: amzn.to/3u07chK
    Gimble: amzn.to/3ouKAoe
    Music - Epidemic Sound: www.epidemicsound.com/referra...
    Video Assets - LenoFx: i.refs.cc/CJXU6Da9?smile_ref=e...
  • Наука та технологія

КОМЕНТАРІ • 133

  • @Grovion
    @Grovion Рік тому +30

    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.

    • @SlackerLabs
      @SlackerLabs  Рік тому +6

      That’s a good point. Depending on your automation you would need to include a trigger to stop the timer as well.

    • @digitaldias
      @digitaldias Рік тому +1

      @@SlackerLabs As long as the timer restarts on movement, it will be functionally no different to a "for"

    • @archiemarper
      @archiemarper Рік тому

      Just to ensure I understand this as I think I incorrectly applied this to my situation. So when my motion sensor clears "for" 3 mins, the action I have associated with the switch turning off, will shut off at the 3 min interval. However, this needs to hold that "no motion" state for 3 mins before the switch turn off action is executed. Is that correct ?

    • @blakeseufert7340
      @blakeseufert7340 Рік тому

      What about if other sensors or switches also control the light?

    • @LDavis-ll5yr
      @LDavis-ll5yr Рік тому +2

      @@SlackerLabs On the timer page it seems to indicate that if you start a timer that is already running, the timer is started over. Might be useful for time-out automations.

  • @Rich33527
    @Rich33527 Рік тому +2

    Started using timers in place of wait conditions for a couple months now. Its made my lighting automations much more reliable. Good Vid.

  • @garethwatson874
    @garethwatson874 Рік тому +1

    A very good tutorial. There are many people on UA-cam offering advice on HA but not many of them explaining things as clearly as this.

  • @This-nerd-house
    @This-nerd-house Рік тому +3

    This is a great idea! I’ve used a timer helper for drip irrigation but that’s all I’ve ever used it for. You make a great point about it retaining after restarts, I’m known to randomly restart my server so this would be a great addition!

  • @mincka3947
    @mincka3947 Рік тому

    Thank you for this new video. My previous automation to turn off the lights was based on an ugly time pattern trigger to check if multiple sensors were all off for at least one minute. The usage of the timer is so much cleaner in this case. I just start the timer again each time one of the sensors is activated to keep the light on. Really easy to change the duration and see the current time before the timer end.

  • @Aurleis
    @Aurleis Рік тому +2

    Thank you sooo much! One of my switches is at the farthest point from my server closet and is always losing communication, and that light never turns off. I really appreciate the solid work you do on your videos and think that you should have far more subscribers.

    • @SlackerLabs
      @SlackerLabs  Рік тому +1

      Thanks! I'm trying to get back in the routine of making more regular videos.

  • @TheMoonSeesMe
    @TheMoonSeesMe Рік тому +2

    Oh man I've had many problems with reliability that can be fixed with timers. The main one, is a you said, with turning things off after a certain about of time - my main one being the heated towel rail turning off after being on for 3 hours.
    Huge thanks for putting this out!

  • @EdgardMello
    @EdgardMello Рік тому +1

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

  • @nickrusso86
    @nickrusso86 Рік тому +3

    Thank you for this suggestion. I think it will help my home automations tremendously. One small suggestion is that during certain parts of the video, you click and scroll so fast, that it's difficult to tell what options you are selecting. I'm having to pause and rewind multiple times to try to determine what you are doing. A slight pause between pointing and clicking would be appreciated.

  • @DanGentry
    @DanGentry Рік тому

    Not sure how I missed this video until this weekend. I have integrated timers into my room lighting automations with great success.

  • @TheHoffVlogs
    @TheHoffVlogs Рік тому +1

    Great walk through! I don't know if it was necessary or not but I also added triggers and logic for if I turn the device off early the timer would be canceled.

  • @Dorff_Meister
    @Dorff_Meister Рік тому +1

    For my stair lights, I use Time of Flight sensors on ESPHome devices to trigger them to turn on. They use a timer that then assists with turning off the stair lights. Handy stuff.

  • @PaulSmith-zs5je
    @PaulSmith-zs5je Місяць тому

    Great video. I used this concept to add 2 timers for a garage water pump. I only want the pump to run for 2 minutes when water detected and a second timer that runs for 30mins which doesn't allow the pump to start if it has finished in the past 30 minutes. Loving what I can do with Home Assistant.

  • @uSlackr
    @uSlackr Рік тому

    I just implemented an automation for my office lights that I used "For" in. Changing it now!

  • @SebastianAde
    @SebastianAde Рік тому

    Thank you! As always very helpful 🙂

  • @xbmcnut
    @xbmcnut Рік тому

    Brilliant video, thank you. Needed to add a trigger to to detect my entity was off and the timer was still active with an action that cancels the timer just in case it got turned off before the timer finished. Other than that, your idea allowed me to clean up a lot of code.

  • @BeardedTinker
    @BeardedTinker Рік тому +1

    I'm always saying that timers are wrongly ignored in HA. Great video!!!

  • @MrSupersidewinder
    @MrSupersidewinder Рік тому +1

    Very helpful, Thanks... I had some off events fail after simply editing an automation the other day... This will help, especially for critical items...😁

    • @SlackerLabs
      @SlackerLabs  Рік тому +1

      Yeah, until recently I was only really tinkering late at night when there isn't many automations running. Now I find myself constantly modifying automations and it was getting a bit annoying when things didnt turn off. haha.

  • @dudefromkeene
    @dudefromkeene 8 місяців тому

    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.

  • @jsjiang6120
    @jsjiang6120 4 місяці тому +1

    There's a flaw in timer. In "Timer" document of HA, it clearly points out that "However, automations using the timer.finished event will not trigger if the timer expires when Home Assistant is not running." I guess that's because HA use time stamp, and when the time stamp occurs when HA is rebooting, the event is not triggered.

    • @SlackerLabs
      @SlackerLabs  4 місяці тому

      Yea. That feature doesn’t appear to be working.

  • @joudatfd
    @joudatfd Рік тому +1

    Hi, great video. I'm using nodered for automations and the problem is the same with trigger nodes. I have automation for water pump to run for 10 minutes. i managed to restart nodered several times, while it was pumping, resulting in empty 5m3 water retention tank. I just migrated some of my flows to timers and it works nicely. It would be great, if there was node for timers, so i don't need to listen to events and then filter out timer entity_id

  • @dronenb
    @dronenb Рік тому +1

    Good info, as always.

  • @schrodingersmechanic7622
    @schrodingersmechanic7622 11 місяців тому

    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.

  • @roymorrison1075
    @roymorrison1075 Рік тому +1

    Great video. Only thing I would add to that is, I add the timer to the dash board, so you can see the timer counting down, so at a glance you can see how long it has to go. I have used this for my watering system, so 8 zones. The other bonus of adding it to the dash board, its easy to open it up, change your time value, for your example if you wanted to go to 25min, rather than trying to find it in helpers, if its next to your swith in the dash board, so just a quick open and change the value.

    • @SlackerLabs
      @SlackerLabs  Рік тому +1

      I almost included the lovelace part. In fact had it scripted out, and ended up leaving it off. Since Home Assistant is making the for attribute in the trigger actually better in the next release (by changing when automations are reloaded) I think it might be good to do a video on some better use cases for timers.

  • @wouterdr
    @wouterdr Рік тому +1

    Thank you for the really good tip! This also makes debugging these a lot easier as I can see the state and countdown of the timer. Takes the hastle out of waiting a few minutes and by then forgetting when I should be paying attention.
    Do you also have the problem that changes to the timer are not saved when changing them through the UI?
    Keep these kind of tips and insights coming please!

    • @SlackerLabs
      @SlackerLabs  Рік тому

      Yea. Changing the timer in the UI only changes that one time I think.

  • @kakaoen4
    @kakaoen4 Рік тому

    This helped me solve a huge thing in my home, i have a water leak sensor in the shower and i wanted it to start a timer when it gets wet and not reset the timer each time water was detected and i could not for the life of me figure out how to put up an automation that would work aswell as being reliable.

  • @richardharnwell3331
    @richardharnwell3331 Рік тому +1

    As a massive Karate Kid fan, the wax_on and wax_off trigger id names made me very happy.

  • @TheDiverJim
    @TheDiverJim Рік тому +1

    I think this will really improve and allow more complexity with my shower light automation.

  • @NSHarrison
    @NSHarrison Рік тому +1

    I also like to use the timer helper as a variable for the timer.start piece. It means you don't have to edit the automations if you decided you want to change the timer duration at any point. For example this snippet of code can be used to achieve this.
    service: timer.start
    data:
    duration: |
    00:{{ states('input_number.wardrobe_timer_duration') | int }}:00
    target:
    entity_id: timer.wardrobe_occupancy
    Besides creating an input_number helper you can also add the input_number to the UI for easy editing.
    Cheers

  • @genepitney155
    @genepitney155 2 місяці тому +1

    So cryptic....maybe going back the Hubitat Elevation may be my next move.

  • @d_sellers1
    @d_sellers1 8 місяців тому

    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.

    • @TechTonor
      @TechTonor 5 днів тому

      Can I ask if you made any other progress with this? I'm in the same situation now, and I've found the trigger_id and "choos" logic, which I didn't normally use, as that was handled in Node-RED. Do you have any other tips, I'd find useful in the migration (talking about Node-RED > HA Automations).

    • @TechTonor
      @TechTonor 3 дні тому

      @@d_sellers1 I'll give it a look. I already spotted Choose, which are great! It makes so much more sense. I don't get that I've not noticed that, until the time of my first comment. Thank you for the answer, btw. Have you found other golden things in the automation setup process, while you migrated your things from NR?

  • @LDavis-ll5yr
    @LDavis-ll5yr Рік тому +1

    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.

  • @archiemarper
    @archiemarper Рік тому

    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!

  • @christophersathen9341
    @christophersathen9341 Рік тому +5

    Nice.
    Is there a way to edit Helpers in Yaml? Would love to be able to do a "random" time interval like // minutes: {{ range(15, 90) | random }}.
    And also agree with Daniel R that it makes it quite complicated to make an automation when you have to jump between layout pages and keep track of separate settings that are actually joined in a single automation. Maybee something to wish for in future user interface upgrades.

    • @daveforrester61
      @daveforrester61 Рік тому

      While not a random setting for a helper, I have some automations that send me actionable notifications asking what value I want a particular helper value set to. Handy for changing things on a regular basis. You could probably create an automation that sets the timer helper value to a random time whenever it is triggered.

    • @nnnextra
      @nnnextra 10 місяців тому

      @@daveforrester61 How do you do this exactly with your automations?

  • @markheatherington8367
    @markheatherington8367 10 місяців тому

    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?

    • @SlackerLabs
      @SlackerLabs  10 місяців тому

      Yeah, you could totally do that using the actionable notifications. I haven't set that up so I can give you all the things you need, but I know that is possible.

  • @RNMSC
    @RNMSC Рік тому

    So, my first 'timer' automation was to automate a wax warmer in the living room. For turning it off after it's been on a while.
    I am going to have to look into timers for at least one more automation. I do 3d printing for my own purposes. and while a 3d printer that is not printing, is not drawing a significant amount of power, it is drawing some, and every Watt hour costs money, so looking to reduce that. I've already got automations that trigger events when a print job completes, as well as when the bed is (or should be) cool enough to release the print that just completed. At the moment a third tree of that automation turns off power to the printer once it's been idle for some period after that. One of the things that I was missing was the event id: option. I know you had a video regarding it earlier, but at the time much more of your videos were Yaml based, and I wasn't ready for that. So having an explanation of using that for Choose events works. I'm going to have use the a timer from when the bed is cool enough to release for 20 min to power down, and figure out how to stop and clear (reset?) the timer if I kick off another print job in that time.

    • @RNMSC
      @RNMSC Рік тому

      Part of me would like to be able to have a pool of timers available (perhaps dynamically created, yet persistent across reloads) that an automation could use in place of the 'for ...' or 'Delay' functions, that a programmer can assign an event id, and a timer duration in the automation, so one wouldn't have to have nearly as many helpers to keep track of. In the next few weeks, I expect to have 2 more printers on line, maybe 3?, and I can see having even more. I'd kind of like the ability to create automations for each of them that do as described above, and being able to template and only change the trigger entity names to reflect each printer, and what plug they are attached to, would be nice. Oh well. (I suppose I could dump, duplicate, and modify the yaml... :-) )

  • @StjepanPuljko
    @StjepanPuljko Рік тому +1

    I have 2 triggers in my automation, one which triggers when motion is detected, which waits for sensor to be off for x minutes. Other one checks if there isn't motion for x minutes, and then turn lighst off. That way light will be turned off after x minutes even if server restarts. Not as precise as with timers but enough for me, an easier to setup.

  • @Einstine1984
    @Einstine1984 Рік тому +1

    Listening for the `timer.finished` event is *not* the only way to know when the timer is finished.
    The timer has a state. The state changes from `active` to `idle`.
    I'd argue that if you want to type less, you'd rather use the state change as your trigger.

    • @SlackerLabs
      @SlackerLabs  Рік тому

      As long as you wanted your automation to fire every time a timer was stopped or canceled as well as actually reached the end of the set time then yes that would work. But if you want to trigger when the timer actually finishes the countdown then you will need to listen for the event. But the state change from active to idle could be because of more reasons than the timer reached zero.

  • @SeattleSandro
    @SeattleSandro Рік тому +1

    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).

  • @74357175
    @74357175 Рік тому +2

    Whoa, I didn't realize automation state was not persistent!
    Is it possible to set an alarm (rather than a count down timer)? Something with the semantics of "anacron", to make sure power outages don't skip over alarms by accident

    • @SlackerLabs
      @SlackerLabs  Рік тому

      You could use time as a trigger, but I am not sure on an alarm option, but you could set a an interval. Like trigger an automation if it hasn't triggered in the last 24 hours. And then it could be your backup trigger.

  • @JGNiDK
    @JGNiDK Рік тому

    All the way from Denmark: THANKS!!

  • @chrisrnz
    @chrisrnz Рік тому +2

    I love HA but I think this UI implementation highlights one of the reasons users (new and old) struggle with this sort of thing. Yeah you can give the timer a name and a duration but nowhere in that dialog box is there a single piece of information that explains what those are, let alone what "Restore" means. Yes there is documentation for many things but many users don't ever refer to the docs. Not a good thing but still a fact.
    The HA UX and UI team needs to do more to show time-of-use help and pointers. In this case a mouseover tooltip would be simple to implement and save a lot of confusion.

    • @SlackerLabs
      @SlackerLabs  Рік тому

      I like that. I wonder if anyone put that in the WTH list.

    • @chrisrnz
      @chrisrnz Рік тому

      @@SlackerLabs What is the WTH list?

    • @SlackerLabs
      @SlackerLabs  Рік тому +1

      October is the month of What The Heck so over on the HA forum lots of people are tossing out WTH suggestions for fixes and improvements. And the community votes on it. And then the dev team tries to knock them out. Some will be in the 2022.11 release.

  • @danielorodriguez1689
    @danielorodriguez1689 Рік тому +5

    This idea crossed my mind several times, but all those times I discarded it b edc ause it suffers from the main problem home assistant has: everything is 5 miles away of each other thing, there is no easy way to have an overview and rather than having the automation information in your automation system you have to keep it in your head. Some degree of decoupling is good, but this is ridiculous and inconvenient

    • @Sparky_D
      @Sparky_D Рік тому

      Can you please explain your nonsensical comment?

    • @Tekwyzard
      @Tekwyzard Рік тому +1

      @@Sparky_D It's not nonsensical at all. Because of that very issue I often have multiple tabs open to different facets of HA, like Developer, states; the automation being edited, the script being edited, the template I'm stressing at, etc. Just last night in fact, I had five HA tabs open to one instance of HA just to try and convince a mediaplayer automation to play nicely, so yeah, it was lots of clicking around as it was, and would have been absolute hell without all those five tabs going at once.

    • @Sparky_D
      @Sparky_D Рік тому

      @@Tekwyzard My comment was in relation to the topic that Danielo had raised, just the fact that it is barely readable.

  • @dmiller9786
    @dmiller9786 9 місяців тому

    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.

    • @SlackerLabs
      @SlackerLabs  9 місяців тому +1

      If the timer is started and it’s running it restarts the countdown.

  • @kodeypatterson8973
    @kodeypatterson8973 Рік тому

    Cool video!

  • @dnoha1
    @dnoha1 Рік тому +1

    I like timer to be run in IoT device localy.
    Tasmota have "PulseTime" timer which will turn light off after some time by it self. My task is only to turn it on via HA, hardware switch or any other way. If another turn on impulse comes to this IoT device, then tasmota starts countdown again from start. So, for light timer usecase there is no wories if HA, wifi, or something else goes wrong, device will turn off, after designed time. I believe that ESPHome can achieve similar.
    Not sure about Zigbee devices. They probably thus not have inbuild countdown?

  • @LDavis-ll5yr
    @LDavis-ll5yr Рік тому +1

    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?

    • @SlackerLabs
      @SlackerLabs  Рік тому

      Yes. Previously it was stated that it would work even if it finished during a reset. But then a big was found. Looks like they decided to just make a note and not “fix” it

  • @Scouras691
    @Scouras691 5 місяців тому

    Great Video. Is there a simple way to create a switch with a timer for my gutter ice melt outlet?

    • @SlackerLabs
      @SlackerLabs  5 місяців тому

      That one might be tricky unless you have a way of knowing when the device plugged into the outlet was on. You would need a way for Home Assistant know when it was on so and a way for it to turn it off. Which prolly means a power metering plug or something like that.

  • @EmilePolka
    @EmilePolka Рік тому

    For functions tends to be useless for me, all the waiting is done on actions for me as that thing had delay and wait till states actions,and also that if-then actions is so good its as if im using node red here.

  • @CrankyCoder
    @CrankyCoder Рік тому +1

    How much of this stuff do you back propagate back into your git repo? or are you leaning more towards just the UI?

    • @SlackerLabs
      @SlackerLabs  Рік тому

      All if should go back to my git repo. But I've been bad about updating it lately. I bounce between the UI and writing the YAML myself. For the stuff I am not use to doing like using events I tend to use the UI because I have to write less. But most of my automations live in the automation.yaml file now. This is to make it easier for me to edit on the go if I need to.

  • @vpsrj
    @vpsrj Рік тому +1

    That’s an another great usage of timers but it’s a shame that HA team doesn’t incorporate it inside the automation creating a new persistent timer using the for time of triggers.

    • @SlackerLabs
      @SlackerLabs  Рік тому

      Well with the new release most of the issue goes away. Automations won’t all reload if you change just one. Only the automation you change will reload.

  • @clairerovic
    @clairerovic Рік тому +1

    I find that often with timers I like to have a UI component so it can be dynamically change the delay/timer. As we all know life requirements are always in a state of flux. It does appear that you cannot easily change the timer duration and it show up in the Helper UI - Yes you can change the duration when starting the timer, though this gets lost in a restart.
    All Fun - Enjoy

    • @SlackerLabs
      @SlackerLabs  Рік тому +1

      Yeah. I need to do some more testing to see how hard to push a timer. It would be nice to be able to create them on the fly like you can with scenes or have multiple instances. Having to define each one for each use case before hand seems like its not going to scale well if you want your lights to all have different times outs. Or like me, have different time periods based on whether its day or night.

    • @discodogge
      @discodogge Рік тому +2

      You can use a input_number to define how long the timer should be. And by setting that first before starting the timer you would get a dynamic timer :) and u can customize it from the UI

  • @jumbleblue
    @jumbleblue Рік тому +1

    Very helpful! Not for motion sensor though

  • @igiannakas
    @igiannakas Рік тому +1

    Funnily enough that has been fixed in the latest beta of HA. In the next release reloading automations will only reset the ones they have been modified. The value of this still remains though with regards to reboots etc.

    • @SlackerLabs
      @SlackerLabs  Рік тому +2

      Second time a video of mine has been made somewhat pointless with the next update. haha

  • @SBinVancouver
    @SBinVancouver Рік тому

    My application for timers is to be able to differentiate between an external motion detection (ostensibly a package delivery) triggered by a camera, and our being detected when fetching that package after a door sensor is trigger. So the logic is: "there's motion sensed on the front camera. But was the door opened in the last minute? If not, notify so we know a package has been delivered" Not earthshatteringly complicated.

  • @guylast9516
    @guylast9516 5 місяців тому

    Thanks for the Video. Someone mentioned in the comments the timer.finished does not work as trigger for action and the same was my experience. I had to use Entity > state > from Active to Idle as my trigger. Also for Action I had to use Device > switch device off and well it worked. The setup of timer and starting timer etc all being the same. I am on 2024.1.0

    • @SlackerLabs
      @SlackerLabs  5 місяців тому

      Were you using the platform event with the timer.finsihed? It works fine in my current automations. Your method will work to. But just be aware if you cancel the timer the state will also go from active to idle so your automation will trigger. Shouldn't be an issue unless it's a timer you expect there to be a reason to cancel at some point and you only what your automation to trigger when the timer actually reaches zero. The state just tells you if the timer is running or not. It doesn't indicate why the timer is no longer active. If that context is important you will have to use the event messages.

    • @guylast9516
      @guylast9516 5 місяців тому

      @@SlackerLabs Basically I followed you in the video and it did not work. I noticed the timer started on turning the the 'switch on' but after count went to idle nothing happened. Guess I can no longer find the right Event trigger. The video is old so things might have changed. I only recently got into HA.
      Oh interesting, I see what you mean about the active to idle. So here is a question. which option would you choose in the trigger section if you are setting it up today?
      I am in the process of figuring out the humidity levels in the bathroom and getting my exhaust fan to turn on when it goes up but struggling with weird humidity readings. In the meant time its turned on manually and left on after showers for a while to ensure mold doesn't grow and sometimes on for hours.
      This is what I did for now.
      No presence > Light turn off + start 20 timer.
      Light turned on > timer cancel
      Timer idle/finished + Fan still on > Turn off fan

    • @SlackerLabs
      @SlackerLabs  5 місяців тому

      @guylast9516 I don't think anything has changed. All of my timer based automations using timers are still working.
      Most of mine follow a similar pattern as you have.
      Typically motion sensor trigger light to come on and an action to start a timer.
      Then a trigger for the event platform with the name of the timer entity.
      Like the automations at www.home-assistant.io/integrations/timer/#control-a-timer-from-the-frontend

    • @guylast9516
      @guylast9516 5 місяців тому

      @@SlackerLabs Ok I deleted my comment as it was getting long. So with my testing I found that the issue is the Timer finish trigger in the ADD TRIGGER section. It does not trigger. I had to change it to Entity> state then pick the timer and call service to action
      So basically this works:
      platform: state
      entity_id:
      - timer.test_timer
      from: active
      to: idle
      id: State timer
      choose:
      - conditions:
      - condition: trigger
      id:
      - State timer
      sequence:
      - service: switch.turn_on
      data: {}
      target:
      entity_id: switch.living_2_light_right
      enabled: true
      This does not:
      platform: event
      event_type: Test timer finished
      id: Test Finished
      event_data:
      entity_id: timer.test_timer
      choose:
      - conditions:
      - condition: trigger
      id:
      - Test Finished
      sequence:
      - service: switch.turn_on
      data: {}
      target:
      entity_id: switch.living_2_light_right
      enabled: true

    • @SlackerLabs
      @SlackerLabs  5 місяців тому

      @guylast9516 updating this comment since I misread something. But here is a link to mine that works. github.com/thejeffreystone/homeassistant-config/blob/0b4fc89e94c2fbac71156e8bb6a90809a5e877ab/config/automations.yaml#L590

  • @udaymshankar
    @udaymshankar 6 місяців тому

    Hi.. What is the advantage of using the Timer Helper instead of the Timer Action inside the automation? As in - In the automation Actions, add an action to start the device and then another action to wait for 5 mins and then another action to stop the device?

  • @jamesking890
    @jamesking890 Рік тому +1

    wax on / wax off !! lol. - great info thanks

  • @mkkm945
    @mkkm945 10 місяців тому +1

    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!

  • @fredamn76
    @fredamn76 Рік тому

    Is the restore option new? I used timers before to manage my motion sensor controlled lights . But timers didn't survive reboots. I will now modify my motion controlled light automations. Thanks Jeff.

    • @SlackerLabs
      @SlackerLabs  Рік тому

      Not sure on that. I didn't even bother with timers until recently. But I want to say it was. Timers are one of the newer things in the UI though.

    • @Tekwyzard
      @Tekwyzard Рік тому

      Yeah, the restore option is a very recent addition, I couldn't tell you which version it appeared in though, as I've only just plucked up the courage to update my instance from what it was running in July.

  • @MatthewN8OHU
    @MatthewN8OHU Рік тому +1

    Regarding the timer expiring during restart; according to Smart Home Junkie, who did a similar video on using timers, this is actually bugged and does NOT work. He has not figured out what exactly is going wrong, though.

    • @SlackerLabs
      @SlackerLabs  Рік тому

      Yea. It appears the event never fires. Doesn’t appear to be a known issue though. At least no open issues. So we need to see about getting one submitted.

  • @Sierra-Whisky
    @Sierra-Whisky Рік тому

    It would have been great if there was a Restore checkbox available for the For function. A timer is a nice workaround but it doesn't solve the real problem. Another workaround is to use a template as a trigger. I use this template as a trigger to turn off a specific light after 30 minutes, no matter what: is_state('switch.light', 'on') and (states.switch.light.last_changed < now() - timedelta( minutes = 30 ))

  • @orrd
    @orrd 5 місяців тому

    So, I'm not the only one who was distracted by thinking of that Karate Kid scene every time he says "wax on" or "wax off", right?

  • @ElCidPhysics90
    @ElCidPhysics90 4 місяці тому +1

    Are timers single instance objects behaving like a singleton in programming? Or can you have multiple instances of a timer running at the same time?

    • @SlackerLabs
      @SlackerLabs  4 місяці тому +1

      They are single instances. If you start it again it will just start over.

    • @ElCidPhysics90
      @ElCidPhysics90 4 місяці тому

      @@SlackerLabs thank you so much.

  • @jbooch
    @jbooch 6 місяців тому

    Hello, I need some guidance. I created a Timer Helper to trigger my garage lights to turn off when they were triggered via someone arriving home after hours. The Automation turns the lights on and starts the time, but, the timer end never triggers. It looks like the timer.finished never gets fired by the timer. Could this be caused by the way I set it up?

  • @jasonstation
    @jasonstation Рік тому +1

    Is it possible to launch an Alexa routine through Home Assistant? I've tried allsorts. If not - why not lol.

    • @SlackerLabs
      @SlackerLabs  Рік тому +1

      Yea there is. You need the Alex Amelia player integration from HACS then you can issue commands as if you spoke them as well as kick off routines.

  • @playroy79
    @playroy79 10 днів тому +1

    do a update since home assistant allows making helpers while creating an automation

  • @yeyomuri
    @yeyomuri Місяць тому

    If you have probles with timer.finished, just uncheck restore on timer configuration

  • @tld8102
    @tld8102 Рік тому +1

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

    • @SlackerLabs
      @SlackerLabs  Рік тому +1

      Yes there is. There is actually a couple of ways to use the sun position as conditions. I usually use the state platform with entity sun.sun and check if the value is either above_horizon or below_horizon. But there is sun platform that can be used that allows you to choose before or after either sunrise or sunset.

  • @paulbacon5056
    @paulbacon5056 Рік тому

    Great tutorial with shades of the Karate Kid 🤣

  • @xelemorf
    @xelemorf 7 місяців тому

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

  • @robertperkins4909
    @robertperkins4909 Рік тому +1

    It would be helpful for newbies trying to learn and make useful things if developers like yourself build an automation from the bottom up and not modify an existing one you have that we can't see all the parameters or how you got there. Overall I like your content but this is frustrating - and unfortunately common. What would be a great help would be a link under Show More to download the developer's automation/template/etc. with comments for explanation. Cheers and thanks for your efforts.

    • @SlackerLabs
      @SlackerLabs  Рік тому

      I did upload the automation to my Video Repo (github.com/thejeffreystone/SlackerLabVideoExamples/tree/main/2022-10-AutomatingTimers) if you want to see the annotated YAML version. Just didn't have it ready for the video release.

  • @notureaveragemiss
    @notureaveragemiss 9 місяців тому

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

  • @dustyward6508
    @dustyward6508 7 місяців тому

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

    • @SlackerLabs
      @SlackerLabs  7 місяців тому

      Because the video wasn't about motion sensors.

  • @barygol
    @barygol 5 місяців тому +1

    Is this still needed?

    • @SlackerLabs
      @SlackerLabs  5 місяців тому

      Depends on the use case. I would still use it for critical automations. But the whole "for" attribute stopping when automations reload isn't an issue unless you are editing the automation waiting on the for.

  • @dankay9202
    @dankay9202 3 місяці тому

    Of course, its so simple

  • @URackADisciprine
    @URackADisciprine 11 місяців тому +2

    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.

  • @IamBucketdotcom
    @IamBucketdotcom Рік тому

    I must be doing wrong, because I cannot get this to function properly where the FOR always works, just with caveats
    In my case
    Trigger1: Ring Doorbell detects Motion - TriggerID = FrontDoor_Motion_On
    Option1: When triggered by FrontDoor_Motion_On
    O1Action 1: Start Timer - timer.front_door_motion_timer
    O1Action 2: light.turnon - Front Door - White
    THAT PART WORKS
    What doesn’t work is:
    Trigger2: ID FrontDoor_Motion_Off
    Event: timer.finished
    Event data: entity id: timer.front_door_motion_timer
    Option 2:
    When triggered by FrontDoor_Motion_Off
    Action: light.turnon - Front Door - Blue
    The timer works, it counts down in Lovelace, but timer.finished does not trigger the turn light blue action

    • @IamBucketdotcom
      @IamBucketdotcom Рік тому

      I made an exact replica of your automation, using a wax warmer on a zigbee switch.... Timer and turn on triggers, but after timer finishes nothing happens
      You say TIMER.FINISH in your video, but type TIMER.FINISHED I am using TIMER.FINISHED.... is this the issue? I have poured through HA docs as well and cannot get this to function....
      Going back to using FOR

  • @cor7797
    @cor7797 Рік тому +1

    bad, complex tutorial

    • @SlackerLabs
      @SlackerLabs  Рік тому +2

      Thanks for the feedback! It will help me avoid making bad, complex tutorials in the future.

  • @SnowyPe
    @SnowyPe Рік тому

    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.

  • @poolace
    @poolace 4 місяці тому

    what wax warmer do you use and how do you have it connected (smart plug, etc)?

    • @SlackerLabs
      @SlackerLabs  4 місяці тому

      I have used quite a few. But they are all connected to a smart plug. Thirdreality Smart plugs, innr Plugs, or minoston zwave. Usually what I had on hand.