RM 5.1 Time Between Not Being Respected

Quite possible I'm doing something wrong, but I can't seem to get RM 5.1 to respect "Time Between" conditions in a rule.

I'm just trying to have a rule that flashes my Inovelli Dimmer LED strip red when a contact sensor is showing "open," but only between 7:30pm and 6:00am (i.e., "overnight" times). The screenshot shows the system knows it's not currently between those times (FALSE, as expected; it's just after 2:30pm locally), but the overall condition seems to be evaluating to TRUE.

Is this a bug or user error?

UPDATE: I'm on Platform Version 2.3.1.142, FWIW

Creating a Condition, by itself, doesn't do anything. You have to use that Condition for it to take effect. It could be used in a Conditional Action (e.g., IF-THEN). Or you could create a Required Expression, and use a similar Condition in it, if you don't want the rule to trigger unless it is within the time window.

1 Like

Ah, I think I sorted it out now (will test shortly). Was a bit confused that the place to "create and manage conditions" is within the "Select Actions for..." screen. To me, that implied that the conditions would be respected for that action. I have now created a Conditional Action, using the time condition, and that seems to be what I want:

Yeah, people are confused about this from time to time. Will add an explanation on that page.

5 Likes

I think that explanation is clear enough--would have saved me this post :smile:

I'm OK as of now--gate is open and LEDs are not flashing (as expected, because it's still not 7:30pm local time yet. I'll test to confirm the LEDs flash the way I want after 7:30pm

1 Like

That should work even better than the note I just added to the docs. :smiley:

2 Likes

Hi,
I am trying this Time Between in a simple scenario where I want a dimmer to be at 100% between 7:00 and 1:00 and at 20% between 1:00 and 7:00. I see the expression turn to True, but the action is not executed. When I click the Run actions button, the dimming level does go to the expected level. What am I missing?

I tried with and without the trigger events.

Cheers Rene

Think I found it. There is a Conditional action, and that does work. Tad confusing for a newbie on Hubitat.
Do wonder what the purpose of that expression part is then.

As noted in the docs, a required expression becoming true (or false--usually) does not do anything on its own. At minimum, it affects whether or not an event that matches a trigger actually triggers the rule (there is also a new option that affects what happens with pending actions should it become false before they happen).

A rule without trigger events will never run its actions, unless you manually run them or they are "called" from another rule via the "Run Rule Actions" action.

1 Like

So an expression should be true before the trigger fires. I did have that but still the action would not run. I have it working using a conditional action now, but I'll do some more experimenting with the expressions.

PS: the help link on the RM5.1 app does not bring up the page you referenced so I was looking at limited documentation. Thanks for this one.

The required expression must be true for the rule to subscribe to the trigger event. The trigger has to run after the required expression becomes true for the actions to execute.

As for the rule, I don't think you even need a required expression unless you just want to keep the light levels in separate rules. You could just do:

Trigger: light turns on
Action:
If(time between 7 and 1)
Dim lights to 100%
ELSE
If(time between 1 and 7)
Dim lights to 20%
END IF
END IF

Enable logging and then see what shows up in Logs, which should give clues to why. There are definitely some cases in your rule as written where this wouldn't be the case when a trigger event happens (e.g., the switch turning on wouldn't trigger your rule because you have the switch already being on as part of your required expression).

Or, I suppose, just use your new, working rule and come back to those feature later if you ever need it somewhere else. :slight_smile:

OK, I've tested, and the rule is mostly working with the conditional statement as part of the action statement. However:

  1. if the gate is already open prior to the "start time," the action isn't triggered (LED strip doesn't start flashing red), and
  2. if the gate is open past the "end time" the action isn't stopped (via the startNotification to stop the flashing).

In #1 above, I would expect the LED strip to start flashing red at 7:30pm (or maybe 7:30:15pm if is starts counting the 15 seconds right at 7:30pm). And in #2, I expect the LED to stop flashing red once the clock hits 6:00am.

I'm sure it's "user error" on my part, but I can't figure out how to handle this around the start and end times I've set in the action. Thanks for any help here...

Might someone be able to help with this? Or do I need to start a new thread?

It would probably be best to share a screenshot or text of your current rule so people can give specific suggestions for it.

But in general, a rule will only run the actions when triggered (which is not to say that you can't use delays, waits, etc. in your actions that may create event subscriptions or scheduled jobs, but, for example, a conditional action will not create any of these, and a required expression changing truth will not cause actions to run, either). So, it sounds like you need to use either a trigger or some kind of wait to make what you want happen when you want, or perhaps just another rule triggered based on whatever time/event if you always want it to happen at that time or in response to that event.

Here's the screenshot:

I understand what you're saying in concept, but can't figure out how to implement it. I just would like the rule to (somehow) start flashing the LEDs if the gate is open at 7:30pm (and then stop even if the gate is open at 6:00am).

First, the 'why it's not working' part. Your rule is only triggered when the contact sensor is opened. At that point, the rule will check the time and run the actions if your time constraint is met. It will not run again unless the contact sensor is closed and re-opened (satisfying the trigger). So, if it's already open and never touched, the time doesn't matter.

So, you're use case is:
If the contact is open and it's 7:30 PM, start flashing the lights until either the sensor is closed or it's 6 am.

What if the contact opens at 7:35 PM? Do you still want to do the light flash? What if it's closed and re-opened?

Understood about why it's not working currently, thank you.

Yes.

Flash the lights in both of these cases too.

And, if the gate is open (and the lights are flashing) before 6:00am, stop the flashing at 6:00am.

Essentially, any time the clock is between 7:30pm and 6:00am and the gate is not closed, I want the lights to be flashing. This is a baby gate at the top of steps, and our baby can get out of his bed/room now, so we want to keep him upstairs. My rule currently is good if the gate's state changes during that time window, but not good as clock ticks into and out of the that time window.

That's pretty simple. I'll drop you an updated rule here in a few.

Edit @budmannxx I think this should do the trick

REQUIRED EXPRESSION
Time between 7:30 PM and 6 am

TRIGGERS
Time is 7:30 PM
Gate Contact opens

ACTIONS:
IF(Gate Contact is open) THEN
Flashy lights
Wait for events: time is 6 am OR gate contact is closed
Turn off light flash

1 Like

Wow, thank you so much. Makes sense reading it here. I'll implement and test this weekend.

UPDATE: I think I have it programmed as you noted, here's what it looks like:

I'm a bit nervous about the Trigger Events section, however. It looks like this will trigger at 7:30pm regardless of the gate's state. Do I somehow need to specify "( When time is 7:30 PM AND gate contact is open ) OR ..."?

I'm attempting to test shortly, but may not be able to until later this weekend.

UPDATE2: my nervousness was unfounded. The lights do not start flashing if the gate is closed at the rule start time. They do start flashing if the gate is open at the rule start time, or if the gate opens (and stays open for more than 15 seconds) during the rule time window.

Thanks to @FriedCheese2006 for the ultimate solution here, and @bravenel and @bertabcd1234 for advice and updating the documentation so quickly!

1 Like