Need help re-creating motion lightning app with time period option and "Delay off" in Rule Machine

I have several Motion Lighting App instances which turn on lights based on motion, then turn them off after there has been no motion for x number of minutes ("delay off" period). Motion during the delay off period causes the delay off timer to reset. I also have several different instances with non-overlapping time periods and different delay off periods, for example:

  • Between 8am→9:59pm: turn on bathroom lights on motion, then turn off after 10 minutes of no motion (I will refer to this instance as "day")
  • Between 10pm→7:59am: turn on bathroom lights on motion, then turn off after 2 minutes of no motion (I will refer to this instance as "overnight")

This has been working perfectly for a while, but for the past two months or so (possibly after installing 2.2.8) I've been experiencing a bug with any of my Motion Lighting Apps which have at least two instances with non-overlapping time periods - the existence of another instance of an app which controls the same lights, but with a different time period, causes the delay off period of that other instance to apply to all other instances.

For example, given the two instance examples listed above, the delay off period for day is now actually 2 minutes (the lights turn off after 2 minutes despite being configured for 10 minutes). If I change the overnight instance to 5 minutes, the lights turn off after 5 minutes during the day period. If I remove the overnight instance, then the day instance behaves as expected and turns off after 10 minutes. Once I re-add the overnight instance, the problem returns.

I've tried several troubleshooting steps, none of which have helped:

  • Completely deleted both instances, then re-created both
  • Guessed that maybe the overnight instance crossing from PM to AM might be causing issues, split it into two separate instances of 10pm→11:59pm and 12am→7:59am
  • Took a screen capture video and submitted a ticket with Hubitat support on 8/1. They referred the issue to the engineering team but suggested that I post here for help with alternate ways to create this automation,

So basically, I'm trying to re-create this in Rule Machine. I've got everything working except the "delay off" period:

How could I update this rule to make it so that:

  • The light turns off after x minutes
  • Motion being detected causes the "delay off" timer to reset

A wait for event elapsed time of X minutes will be canceled anytime the rule is triggered.

After the wait for elapsed time turn off light.

If motion goes active before the wait is complete, the rule basically starts over and light will not be turned off..

Interesting. I suspect there may indeed be a bug, and will investigate.

1 Like

Thanks @bravenel! If it helps, the ticket number is 22995 and I'd provided a screen capture video demonstrating the issue, along with a text transcript of the events shown in the video.

@terminal3 Cool, thank you. I will test this in a little bit...

BTW, in Motion Lighting if you used modes instead of times, and have those modes be set according to your time schedule, there is a feature for delay per mode -- and you wouldn't need multiple instances.

Could you show me what these look like, how you have them setup. The main setup page screenshot would be very helpful. Did they each have a time restriction for when they should not turn the lights off?

My solution would be to create two rules as follows:


Bathroom Lights: Motion: On

Trigger:

Bathroom Motion Active

Actions:

 On: Bathroom Lights

Bathroom Lights: Timer: Off

Trigger:

Bathroom Lights turn on

Actions:

If (Time between 8:00 am and 9:59 pm)
    Wait for Condition: Bathroom Motion Inactive AND Bathroom Lights On -> Duration: 00:10:00
If (Time between 10:00 pm and 7:59 am)
    Wait for Condition: Bathroom Motion Inactive AND Bathroom Lights On -> Duration: 00:2:00
Off: Bathroom Lights

Here is an example of a rule with 5.0 that is working for me. It is for two sensors. The lights will have a different delay on inactivity based on day/night. The brightness with which they turn on with activity will also vary based upon day/night.

I had never used Modes, but I tested it out based on your suggestion, as it seemed like the least complex solution to implement, and it's working great. I've set up Basic Rules to change modes automatically based on time-of-day, and then I've updated the Motion and Mode Lighting apps to use the delay per mode feature (and removed the time period restrictions) and everything works as expected now.

Here are screenshots of the main pages of the two examples I'd mentioned:


No, they only had restrictions for when the lights should turn on. There were no other time-based restrictions.

Mode Manager will do this for you, with more options...

Very cool, thank you! I've removed the Basic Rules and set up Mode Manager instead.