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
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.
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.
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.
If we had a digital input available on gpio14 a cheap digital light sensor module could be used as a master photocell on Sonoff to control a scene. The modules are 3.3v and sell for about $1.00.
It would be fantastic if this could be added to the stock firmware.
gpio14 high to low turn relay on
gpio14 low to high turn relay off
there is a ldr in the sonoff sc, add one to your home and you can use scenes to switch accordingly
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.
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..
Truth is, I like the internal timers because they will work even when the Internet is down or the local wifi is unavailable. What would be ideal would be dusk to dawn setting that would update the timers daily via the cloud. I have 4 lights on sonoff basics and have been updating them manually about once a month.
I have played with the scene by making one basic a "master" timer then turning the others on/off when it changes state. The idea being to only have to update one unit and have the others follow it. It works but I found it unreliable because these things drop on and off wifi connections.
Glad you mentioned the IFTTT support. I will experiment with that!
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.
I have posted a bit more refined version of my webhooks script on my website if anyone is interested.
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..