Motion sensor after sunset ONLY

I am new to Hubitat, I cannot figure out how to do an automation, the automation requirements are simple.

I only want the Trisensor motion detection to be active from sunrise to sunset go turn on the shed light.

My setup is I have a Trisensor that detects motion and turns on my shed external lights. It is connected as follows

Trisensor motion -> Alexa -> SonOff light switch.

I hope someone can help

Welcome to HE and to the community!

Can you expand on this a bit? It sounds as if your Sonoff light switch is paired to Alexa rather than to HE? If so is it a zigbee lightswitch or wifi?

1 Like

Yes that is correct the SonOff light switch is WiFi based

There are probably a couple of ways to get this to work, but honestly the easiest way is to use switches that are natively compatible with HE (which are usually not wifi) and use a basic rule or the room lighting app to do it.

If you want to try something to make use of your current Sonoff switch (not really what I recommend) you could:

(1) See if someone has written an interface for this Sonoff switch. If there is an open API someone might have done it. If there is and you can control the Sonoff switch directly from Hubitat something like the basic automation app would work. Your best bet is to search the forums here. I did find a couple of references to switches but not sure if there's actually a working integration.

(2) You could expose your HE motion sensor to Alexa and create a routine using Alexa. I'm not sure Alexa's routines have enough flexibility to do this easily, though. You might have to create a rule on HE that only enabled the motion sensor between sunset and sunrise, and then a corresponding routine on Alexa that used the motion sensor to turn the switch on and off. While this would likely work it would definitely be a chewing gum and duct tape solution and there might be a delay turning on the light. It would also be a pain to troubleshoot.

What kind of trisensor is it?


Thanks very much for your help I will take a look at your suggestions

Like Brad mentioned, welcome aboard.....

Once you get to the next version of your rule / automation, if you still need help, many (like me) find it useful to also see a screenshot of your automation, e.g. a rule in Rule Machine.

1 Like


Step one: create virtual switch

Step two: create rule that turn on virtual switch after sunset via motion sensor attached to hubitat

Step 3: Expose virtual switch to echo integration on hubitat so that alexa sees it

Step 4: create routine on alexa that turns on your sonoff wifi switch when it sees the virtual switch turned on and turns off when the virtual switch is turned off.

Step 5: Drink beer


Thanks very much for your help I will give it a go

I have given it a go, just waiting for dusk, I really understand Drink Beer bit

1 Like

You can test by going to the rule on hubitat and clicking Run Actions (Your after sunset trigger should be on hubitat and not alexa). Doinig the run action bypasses the trigger and makes sure it's running ok. So run action, that should turn on the virtual switch and alexa should do it's thing

1 Like

From what I can find doing a quick perusal of the web, Sonoff provide a documented REST api for local control of some of their devices. Much good information to be found at:


So, while it's a bit of a janky way of doing things, you could just send the appropriate http:// requests directly from Rule Machine. Horribly ugly, but it will get the job done. A vastly better solution would be to craft a switch driver so HE can properly access it, but at the current time I'm not sure I know HE well enough to try doing that.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.