Author Topic: Only run scene if no motion detected for ten minutes  (Read 211 times)

Offline Callero

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
Only run scene if no motion detected for ten minutes
« on: December 04, 2017, 12:06:52 pm »
I have a scene that triggers on light level.
It basically cuts the light after sunrise.

But I don't want it to cut the light if the family is having breakfast, so I would like it not to run unless there has been no motion for ten minutes.

Can someone help point me towards a code example I could build on?

I'm a total Luup newbie, but I am somewhat proficient with JS and Python.

Offline melsman

  • Sr. Newbie
  • *
  • Posts: 35
  • Karma: +2/-0
Re: Only run scene if no motion detected for ten minutes
« Reply #1 on: December 07, 2017, 11:28:38 pm »
I have a similar routine that I run to turn off my garage light after 15 minutes if it sees no motion.  I use the countdown timer app to create a countdown timer (in my case, wittily called, "Garage Light Timer"), that I trigger when the garage light is turned on manually, or by motion sensor. (Using a scene called - again very wittily - "AutoOn Garage Lts").  Basically, I tell the countdown timer to "Restart" each time there is a motion or door sensor trigger, and the timer starts over, counting down to 0. 

However, the magic comes from using a scene called "AutoOff Garage Lts" that is triggered when the countdown timer completes.  Thus, if the timer counts down to zero without getting a motion or sensor trigger (and restarts because of the trigger), it triggers a scene that turns off the light.

Melsman

Online RichardTSchaefer

  • Master Member
  • *******
  • Posts: 9922
  • Karma: +749/-141
    • RTS Services Plugins
Re: Only run scene if no motion detected for ten minutes
« Reply #2 on: December 08, 2017, 12:58:05 am »
If you want to get more serious about automation you might want to look at PLEG.
It's much higher level than LUA ... and all in one spot as opposed to a couple of scenes and a plugin that work together. There are many PLEG examples for this topic out there.

Offline Chrisfraser05

  • Sr. Member
  • ****
  • Posts: 449
  • Karma: +16/-31
Re: Only run scene if no motion detected for ten minutes
« Reply #3 on: December 08, 2017, 01:43:58 am »
Pleg is amazing to be fair

Offline jchin

  • Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
Re: Only run scene if no motion detected for ten minutes
« Reply #4 on: December 30, 2017, 01:22:01 pm »
I have a similar routine that I run to turn off my garage light after 15 minutes if it sees no motion.  I use the countdown timer app to create a countdown timer (in my case, wittily called, "Garage Light Timer"), that I trigger when the garage light is turned on manually, or by motion sensor. (Using a scene called - again very wittily - "AutoOn Garage Lts").  Basically, I tell the countdown timer to "Restart" each time there is a motion or door sensor trigger, and the timer starts over, counting down to 0. 

However, the magic comes from using a scene called "AutoOff Garage Lts" that is triggered when the countdown timer completes.  Thus, if the timer counts down to zero without getting a motion or sensor trigger (and restarts because of the trigger), it triggers a scene that turns off the light.

Melsman


Would you mind sharing the code?


Online RichardTSchaefer

  • Master Member
  • *******
  • Posts: 9922
  • Karma: +749/-141
    • RTS Services Plugins
Re: Only run scene if no motion detected for ten minutes
« Reply #5 on: December 31, 2017, 10:45:58 am »
You can use the Countdown timer and a couple of scenes for EACH door you want this behavior with.

Or you can use a single PLEG to do all of your doors and other activities.
I used Futzle's Countdown Timer and Combination plugins when I first started using Vera.
But I had to create so many Countdown Timer and Combination Plugin devices that I ran out of memory. Her countdown Plugin was the motivation to create PLTS and the Combination plugin motivate PLEG ... each condition in PLEG is like a single Combination plugin device. A single input timer in PLEG is like a single Countdown timer device. Using PLEG can save a lot of memory. A single plugin device in PLEG uses minimally 2 MB of memory.
This was really important on a Vera 3 and Vera Lite. Less important on newer devices with more memory. But there are other benefits to using PLEG as well.