Controlling lights with my raspberry pi

Over the last year, I’ve been toying with ways to have my outdoor lights turn on and off automatically. I tried using my feet (aka, getting up and turning them on/off), but that didn’t work so well (I got lazy a few times). Then I tried using a straight timer. This mostly worked – until we hit daylight savings time, at which point I had completely forgotten how to program the timer, and I would spend a week or 2 avoiding it, hoping it would magically fix itself. Unfortunately, it never did, and I didn’t really enjoy finding the way to fix it twice a year. So, last week, I opted to try the zwave route. I just spent the weekend installing a 3-way zwave lightswitch in my home (yes, it took that long), but once the lightswitch was installed, things got much easier.

The internet being the wonderful tool that it is, I was able to find a way to control my zwave components from my raspberry pi. The post is old – but it was very accurate. Here’s the link

I followed the directions exactly (up to step 10), got it working with my aeon stick, and then decided that I wanted to use the telnet interface to control it. By making this choice, I was then able to write a quick bash script that would allow me to turn it on and off. And then, from there, I can now just add it to my crontab, so I can change the time that it goes on/off from the comfort of my laptop on my couch. Nice. But it doesn’t solve my problem completely (this didn’t solve my issue with daylight savings).

Although, I’ll always remember how to edit a crontab, wouldn’t it be nice if it just fixed itself? There are a couple of ways to solve this, but the best way (to me) seemed to be to have the light turn on a specific time after sunset – so this way it would auto-adjust for daylight savings, and save energy along the way.

I started searching for a way to calculate the time that the sun goes down, and then find a good way to auto-edit my crontab. As I was searching, I began to realize how complicated this solution was, and I began to think that this was WAY too complicated.

So I began searching for a way to just calculate the current sunset time – when I stumbled upon this post. This seems to solve all of my problems (look at example 3) – it’s nice and simple, and it just kind of works.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s