Philips hue lighting system - a JSON device
Mostra commenti meno recenti
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 Commenti
Star Strider
il 14 Gen 2016
I searched for ‘Philips Hue’ on the Arduino and Raspberry Pi sites (that MATLAB supports) and couldn’t find anything there. From what I’ve read about them, they could have the hardware to communicate with the lights. You would have to search them to find out.
Mark Hayworth
il 17 Gen 2016
Modificato: Mark Hayworth
il 17 Gen 2016
Guillaume
il 27 Gen 2016
For your information, JSON has been around for over a decade and is already hugely popular for data serialisation (particularly with javascript). It's certainly much easier to process and less heavy than XML.
Not that it helps with your question.
Star Strider
il 27 Gen 2016
Guillaume — Your Comment quite definitely could help if you could attach or link to any free references, ideally with code examples, on how to interface the requisite javascript functions with core MATLAB. A suite of such functions, if they don’t already exist, would be worthy of an undergraduate or Masters thesis project, uploaded to the File Exchange.
Mark Hayworth
il 27 Gen 2016
Massimo Ciacci
il 1 Lug 2017
Modificato: Massimo Ciacci
il 1 Lug 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
il 1 Lug 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.
Risposta accettata
Più risposte (1)
Image Analyst
il 1 Lug 2017
Modificato: Image Analyst
il 2 Lug 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

Categorie
Scopri di più su Web Services in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!