Philips hue lighting system - a JSON device
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Mark Hayworth
el 14 de En. de 2016
Editada: Image Analyst
el 2 de Jul. de 2017
My son got a Philips Hue bridge (network device) and some wi-fi bulbs. He wants to have his computer control the light bulbs. Has anyone played around with this Philips "personal wireless lighting system"? There is a Developers site and there are SDKs in a wide variety of languages but sadly none in MATLAB. So I guess one approach is to use the Java SDK and talk to that from MATLAB. I could probably figure it out but I was just hoping that if someone has done it already, I could start with a leg up. I already searched the entire Mathworks website and there is nothing on it (so far).
7 comentarios
Massimo Ciacci
el 1 de Jul. de 2017
Editada: Massimo Ciacci
el 1 de Jul. de 2017
Finding the IP address was not too hard, as follows:
url = 'https://www.meethue.com/api/nupnp';
data = webread(url);
Hue_ID = data.id;
Hue_IP = data.internalipaddress;
url = sprintf('http://%s/api/invalidUserID1234/', Hue_IP)
response = webread(url);
response.error
type: 1
address: '/'
description: 'unauthorized user'
Now I have to figure out how to use POST without using webwrite (I use ML2014b) to send messages to it such as..
body = '{"devicetype":"my_hue_app#_appname"}'
The next step would be to get a valid user name after pairing with the bridge (pressing the button on it), as described in
https://www.developers.meethue.com/documentation/getting-started
Image Analyst
el 1 de Jul. de 2017
Nice trick. I've oncorporated it into my code. But I wonder how meethue.com knows the IP address of my lamp. Does the lamp "phone home" to Philips?
I'll post my code, which does lots of fancy things with the Hue lamp below as an answer sometime today. Will probably upload it to my File Exchange this weekend.
Respuesta aceptada
Stephen Doe
el 19 de En. de 2016
The webwrite function supports GET and POST methods only.
You might try using urlread2 to communicate with the device. It's a user submission that might help you.
6 comentarios
Walter Roberson
el 27 de En. de 2016
On the previous firmware on my Cisco/Linksys it would have been no problem to add a fixed IP address for a MAC address. With the version I seem to have now, I don't see a way to do it.
You can use a tool such as nmap to find out what devices are present on your local network.
If you were using a Unix type system then you would be able to use netstat to read the table of known MAC addresses off of your PC. I think there might be an equivalent for MS Windows, but do not have time to check.
Walter Roberson
el 1 de Jul. de 2017
Looking again on my Linksys router, if I connect to the router's web page from the lan, log in, select "Connectivity", and click on the "Local Network" tab, then there is a DHCP Server section and a DHCP Reservations button there. clicking on that gets me to another page that lists the current reservations and has a "Manually add device reservation" button that can be used to associate an internal IP address with a particular MAC address.
Más respuestas (1)
Image Analyst
el 1 de Jul. de 2017
Editada: Image Analyst
el 2 de Jul. de 2017
Mark, I have a Philips Hue and have made a nice program that will let you send any color to your lamp. Plus it will let you browse to a folder with music files and it will let you change the color of the lamp in time with the music as it plays. I've also measured the spectrum of the lamp with my Ocean Optics spectrometer, and the spectrum of the emitted light is displayed as the light color changes. So the spectrum is accurate.
% Program to manipulate the colors by the Philip Hue wireless LED lighting system.
% Program plays music files and the brightness of the lamp is controlled by the volume of the song.
% Communicate with a Philips Hue bridge to talk to the Hue personal wireless LED lights.
% Ref: http://www.developers.meethue.com/documentation/getting-started
% Make sure you do everything on that page to find out the IP Address of the bridge (something like '192.168.1.120'),
% and to set yourself up as an authorized user (with a string something like 1028d66426293e821ecfd9ef1a0731df that identifies you).
% Uses function urlread2() from the File Exchange. http://www.mathworks.com/matlabcentral/fileexchange/35693-urlread2
% Although the program will work with any music file, these are
% recommended music files to effectively demonstrate the capability of the program and lamp.
% Note: classical music pieces seem best because they vary the volume slowly and have a great dynamic range in volume.
% Fanfare for the Common Man, by Aaron Copland
% Symphony #5 by Beethoven
% Symphony #9 "New World" by Antonin Dvorak (one of the best symphonies ever written)
% O'Fortuna from Carmina Burana by Carl Orff (powerful, spine tingling music I'm sure you've heard before)
% Toccata in D minor by Bach (haunting, creepy funeral dirge organ music)
% Also Sprach Zarathustra by Richard Strauss (2001 a Space Oddysey movie theme)
% The Four Seasons by Vivaldi
% Anvil Chorus by Giuseppe Verdi
% Palladio Allegretto by Karl Jenkins (deBeers "A Diamond is Forever" theme music)
% Note: Some music that you might think would be good, such as Ode To Joy by Beethoven, which have a good beat,
% unfortunately change too rapidly for the lamp to follow. The lamp can only change colors about 10 times a second, but it seems
% even slower than that.
% Some rock songs that play well because of large but slow volume oscillations are
% Good Times Bad Times by Led Zeppelin
% Dazed and Confused by Led Zeppelin
% Stairway to Heaven by Led Zeppelin (actually almost any Led Zeppelin song!)
% We will Rock You by Queen
% Good Riddance (Time of Your Life) by Green Day
% Uprising by Muse
% Viva la Vida by Coldplay
0 comentarios
Ver también
Categorías
Más información sobre JSON Format en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!