Actions between two times

Hi all,
i have a rule that controls lights in my kitchen and dining room, such that after 30 minutes of either of these lights been turned on they will turn off. this is done by setting a delay of 30 minutes and turning them off.

i would like to improve it, as it seems to be a little annoying in practice, so:

  1. i would like the trigger to only fire if it is not the afternoon or evening, say do not trigger if it is after 3pm until 8pm, so the times that the kitchen may have the heaviest usage. at times outside this duration id like the rule to be active.

I see only the option to have "at certain time". is there not a between A and B capability?

Could this be done with local variables?

i am somewhat new to rule machine.

If you post a screenshot of your current rule, that would probably give you the best suggestions. But it sounds like you're asking if a trigger can be restricted to just specific times. That answer is no, but it's (usually--again,, depending on your actions) an easy problem to overcome: any event matching a trigger will, by the definition of Rule Machine triggers, cause the actions to run. But in the actions, you have lots of options to restrict things based on any criteria, not necessarily even one related to the trigger, by way of conditional actions (IFs and whatnot).

Alternatively, if you don't have a reason to use Rule Machine for this, you could consider one of the built-in apps like Motion Lighting or Simple Automation Rules that are designed to handle lighting. With Motion Lighting, you could use the "don't turn off between these times" option and set up the rest of the app however you want. With Simple Automation Rules, you could create two instances, each with "Restrictions" set to run only during specific times, and in the one I'd suggest making for 3-8 PM, you could have it just turn the lights on but not turn off. Or if I'm misunderstanding your goal and you only want the lights to turn on or off after 8 PM, then you'd only need one instance (of either ML or SAR) with options or restrictions set to just the time you want.

1 Like

Do you want the lights to neither turn on nor turn off between 3pm and 8pm?

You could allow the rule to trigger but add something like this as the first action;

If (Time between 3:00 PM and 8:00 PM) Exit Rule

That would keep the rest of the rule from actually running.

Better to use a motion sensor rather than simply timed off otherwise it's going to be quite irritating in practice I think (even with your periodic timing). You can add something like the Sonoff Zigbee 3.0 motion sensor for around 10 bucks and they work really well.

Thank you everyone for the input. I set up a local variable that changed state between set times and then the rule is enabled or disabled based on it. It’s a bit clunky but it works. Drives my son mad. :slight_smile: anyways I think whoever suggested a motion sensor, I think that will be better, may upgrade to use that.
Again that you all for the feedback.