Jump to content
View in the app

A better way to browse. Learn more.

Universal Devices Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to not run program (wait) if it has already run in the last X minutes?

Featured Replies

Hello,

To simplify, I have a motion sensor.  I have a program set to turn a scene on when motion is detected.  The issue is that if I am in the building and manually turn the scene off then the motion turns it right back on.  How can I set the program to only run if it has not already been run in the last say 5 minutes?  So basically something like "If this program has not been run in last 5 minutes AND motion is detected THEN turn SCENE to on".

Thanks so much,

-David

Edited by zxplod

You can have the program run another program that disables it, waits 5 minutes, then enables it.

ie

Program 1

IF
   whatever you want
Then
   Run program 2 "then" section



Program 2
If
   blank
Then
   Disable program 1
   all the stuff you want
   wait 5 minutes
   Enable program 1

EDIT: Also, set program 2 run at startup.  Just in case there is a power failure in the middle of the wait, when power comes back on, program 2 will run so that program 1 isn't left disabled.  (a blank "if" section will always run "then" at startup if set to run at startup).

Edited by apostolakisl

The other thing you could do is create a countdown variable.

Create an integer variable, we'll call it iDisableMotion.  Leave the Init value of iDisableMotion as 0 so if the ISY is rebooted motion detection will be enabled by default.

Program 1

If
      Motion is detected
  and iDisableMotion is 0
Then
      Run Program 2 Then Section
      Turn Scene On


Program 2

If
      blank
Then
      Set iDisableMotion = 1
      Wait 5 Minutes
      Set iDisableMotion = 0

 

Edited by kclenden

2 hours ago, paulbates said:

If you are on V5 of firmware, there is the "From last run time" construct under Schedule. You can manage to the last time the program ran

image.png.0044aa35e8aa02ce0a1af4ec0ecc92ef.png

Paul

I haven't played with this feature, but I don't think this would work.  Since the motion sensor would be a trigger and keep pushing back the last run time preventing the program from ever running true until there was no motion for 5 continuous minutes, which I don't think is desired here.  He wants it to wait 5 minutes from the last time it ran "True", not just the last time it ran at all.

Edited by apostolakisl

17 hours ago, zxplod said:

<snipped>

The issue is that if I am in the building and manually turn the scene off then the motion turns it right back on.

<snipped>

 

7 hours ago, apostolakisl said:

I haven't played with this feature, but I don't think this would work.  Since the motion sensor would be a trigger and keep pushing back the last run time preventing the program from ever running true until there was no motion for 5 continuous minutes, which I don't think is desired here.  He wants it to wait 5 minutes from the last time it ran "True", not just the last time it ran at all.

I don't think this is quite right yet.
The OP seems to want to block MS On operations, after an "Off", from other  manual devices, not the MS.
IOW: Block MS action for five minutes after being turned off manually by any device but not the MS. 

The lock-out algorithm needs to be based on a device (not MS), ANDed with their Off signals, and should not include the MS in the conditions..

As an expansion of Apostolakisl's program algorithm...

Trigger On
IF
   control MS is switched On

Then
   set Light-scene On
   Wait 20 minutes
   set Light-scene Off

Else
   ----



Trigger Off
If
   control ManualControl1 is switched Off
  OR
   control ManualControl2 is switched Off
  OR
   control ManualControl3 is switched Off
  OR
   ........ more?

Then
   Disable program "Trigger On'
   set  Light-scene Off
   wait 5 minutes
   Enable program "Trigger Off"

Else
    ---

This is a very common problem with MSes not placed outside of the view of the manual override device. I just let my LED lightbulbs cycle On/Off from MSes during the day etc.. Basically I use home automation on and off and hardly ever turn things off manually.

Yeah, the middle of the night times require 10% on levels, and 30 second timers. :) During the day LED energy required has changed the needs to very low priority.

  • Author

Hi everyone!  Thanks so much for the great replies!  I will try programing some of these solutions.  The first seems pretty iron clad but I may also try upgrading to 5x as well just to play with the new "last runtime" parameter.  That is an exciting addition!  I'm also curious if that will create an endless cycle or not.

