Trigger only between sunset and sunrise

I have a RM rule to turn on my porch lights at sunset at 50% brightness and then to wait until sunrise to turn them off. This appears to be working.

I have another RM rule for a motion sensor. It is set for sunrise to sunset, when motion detected, turn brightness to 100%, wait 3 minutes, set brightness to 50%. At least that's the intent. The light comes on at 100% whenever the motion is detected. Here's the rule:

Have I done that correctly?

Your description says "sunrise to sunset" but the screenshot shows 'sunset to sunrise'.

That looks like it should work to me, unless you meant to reverse sunrise and sunset as described (and suggested above). Have you noticed any problems?

That being said, it's more likely that you want to trigger on motion active, turn on the light, then wait for motion to become inactive before starting your countdown and the eventual dim. That way, if motion is continually active, the light will remain fully on. That is an easy adjustment:

Dim: Porch Light: 100
Wait for expression: Front door motion inactive --> duration: 0:03:00
Dim: Porch Light: 50

You can, of course, adjust that duration as needed (maybe less if 3 minutes was enough before, depending on how long your sensor reports "active" for). Make sure to use "duration," not "timeout," and if you're on an older hub version, this action may be called "Wait for conditions" or "Wait for rule" instead.

1 Like

Sorry, I did reverse them in my description. I want the motion to be detected between sunset and sunrise.

That looks like it should work to me, unless you meant to reverse sunrise and sunset as described (and suggested above). Have you noticed any problems?

Thanks, I edited the rule with the Wait as you specified.

But the rule triggers any time motion is detected and not just between sunset and sunrise. "Porch light" is a Kasa dimmer switch with the user provided "Kasa Integration" app, so that may be an issue. But I'm thinking the RM logic should honor the sunset / sunrise timing regardless.

It shouldn't--it should work as you describe. The driver also shouldn't be an issue, as this is handled at the app (Rule, here) level. I'd suggest turning on at least trigger and action logging for this rule to see what's going on when, and also look at any other apps that use this device to make sure something else couldn't be doing it.

Hmm ... light didn't turn on at sunset. I'm thinking it might be the Kasa integration as my regular Zigbee devices are working well. I reverted to my Alexa routine for this and will get a compatible switch that doesn't require a user integration.

Oh, yeah, if the light didn't turn on, that could be a device or driver issue. The Rule logs will at least show you what actions the Rule is running and when, so that could help you eliminate the app/rule as a possible cause. Of course, if you're happy with the Alexa alternative, that works too. :slight_smile:

There was a similar thread not too long back that Bruce helped with, I'll see if I can track it down....

I couldn't find it, but from memory if was to do with sunrise or sunset + a value, where they are changed when sunrise or sunset occurs... But I could be wrong about that. Looking at your last screenshot, it looks like you removed that from the predicate anyway. If you have something that works and you are happy to use, probably worth just running with that for now.

I'm going to try a regular, Zwave supported dimmer switch that should arrive tomorrow. I want to move away from Alexa routines if at all possible; they are slow to react, and I like the idea of rules being local and immune from Internet outages.

2 Likes

Rebooted my hub because I still had a "register hub" message and it is registered. Then I noticed the Rule for sunset to sunrise now honors the time - at least it tells me the equation is false in the rule listing unlike before. So I have high hopes for this after sunset tonight.

rule-expression-false

And it looks like the reboot of the hub worked. The motion sensor is only firing between sunset and sunrise and it's working well. Response time is much faster with Hubitat local control than my old Alexa routine.

1 Like