Fun with Hue Part 2

Posted on

So last post on this topic I managed to fit them around my flat. I used lampshade.io to rename the bulbs and play with them. It has some default scenes and whatnot but I wanted more (as always). I did some looking on t’internet, and found phpHue this is quite a simple set of php pages which can control your bulbs. There were alternatives but they seemed very complex and a bit over my head at this point.

Using phpHue I was able to work out what was happening and start to be able to do my own stuff with it. For example I wrote gradual.php

#!/usr/bin/php
<?php

require("hue.php");

        $target = 3;
        $command = array('bri' => 0);
        echo $command[0];
        setLight($target, $command);
usleep (100000);
        do {
        for ($i = 1; $i <= 254; $i = $i + 10) {
                echo $i;
                $command = array('bri' => $i);
                setLight($target, $command);
                usleep(5000);
        }
        } while (true);
?>

This sends to bulb 3 (which is in my case the lounge light) and makes it get bright and dim reasonably quickly. As shown in the youtube vid in my previous post.

The way philips hue works is by sending json commands. Now as I have stated previously I am not a coder, but I am able to understand various bits and pieces and normally can munge stuff around.

Fortunately there is some good instructions on the philips hue developer site here An example of getting the status from one of my bulbs to see whether it is on in the image below

Checking the status of the bulb
Checking the status of the bulb

To do this you need to set up an account on the Hue so that you can access it using this as part of the url. As you can see I have set up an account called newdeveloper. To do this follow the instructions here

Leave a comment