Start a new topic

Dusk and Down control


A nice feature would be dusk/down on/off functionality.

Preferably with an configurable offset (with or without randomization).

Would be perfect for all outside illumination

Kind regards

49 people like this idea

This is a good idea. Maybe it works with the Sonoff TH. Sonoff TH comes with an external temperature sensor. But for the sonoff it makes no difference if this is the temperature or the brightness from a light sensor.

4 people like this

After posting i found out there is now limited ifttt support,  just for basic and 4ch devices at the moment and only on your mobile phone approaching home,,  But, looks like the thin end of an interesting wedge ;)

And your right the SC isnt an out door device..

for the time being a weekly updated schedule following the sun is all you can do..  

4 people like this

I had 3 Metal Halide lights on the outside of a building that were tucked so deep under the roof eaves that the dusk to dawn photocells never worked right.  I removed the 3 wire photocells and replaced them with sonoff basic switches.  I sealed the switches from moisture/insects and put them about 6 inches away from the hot lights.  They work great!  Now I really need the dusk to dawn function.  Other apps I use have this feature so I encourage ITEAD to implement it.  The Sonoff Basic makes a nice replacement for a photocontrol but lacks a critical programming method.

4 people like this

One can run a Google Script, that can determine sunrise and sunset times, then send an email. But it's not yet possible to trigger the Sonoff device, but it would be possible if ITEAD intergrated with IFTTT. I hope that functionality will come.

2 people like this

I agree, very useful. There are dusk/dawn timers which are programmed with the time/date and  latitude/longitude and then calculate dusk and dawn. This would be really useful!

2 people like this

I put a standard photocell inline to a Sonoff Basic device (called -Darkness).

When it gets dark, -Darkness turns on. I created a Scene in the eWeLink app to turn on the appropriate lights when -Darkness turns on. 

You just have to position the photocell so it turns -Darkness on at the right time.  

If it gets too cloudy/dark during the day, the lights go on and stay on.

I turn the lights off at a fixed time every night.

I named it -Darkness so it appears at the top of the list.

(60.4 KB)

2 people like this

Glad you mentioned the IFTTT support.  I will experiment with that!

1 person likes this

I think EW has the more elegant solution, mine is to run a scene to switch a sonoff basic on/off dependant on the lighting conditions detected by a SC device on a windowsill.  this powers on/off a 5v psu->sonoff bridge which feeds input for scenes to switch lighting on/off dependent on movement detected by pir devices attached to the bridge which is turned on when dusky/dark .  So when its light out the pirs trigger but the bridge is offline and fails to detect and trigger the scenes that control lighting. but when dark the bridge is powered up and online to respond to the pir triggers/alarm conditions 

the trick is to hide the sc behind a curtain so that internal lights do not trigger a false positive, and only the external light conditions are monitored through the window, also im not lighting up the area outside that window..    


1 person likes this
Any home automation application can be programmed depending on the sunrise / sunset, calculated from the time zone. And you can add + - X minutes. I do not understand what Ewelink expects to improve basic things.

1 person likes this

there is a ldr in the sonoff sc, add one to your home and you can use scenes to switch accordingly

1 person likes this

Yeah, I have looked at the SC but don't know how well it would work for an outdoor light sensor even stuck in a window.  Kinda expensive just for a photo control.  Dusk to dawn timer in the app/cloud would be best and there are tons of uses for a simple digital input.  I don't know why ITEAD doesn't enable that in firmware.

1 person likes this

Well I got set up on IFTTT and started playing with it. Since I am pretty new to the IOT scene I had heard about but not tried IFTTT. I must say, it is very useful. I tested the sunrise/sunset triggers from Weather Underground but didn't like the lack of control so I moved on to the Webhooks and set out to write my own dusk to dawn service. I have a shared web hosting account so I crafted a PHP script to run as a cron job. So far it works great. I thought I would post the script here for anyone interested. It is still pretty raw but appears to be working right.

To use this:

1. You need a host server that supports cron jobs and php. My host is running linux.

2. You need an IFTTT account. (free)

3. You need an ewelink account. (free)

4. Build your applets on IFTTT to trigger on weblinks "dusk" or "dawn".

5. Build your applets on IFTTT to operate your ewelink sonoff switches.

6. Edit this script for your time zone, weblinks key, latitude, and longitude.

7. Copy the script to your server.

8. Set up a cron job to run it every 5 minutes.


With its default settings the script will trigger dusk 12 minutes before civil twilight ends and trigger dawn 12 minutes after civil twilight begins. I find this timing pretty well aligns with when my hardware photo controls turn the lights on and off. The script includes a $skew variable which you can edit to suit your taste. The larger the value of skew, the brighter the sky will be when this triggers.


This script sends the webhook trigger twice at dawn and twice at dusk. The second trigger occurs 10 minutes after the first. This was done as a fail safe measure just in case the first signal was missed by a switch. If the switch is already on or off it makes no difference if it gets another signal for the same state. This behavior can easily be changed with the $repeat variable. Set $repeat = 1 to only send one signal or heck set it to 3 or more if you want more


One more thing... This script may time out on older versions of php on Windows servers. It uses the sleep() function to wait for dawn or dusk and the wait can be up to 5 minutes. Windows had a bug which counted sleep time as execution time. This does not occur on linux based hosts. If you run into this problem you may need to comment out the the sleep() line. The script will still work but the resolution will be 5 minutes instead of 10 seconds.


The script is attached. If you have questions, suggestions, or find bugs, let me know.

(2.89 KB)

1 person likes this
It would also help if Amzon were to incorporate a Dusk setting in Alexa. This would allow you to turn on the Switches via the Routine function. I recognise it is wishful thinking but I have suggested it to Amazon in the feedback option.
@Fil <there is a ldr in the sonoff sc, add one to your home and you can use scenes to switch accordingly>
I have tried it, doesn't work at a scheduled Lamp off time. Because the SC - based scene switches the lamp immediately on again when still dark outside. Would work if a scene had a "once in 18 hours" switch.


o  bom seria  progamar  o  timer  do  sonoff para reconhecer o horario am  pm e montar uma cena a noite 

Login or Signup to post a comment