I have an automation that turns my driveway lights on when motion is detected. It normally works fairly well but it was windy last night and that caused the automation to trip endlessly as my trees and bushes were whipping around. Lights would come on, shut off 10 minutes later, then turn right back on again. It basically did this all night until I disabled the automation.

I’ll do some fine tuning of the motion sensors which will help and I’m considering adding a condition to the automation where it won’t trip if the wind speed is above a certain level but how can I add some kind of cool down timer to the automation to prevent it from endlessly engaging?

  • 👍Maximum Derek👍
    link
    fedilink
    English
    10
    edit-2
    6 months ago

    There may be a more straight forward way to do it now, but the traditional way is to add a condition to the automation based on the automation’s (or maybe the light or motion detector) last_triggered property. You need, AFAIK, to use a template for this.

    A condition with something like this should make it so it can’t fire more than once every hour (60 seconds times 60 minutes): {{ (as_timestamp(now()) - as_timestamp(state_attr('automation.driveway','last_triggered'))) > 60 * 60 }}

  • @champagne_laugh@lemmy.world
    link
    fedilink
    English
    66 months ago

    I’m using the timer helper for this sort of thing. You can have a condition in your automation for not triggering if the cool down timer is active.

    • BuelldozerOPA
      link
      English
      26 months ago

      I didn’t know that the timer helper existed, I’ll check that out!

    • BuelldozerOPA
      link
      English
      16 months ago

      That’s a good suggestion, I’ll have to think on that one.

  • @thisNotMyName@lemmy.world
    link
    fedilink
    English
    56 months ago

    A quick and dirty solution would be using a date input helper, that get’s updated with every run and is used in a condition. But there is probably a smarter way

  • @Confuserated@lemmy.world
    link
    fedilink
    English
    46 months ago

    To me this automation seems much better suited to using the Node-RED addon. There is a built in “delay” node that can be used for rate limiting. You would set the delay node to once per hour and put it between the node watching your motion sensor, and the node flipping the light switch. Easy stuff. You could do the same with one or two more nodes to get and check the current wind speed and put that inline as well.

    Keep in mind though, any kind of rate limiting/cool down makes it more likely that the lights won’t turn on when you actually want them to. For example, if you leave the house and come back after the lights have turned off, but before the cool down period expires you won’t have lights.

    • BuelldozerOPA
      link
      English
      36 months ago

      To me this automation seems much better suited to using the Node-RED addon.

      Node Red is a decent suggestion but I’m not currently using it and I’d prefer not to add it just to handle this one thing. Someone else suggested some logic to handle the cool down and I can put the wind speed directly into the automation as a condition.

      Keep in mind though, any kind of rate limiting/cool down makes it more likely that the lights won’t turn on when you actually want them to.

      Yeah, that’s an issue. I’m thinking that instead of a cool down it would be a better solution to either install a motion sensor into a position where it can’t see the shrubbery whipping around in the wind OR to create a separate automation for nights with High Wind that just pins the lights on at 50%.

  • LifeBandit666
    link
    fedilink
    English
    16 months ago

    Add a door sensor to your setup? Have it trip, the lights then wait for the door to open and close before it trips again.

    I mean let’s face it, if someone keeps coming into your garden and doesn’t knock on your doorz at nightz you don’t want them to be able to see where they’re going.

    Just a thought.

    • BuelldozerOPA
      link
      English
      26 months ago

      That’s a fair idea and I’ll consider it!