SteveyO / Hue-Emulator

A Bridge API Emulator for the Philips Hue (Personal Wireless System)
165 stars 41 forks source link

how to change the state of the light #30

Closed uditaghosh closed 8 years ago

uditaghosh commented 8 years ago

how can we change the state of the lights? when we save the json file the present state is can be deciphered but json file I want to load to change these states can't be done.

SteveyO commented 8 years ago

You can change the state of your lights as you would with a normal bridge, by sending an HTTP Put. This is documented in the developers meethue website at the below URL (registration is required though). http://www.developers.meethue.com/documentation/lights-api#16_set_light_state

I didn't understand your last sentence, maybe providing an example of what you tried would help.

uditaghosh commented 8 years ago

thank you for replying. there is an option under 'file' called 'save config' by which i saved the present configuration, like 2 bulbs on and 1 off with other info, as json file. However when i created another json file with a new configuration, like 1 bulb on and 2 off, and tried to load('Load config'), it is not happenning. can you help?

uditaghosh commented 8 years ago

i figured out the 'Load config' and 'Save config'. however i cant send the HTTP Put. can you please mention the steps or upload a video?

SteveyO commented 8 years ago

Hi,

I suggest you watch some tutorials on sending HTTP requests. There is nothing specific to the emulator here. There are many free HTTP clients out there, so just find one you like. Personally I use the free 'Poster' plugin for Firefox.
So for example to turn off the first light in the emulator (light id 1), you can run the emulator (using the default 8000 port if you like). Open up the Firefox Poster plugin (or other HTTP client). For the URL you can use: http://localhost:8000/api/newdeveloper/lights/1/state (or use 127.0.0.1 if localhost is not configured in your hosts file).

and in the body (or Content to Send) use the JSON: {"on": false} And click the 'PUT' button, and voila!

To change the colour you turn it back on (using "on": true) and send a hue/xy value. eg. {"hue": 40000}

In the URL I sent you before, this details most of the commands you can use. Note however, the Emulator is developed up to 1.3 of the Hue API, so some of the later features won't work (e.g. multi-source luminaires).

Steve

uditaghosh commented 8 years ago

hi, it worked!! thanks a lot!!

SteveyO commented 8 years ago

Great!. I will close the issue in github.