More Home Automation – Ikea Tradfri Lights Hack

I started subscribing to MagPi a few months ago – a birthday prezzie from my other half.  This month, there was an article about hacking Ikea lights.  I’ve got quite a few Ikea bulbs round the house as they’re cheap as chips compared to others – especially the GU10 bulbs.  One thing the app lacks is the ability to turn a light on at sunset.  You can do it with an absolute time but not sunset.

So, with the article from MagPi and a bit of Python to get the sunset time for the day, compare it to the current time and switch the light on if it’s later we have success.  There’s a cron job that runs the Python script on the Raspberry Pi every 15 minutes from 15.00 to 22.00.



If you have your sound on, the “Oh” is where I see the cron job fire, immediately followed by the light turning on.

Happy days!