It has been about 5 months since I last wrote about setting up open-zwave / z-wave controller on my Raspberry Pi and I have been extremely pleased with the reliability.

I used a simple cron job to turn the lights on at a set time every night and I have had to adjust it a few times to deal with the sun setting earlier. The updates every week kills my “set it and forget it” approach. Time to play with the sunset/sunrise features built into PHP.

My plan is to have a z-wave cron job run the php script during possible sunset and sunrise times and if the time is right the signal will be sent to open-zwave and the lights will come on or go off. I can hopefully add some randomness into the mix so it doesn’t look like I just have it on a timer.

PHP Sunset via date_sunset

Getting the sunset time is easy enough with the date_sunset function.

$sunset=date_sunset(time(), SUNFUNCS_RET_TIMESTAMP, 35.1775, -37.5039,90.8333);
//make sure to use the correct lat/long for your location

However, I did notice that in the latest version (or at least the latest version on the Pi), daylight savings time is not accounted for in the calculation. Rather than do the proper research, I added:

Followed the same steps for the sunrise and then modified my cron job and z-wave turn on/off script which I will post in the next few days. I plan to use the same system for my Christmas lights – which I am thinking about enabling some kind of web feedback.

Leave a Reply