Previous DelayLight functions from Vera, create in RM

I have created multiple basic rules to complete these tasks, somewhat...But as I am trying to get better with Hubitat and RM, I am looking for some guidance on a more elegant way to perform these two similar but different needs. I used DelayLight for these in my old vera but that plugin is not available on Hubitat. I feel this is some if/then/else statements but I am getting lost. Here's what I am trying to do:

Patio lights

-motion sensor

-Lights on at sunset set to 7% level
-Lights off at 1 am

Conditional Actions:
-Between sunset and 1 am, if motion is detected set level to 100% and delay for 3 min after motion ends. Then do not turn off, but revert back to set level back of 7%.
-Between 1 am and sunrise, if motion is detected set level to 100% and delay off for 3 min after motion ends

White Noise Generator

-On/off switch for noise generator
-Energy reporting outlet for TV

Actions/conditional needs
-11:45 PM turn on noise generator if the TV is not on (energy reporting <=20W) (I cannot use switch status because there are other devices plugged into the outlet
-when the noise generator is on, if the TV is turned on, turn off the noise generator. If the TV is turned off, turn the noise generator back on.
-Turn off the noise generator at 6 AM on the weekdays and 8:30 AM on the weekends

There are likely many ways to do this. My recommendation would be to do these in separate rules.

The action to turn on the lights could be done with Basic Rules, Simple Automation or Rule Machine as a stand-alone rule.

The motion event could be done in Rule Machine:
Create a time variable

Required Expression: Between sunset and sunrise

Trigger: Motion Active

Save the current time in the time variable
Pause the rule that turns off the lights at 1am
Capture devices - for all your patio lights (This captures their current state - dim level, on/off, color, etc.)
Set lights to 100%
Wait for expression: motion stopped -> duration: 3 minutes
If current time > 1am and time variable < 1am, then (This take care of the situation where the motion occurs during the 1am transition)
turn off lights
Restore light state (This restores them to their previous state)
Resume the rule that turns off the light at 1am

Now for:

Rule 1:
Trigger: time is 11:45pm
Wait for energy reporting outlet <= 20w
Turn on noise generator switch

Rule 2:
Trigger: Monday-Friday 6AM or Saturday-Sunday 8:30AM
Rule: Turn off noise generator

Rule 3:
Required Expresion:
Noise Generator switch is on

Energy reporting outlet for TV >20W

Turn off Noise Generator Switch
Wait for event: energy reporting <=20w
Turn on Noise Generator Switch

Looks like you've got some great pointers to get you started. Just wanted to add that for your lights, you could probably just use Basic Rules. There is nothing "basic" about this app, it has become a powerful if/this/then/that app.

If you can break the rule in basic logic "when this happens, do this, then do some other things," then the Basic Rules is the tool for the job.

Rule 1 When sunset, set the light to 7% then wait and when time is 1 AM turn off.
Rule 2 When motion is active set the light to 100% then wait until motion stops and stays inactive for 3 min, then set the light to 7% (with time restriction). Your rule would look like this:

Rule 3 is a repeat of rule 2 but with different restriction.

1 Like

Thank you gentlemen. Those were great pointers and a different approach than I had been trying. Tomorrow, I automate! I’ll report back with my success or failure.


Got this setup and is working. NOW, because I am also an engineer, I have to fix things until they are broken. For the noise gen rule I have a simple RM rule that has a trigger event of weekdays @ 6 AM or Weekends at 7:30 with the action to simply turn off the device. I also have a button remote by the bed to run scenes to turn things off at night.
How would I go about using one of those buttons to simply delay the action event 1 time for an hour. So, Sat I want to sleep in so I push the button friday night or sat morning to delay the off action for an hour? I know the baked in options in RM are pretty powerful, but is this the threshold that would require me to now use conditional statements? I have seen number of examples here that do this but those folks are doing some pretty complex things and it is difficult for me parse if all that is needed for my use. Also, many of the examples were in significantly older versions of RM so some functionality may be present now that wasn't before.

You could create a hub variable to store the time in it. Have a rule that is triggered by the button press which adds an hour to the variable. It should then wait for a specific time to reset it back.

The trigger for the RM rule could be the time in the variable.

Maybe the community app Lights on Motion Plus would be suitable for this task?