Python sunset timer for Philips Hue

The Philips Hue has a nice API. It took me a few picnics to figure out how it works. So for your convenience I give you a few snippets of Python code.

First you have to figure out what your username is:

With this username you can check lights or turn them on and off:

And now a wrapper function:

The iot class is a homebrew event logger:

You can use crontab to set timers. But why not make it yourself 🙂

You have to put all timers in timers.txt
Yes, I know, it looks a lot like crontab. This one is not better, but I made it myself 🙂

And you need to know when the sun rises and sets. I didn’t write this class myself but I also forgot where I found it. Credits to the anonymous maker!

One Reply to “Python sunset timer for Philips Hue”

Leave a Reply to Braddy Cancel reply

Your email address will not be published. Required fields are marked *