P.S. I use MobiLinc to turn the scene off.  Basically, I have the motion set up to turn the scene on when I enter the room.  But when I'm leaving I will turn everything off by turning the scenes off in mobilinc but then the motion turns it right back on.  It is a little more complex because I have quite a few motions, devices, and scenes but that is the summed up issue. 

All my best,

-David 

Edited by zxplod

5 minutes ago, zxplod said:

Hi everyone!  Thanks so much for the great replies!  I will try programing some of these solutions.  The first seems pretty iron clad but I may also try upgrading to 5x as well just to play with the new "last runtime" parameter.  That is an exciting addition!  I'm also curious if that will create an endless cycle or not.

P.S. I use MobiLinc to turn the scene off.  Basically, I have the motion set up to turn the scene on when I enter the room.  But when I'm leaving I will turn everything off by turning the scenes off in mobilinc but then the motion turns it right back on.  It is a little more complex because I have quite a few motions, devices, and scenes but that is the summed up issue. 

All my best,

-David 

If you are using mobilinc to shut if off, you could execute program 2 from mobile linc rather the scene directly.   

  • Author

That is another good idea that I had not thought of!  It is at a business and some people don't have the mobilinc program.  So I also have a switch installed so they can just push the button and it turns everything off.  But...  it is within pickup distance of the motion.  So as soon as they push the button then it turns off but then the motion turns it right back on haha.  It feels like there would be some more obvious solution like the "wait" command so I thought I was missing something.  There should be a simple "Do not run if ran in the last X minutes" command" or something.  The idea to have it run a second program and disable the first program then reenable it after 5 minutes essentially accomplishes this.  I'm very curious about the "From last run time" though as it seems that would be the intention of this new feature. 

Thanks again!

-David

Edited by zxplod

3 minutes ago, zxplod said:

That is another good idea that I had not thought of!  It is at a business and some people don't have the mobilinc program.  So I also have a switch installed so they can just push the button and it turns everything off.  But...  it is within pickup distance of the motion.  So as soon as they push the button then it turns off.  It feels like there would be some more obvious solution like the "wait" command so I thought I was missing something.  There should be a simple "Do not run if ran in the last X minutes" command" or something.  The idea to have it run a second program and disable the first program then reenable it after 5 minutes essentially accomplishes this.  I'm very curious about the "From last run time" though as it seems that would be the intention of this new feature. 

Thanks again!

-David

I don't think the new feature is intended to be used to not run the same program that it is contained within.

  • Author

Hey guys!  I remotely configured this so can't test it yet but I updated to the beta and I think **HOPE** that this works!  :)

Disable Motion Screenshot.PNG

  • Author

Yeah... the new "Last Run Time" totally didn't work...

All my hallways have motion sensors and the lights are controlled such that:

·        Switch on the lights when motion is detected and the area is dark (variable "Min_luminance_percent").

·        Switch off the lights when no more motion is detected and the lights were on long enough. The duration is variable “Motion_light_number_of_5s_intervals_on” times five seconds.

·        Force the lights on with the wall switches - motion is ignored.

·        Force the lights off with the wall switches and ignore motion for some duration. The duration is variable “Motion_light_number_of_5s_intervals_off” times five seconds.

Note the state "force off" in the attached FA diagram. I think you're trying to implement a similar use case. Let me know if you're interested and I will post the ISY programs that implement this state machine diagram. You should be able to modify the programs to suit your needs.

MotionLightFA.png

1 hour ago, jfailenschmid said:

Let me know if you're interested and I will post the ISY programs that implement this state machine diagram. You should be able to modify the programs to suit your needs.

MotionLightFA.png

Nice state diagram!  Having been playing around with a motion sensor for the last couple of weeks, I'd love to see your programs.

Here are the programs for the "Ohana hallway":

Ohana_hallway_lights_timed_on

If

        (

             // state: lights off or lights on timed

             $sOhana_hall_lights is 0

          Or $sOhana_hall_lights is 1

        )

    And 'Ohana hallway / Ohana Hallway multi-sensor / Ohana hallway.Motion' is switched On

    And 'Ohana hallway / Ohana Hallway multi-sensor / Ohana hallway.multi-sensor' Luminance < '$Min_luminance_percent %'

