Controlling Philips Hue lamps with a Pebble smartwatch

As far as I know, at this moment there is no direct way to control Philips Hue lamps using a Pebble smartwatch. A workaround is possible though, with the help of a webserver that sends the right commands to the Hue bridge as you visit a specific webpage. Here’s how I did it.

Short demonstration on Youtube

What I used:

  • Philips Hue starter pack including Hue bridge (plus several Hue, Living Colors and Living Whites lamps which can be controlled by the bridge)
  • iPhone 4S
  • Pebble smartwatch
  • Smartwatch Pro app for iOS and the included WatchApp to be run on the Pebble
  • PC acting as a webserver (eeepc 4G, an older and relatively cheap netbook) on my local network
  • Debian GNU/Linux with Apache, PHP5, Phue, Composer, php5-curl

The steps as I recall them:

  • Make sure you can control the lamps using the Hue app for the iPhone.
  • Register your own ‘username’ with the Hue bridge as explained in http://developers.meethue.com/gettingstarted.html (Phue includes a tool to do this as well). You can test if you can control the lamps from your web browser using the Clip debugger.
  • Install Debian GNU/Linux on a suitable machine (just about any pc-like system that you can keep running on your network). For installation instructions, see http://www.debian.org/distrib/ At installation, make sure you select the task webserver. A full desktop system is not necessary for this purpose.
  • The Apache webserver and PHP5 should already be installed. If not already done, install package php5-curl (aptitude install php5-curl) as well.
  • Install Composer. At this moment it’s not an included package, so you can use these steps:
apt-get install curl
curl -s https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
  • Make a subdirectory (folder) in /var/www where your webpages will be located.
  • Install Phue by creating a composer.json file in the web folder
{        
"require": { "sqmk/phue": "*" }
}

and then running

composer install
  • create php webpages like the following (call it lamp1.php for example). Make sure you have the right IP address of the Hue bridge and the previously registered username.
<html>
  <head>
    <title>Turn on lamp 1</title>
  </head>
  <body>
     <h1>Lamp 1</h1>

<?php

require_once 'vendor/autoload.php';

$client = new PhueClient('192.168.1.2', 'thisismyhueusername');

try {
    (new PhueCommandPing)->send($client);
} catch (PhueTransportExceptionConnectionException $e) {
    echo 'There was a problem accessing the bridge';
}

// Manually send command to get light by id
$light = $client->sendCommand(
    new PhueCommandGetLightById(1)
);
echo $light->getName(), "n";
$light->setOn(true);
// Setting brightness (0 for no light, 255 for max brightness)
$light->setBrightness(255);
// Set color temp (153 min, 500 max), changes color mode to 'ct'
$light->setColorTemp(400);

?>

  </body>
</html>
  • Open the created webpage from a web browser in your network and see if it works.
  • Install the iOS app Smartwatch Pro, run it and install the watchapp on your Pebble. It doesn’t have to be Smartwatch Pro, but any app that can open a web address by pushing a button on the Pebble.
  • In Smartwatch Pro on the iPhone, enable the HTTP requests option, and add a HTTP request to the webpage you just created.
  • In the Smartwatch watchapp on your Pebble, select the HTTP request and enjoy 🙂

To see what you can do with Phue, check https://github.com/sqmk/Phue and the Hue developers information at http://developers.meethue.com/