Monday 12 May 2014

Ultimate outdoor light (with Arduino)


Coming home to a house with the outdoor lights on is much nicer than coming home to a dark house. With a bit of scripting it was possible to automate the outside lights to follow this logic,

 - if it's 30 minutes after sunset, and at least one person is not home, then turn the lights on.
 - if it's after sunset and everyone is home then turn the lights off.
 - if the lights have been manually turned on, leave them on (i.e. guests are expected).

Sunset & Sunrise times.
An easy way to get sunset/sunrise times is from wundermap. You'll need to register (for free) to get an api key, once done you can get current conditions, forecasts, astronomy info etc. The following will download theastronomy json file for Sydney. Put this in a crontab and download it once a day.
 curl http://api.wunderground.com/api/<your_api_key_here>/astronomy/q/Australia/Sydney.json >astro.json

A simple parser can then pull out the hour and minute for sunset and sunrise.

Presence.
Presence is a common issue in home automation systems, i.e. knowing who is home (or even who is in each room). To deduce who is home I used a simple cheat - ping everyones mobile phone on the wifi and see which respond. If the mobile doesn't respond we'll assume the person is out. Of course this assumes the mobile hasn't just gone flat, been lost or had the wifi turned off. 
 

Thursday 8 May 2014

CBUS programming


Being a little technical I programmed the CBUS system myself. This is when you learn the true age (sorry maturity) of the product. To learn the programming I first made a test bench with some of the units wired to a switch and a motion senor. Whilst the documentation is thorough a test bench was invaluable to learning how to program the units and use some of the logic within the units.
 For example some interesting logic can be applied to link a motion sensor to a light switch. The end result is that the light only turns on when both the light switch is on and the motion sensor detects motions. When the motion detector times out (after a configurable amount of time) the llight switches off, even though the light switch is still on.