Then

        // state: lights on timed

        $sOhana_hall_lights  = 1

        // starts / restarts the lights on timer program

        Run Program 'Ohana_hallway_lights_on_timer' (If)

Else

   - No Actions - (To add one, press 'Action')

 

Enters the "lights on timed" state and (re-)starts the timer program.

While motion is detected, the lights stay on for the programmed duration by

restarting the timer program.

This particular motion sensor is configured with a PIR period of 15 seconds.

The sensor does not send "motion on" events repeatedly. A "no motion" event

is sent only after no motion is detected for at least the configured PIR period.

Ohana_hallway_lights_on_timer

If

        // state: lights on timed

        $sOhana_hall_lights is 1

Then

        // state: lights on timed

        Set 'Ohana hallway / Ohana hallway lights' On

        // program ends if state is not "lights on timed".

        $Motion_ohana_hall_interval_count  = $Motion_light_number_of_5s_intervals_on

        Repeat While $Motion_ohana_hall_interval_count > 0

           Wait  5 seconds

           $Motion_ohana_hall_interval_count -= 1

        // state: lights off

        Repeat While $sOhana_hall_lights is 1

           Set 'Ohana hallway / Ohana hallway lights' Off

           $sOhana_hall_lights  = 0

Else

   - No Actions - (To add one, press 'Action')

 

Turns on the lights and keeps them on for some time.

Then turns the lights off.

The program stops if the state is no longer "lights on timed".

Ohana_hallway_lights_force_on

If

        // state: lights off OR lights on timed OR force off

        (

             $sOhana_hall_lights is 0

          Or $sOhana_hall_lights is 1

          Or $sOhana_hall_lights is -1

        )

    And (

             'Ohana hallway / Ohana hallway lights' is switched On

          Or 'Ohana hallway / Dimmer at dining doorway' is switched On

        )

Then

        // state: force on

        // Stops WAIT of timer programs

        $sOhana_hall_lights  = 2

Else

   - No Actions - (To add one, press 'Action')

 

When one of the light switches is switched on, enters "force on" state.

Switching the state stops any running timer programs.

Ohana_hallway_lights_force_off

If

        // state: lights on timed OR force on

        (

             $sOhana_hall_lights is 1

          Or $sOhana_hall_lights is 2

        )

    And (

             'Ohana hallway / Ohana hallway lights' is switched Off

          Or 'Ohana hallway / Dimmer at dining doorway' is switched Off

        )

Then

        // state: force off

        // Stops WAIT of timer programs

        $sOhana_hall_lights  = -1

        Run Program 'Ohana_hallway_lights_forced_off_timer' (If)

Else

   - No Actions - (To add one, press 'Action')

 

When one of the light switches is switched off, (re-)starts the "force off" timer program.

Ohana_hallway_lights_forced_off_timer

If

        // state: force off

        $sOhana_hall_lights is -1

Then

        // program ends if state is not "forced off"

        $Motion_ohana_hall_interval_count  = $Motion_light_number_of_5s_intervals_off

        Repeat While $Motion_ohana_hall_interval_count > 0

           Wait  5 seconds

           $Motion_ohana_hall_interval_count -= 1

        // state: lights off

        Repeat 1 times

           $sOhana_hall_lights  = 0

Else

   - No Actions - (To add one, press 'Action')

 

Waits for some time before lights can be turned on by motion.

The timer stops when the state changes to any state but "force off".

3 hours ago, jfailenschmid said:

Here are the programs for the "Ohana hallway":

Thanks.  Between the state diagram and the program comments your programs are really easy to follow.

  • Author

Hi @jfailenschmid!  Thanks for the great info.  Just curious... what kind of motion devices are you using? 

Thanks,

-David

14 hours ago, jfailenschmid said:

You're welcome.

I see you are using the "send on lockout" feature in the MSes. In the older MS versions (I have 12) I find the "on-send lock-out time" does not use the settings I inject via the admin console options. Can you verify actual functionality on this parameter? Mine seem to only default to about 2 minutes.

They work as they should. Also, all sensors are powered by a central power supply with step-down converters at each sensor. No batteries here. 

Guest
This topic is now closed to further replies.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.