Restrictions on rule trigger/execution?

I'm looking to find out how to add a restriction to a Rule, so that it only executes during a certain time of day. IF x THEN y but only between specific time period.

I've not quite been able to figure that out via triggers, and don't see restrictions that I similarly see in the Simple Automation Rules.

Am I overlooking something?

You can't do it with a trigger: any trigger that matches will cause your actions to run. What you want to do is use conditional actions (IFs) to effectively restrict when your actions run.

The rule would end up looking something like this:

Trigger events: whatever you want (e.g., motion changed)

Actions to run:

IF (Time is between X and Y) THEN
  Action 1
  Action 2
END-IF

While a built-in "Restrictions" section comes with many stock (and custom) apps, you won't find that in the current version of Rule Machine because you're capable of doing all that and a lot more with your actions. If you're not sure how to do the above with your rule, providing a screenshot or description may help someone give more specific advice.

Good luck!

1 Like

I kept playing with it and ultimately couldn't get it on the first go around. So I removed the entire rule I was working with and started a anew.

This time, it appeared there were additional options to complete the sequence -- almost like I broke the original scenario.

I think I figured it out though, and temporarily created one using a time trigger to 'check'.

Basically, Every 1m check if it's daylight hours and if an outdoor light is on. If true? turn it off.

What I came up with: Imgur: The magic of the Internet

1m may be too frequent, but I like some self-correcting rules as some folks in the household still can't remember which switch belongs to what even when only two switches are side by side thus turning flood lights, sconces and such on in the middle of the day. My OCD triggers when I come home to that lol.

I do appreciate the response!

Edit: just figured out the Off event was created in the wrong order in the example above. Needed to be created after the conditional! I'm learning though!

Yeah, your edit is correct--the IF THEN as the last line in your actions will have no effect. :slight_smile: Also, while there's nothing that would technically make it not work, it's generally recommended not to use recurring time-based triggers when another event would make more sense--otherwise, you're waking the rule up all the time for what is likely no reason, and you'd do better just to respond to the occasional event where things might actually matter.

I'm still not sure what you're actually trying to accomplish. If you want to turn off the bulb automatically after a minute but only between certain times, something like this might work better:

Trigger: Bulb 1 turns on

Actions:

Cancel Delayed Actions
IF (Time between X and Y) THEN
  Delay 0:01:00 (cancelable)
  Off: Bulb 1
END-IF

Here, the rule only triggers when the bulb turns on. If it's between whatever time, it schedules an "Off" after 1 minute. The two cancellation-related features I used work together to ensure that if the bulb is turned (off and then) on again during that 1-minute countdown that the timer gets "reset" (or more accurately that the originally scheduled "off" gets cancelled and a new one will be set if the conditions are still met).

Try setting up night mode, then If night mode is off, and light is on, turn it off.