View on GitHub

Hue-emulator

A Bridge API Emulator for the Philips Hue (Personal Wireless System)

Download this project as a .zip file Download this project as a tar.gz file

Hue Emulator.

The Hue Emulator is a hue Bridge API Emulator for the Philips Hue - Personal Wireless System.
It allows developers who don't have access to a Philips Hue system (i.e. A Bridge + Hue Light Bulbs) to write hue apps.

Note It should be noted that this is a Bridge API Emulator, ** it is not a hardware Emulator** so response times (for example the number of light/group commands that can be sent per second) will differ to an actual bridge. For a true test a Hue Bridge should be used.

Note x2 This Emulator is not complete. For example, there are no Sensors, Rules, MultiSource Luminaires and generally has all fields up to a Hue Bridge API 1.3, so some later fields may be missing. If your app focuses on Lights, Groups, Scenes and Schedules (limited) this it should be fine.

How to use

The emulator is written in Java so a Java Runtime environment is required.

The emulator is an executable .jar file, so can either double click or from the command line:-

java -jar HueEmulator-v0.6.jar

Note that if you are running on OS X on Port 80 you may need admin privileges so try:

sudo java -jar HueEmulator-v0.6.jar

Enter the port you want your emulator to run on and click the Start button (this starts the Emulator/HTTP and UPnP Server). It is recommended to use port 80, as using port 80 allows the Emulator to be found by hue apps which use Java SDK. However, if port 80 is blocked or inaccessible pick another port. Note, that the UPNP code is still in Beta and not 100% working (doesn't work with the iOS SDK for example). This will be improved at some point. To check the Emulator is running use the below URL. The full bridge config should be returned, in JSON format:

http://localhost:8000/api/newdeveloper

Or, if you are running on Port 80 then:

http://localhost/api/newdeveloper

The root of the github project contains the HueEmulator-v0.6.jar executable, so building the source is not required.

Note By default the Emulator loads in the username "newdeveloper" for quick use. In the future (Feb 2016) custom whitelist entries will not be allowed in a Hue Bridge, so it will no longer be possible to create the username "newdeveloper". However, I will always keep this in the Emulator for ease of use (as easier to remember than a 32 char random username).

You can use the emulator a variety of ways:

Hue API

The emulator accepts RESTful web service calls (in JSON format) just as the Hue bridge obviously.

For more details on the valid Hue API calls consult the documentation at: http://www.developers.meethue.com/

Java/Android SDK

If you are running the emulator using port 80, the Java SDK should find the emulator using a bridge search. If port 80 is blocked or inaccessible then, using the Java SDK you can connect to the emulator using the following lines of code:

PHAccessPoint lastAccessPoint = new PHAccessPoint();
lastAccessPoint.setIpAddress("192.168.1.1:8000");   // Enter the IP Address and Port your Emulator is running on here.
lastAccessPoint.setUsername("newdeveloper");        // newdeveloper is loaded by the emulator and set on the WhiteList.
phHueSDK.connect(lastAccessPoint);

If you are testing on Android make sure your Android Wifi and your PC are on the same Network/Wifi. Additionally if connection failures occur your firewall settings may need adjusting.

See the code examples on the Philips GitHub page for more info.

Currently Implemented Features

The Emulator currently supports the following:

TO DO

The Emulator is currently in development and will be updated as of when new features are implemented.

The following features may be added soon (roughly in the below order).

Support or Contact

The HueEmulator is currently in alpha. Please report any bugs on GitHub and if you are using the Emulator and require a feature request drop me a line.