Currenttime in a conditional

I have a rule that uses 'Trigger Event' to turn a light on at either
sunset - 60 minutes of at 5:45 PM.

I want to invoke this rule from another rule. This is simple, however,
when running a rule from another rule, it only activates the rule
actions; it does not take the trigger events into consideration. I
understand this an use it frequently.

The issue is that in the rule I want to use to manage the light
under the same conditions, i.e. ss-60 or 5:445 PM, the conditional
does not provide a mechanism for this.

When I create a Conditional Action in the new rule and get to the 'Select
capability for Action Condition', there is no way to choose a time
value, only 'Between two times'.

I see no reason not to be able to have the conditional express
'if currenttime >= ss - 60 or currenttime >= 5:45 pm' turn on the
light.

This is indeed possible! Your example is really looking for one of two things, which you can achieve by combining these two individual conditions into an expression using an "OR":

Time between Sunset-60 and midnight, Time between 5:45 PM and midnight

(Note that this hub is using 24-hour time, and it sounds like you aren't, but selecting equivalent values like 12:00 AM should do the same.)

1 Like

Thanks. That certainly works but appears to be a bit of a kludge. The Hubitat code should support direct time based conditionals.

I think youre missing time of day, it’s further down the list

Do note that this will only catch those two particular, exact times, which, I suppose if the rule is just "triggered" (actions run from the other rule, really) at either particular time is a slightly fragile/awkward way of getting the same result, but it should work! My expression was written from more of a "purist" perspective to capture the actual desired condition. :slight_smile:

My understanding is that this was necessary since the other rule was indiscriminately running the actions -- but, of course, another way around this is to control when that rule runs them in the first place. Seeing the actual rules is usually suggested when asking for help for reasons like this, since there are so many ways you can get to the same outcome.

But hopefully one of these helps!

This what I see when I generate a conditional…