Help with Rule Machine

Hey, I would like to schedule an zigbee outlet to turn on for 3 hours. and then stay off for another 3 hours and repeat that process nonstop

If you dont need a specific time or anything else for it to interact with then something like this

Replace SJ Outlet1 with your switch.


hey thanks appreciate the reply when you apply the delayed action. are you applying it when turning off the outlet?

Yeah, that's what it does. The two actions run right after each other, but the second one delays what it's going to do for 3 hours.

Here's another way, that is started by whatever trigger you want, or just by Run Actions:

1 Like

Yes, just like that. And enable all logging for a bit to so you can verify its working as expected later by checking the Logs page / Past logs.

@bravenel way looks like a cleaner solution

I apologize, but am I skipping a step or something? because the rule is not running. am I supposed to put a trigger?


Anatomy of a Rule

Rules consist of up to three parts:

  • Required expression: (optional, disabled by default) When specified, the rule will not trigger (see below) unless the required expression is true.
  • Trigger events: When a trigger event happens, the "Actions to Run" will begin executing.
  • Actions to run: A list of actions to run when the rule is triggered — for example, turning on lights, changing a mode, or running just about any command on any device. There are also ways to use conditionals ("if then/else"), delays, repeats, and other features in actions, as described below.

Hey, thanks for the reply I would like to know what trigger can I use to run this rule? The reason why I'm asking is because this is a non-stop rule. I don't want it to stop I want it to keep going which is turn ON for three hours and then turn OFF for another. three hours. and continue going 24/7 So My question is, what trigger can I use?

Look at the example by @kampto

1 Like

I apologize. I don't understand I don't wanna put this on a timing schedule and I cannot recreate @kampto triggers it has a timing schedule for 0:00. without no PM or AM. Every time I try to apply zeros, it puts it to 12:00PM

If you use the Repeat action noted above and you don't care what exact time it runs then you can just put anytime for the trigger. You just need something to get it started in the repeat loop.
You can even use a trigger when the hub boots up to start there and run the Repeat action loop forever.

1 Like

I tried this and is still not running

Assuming that you have installed this rule, just hit Run Actions.

1 Like

I know you said that you want the rule to run forever but what if you want it to stop, say to service the pump. You'd need to go into the rule an stop it. I would just make a virtual switch and use that to trigger the rule. You could also put it on the dashboard for easy access.

Trigger Events
VirtualSwitch *changed

Actions to Run
Stop repeating actions
IF (VirtualSwitch on) THEN
    Repeat every 3:00:00 (stoppable)
        Toggle: Pump
    Off: Pump
1 Like

@bravenel yes i did I tried with two different outlets one from China/Amazon and one from Ikea And then I tried with a Philips hue light

Turn on all of the logging in the rule, and then post a screenshot of the logs.

this worked how can i add the ELSE Is it necessary If it's working?

Off: Pump

You used a Simple Conditional action. That doesn't have an ELSE. You would have to replace your current IF with the IF-THEN form of Conditional Action, then it will offer the ELSE and END-IF.

Got it working one more question. Let say if i have to restart my hub or a power outage. Would the virtual switch still stayed on if was previously on?