probonopd / ESP8266HueEmulator

Emulate a Philips Hue bridge running on an ESP8266 using the Arduino IDE.
MIT License
411 stars 93 forks source link

Cannot connect to bridge #17

Closed lukecyca closed 7 years ago

lukecyca commented 8 years ago

Great idea and awesome project! I got this compiled and installed on a ESP-07 to try it out.

I used Chroma.app on my laptop, and it can discover the bridge, but cannot connect.

screen shot 2015-12-14 at 7 41 02 pm screen shot 2015-12-14 at 7 41 14 pm

Here is the console output from the ESP chip:

===
980631
requestedUri: /api/api/config
980632
{"name":"hue emulator","swversion":"0.1","mac":"18:FE:34:FE:34:F3","dhcp":true,"ipaddress":"192.168.1.147","netmask":"255.255.255.0","gateway":"192.168.1.1","whitelist":{"api":{"name":"clientname#devicename"}},"swupdate":{"text":"","notify":false,"updatestate":0,"url":""}}
980643
===
980659
requestedUri: /api/e5qGUywTisnjL1XU
Running rgb2hsb
1.: H, S, B
2.: Convert to hue, sat, bri
Running rgb2hsb
1.: H, S, B
2.: Convert to hue, sat, bri
Running rgb2hsb
1.: H, S, B
2.: Convert to hue, sat, bri
Running rgb2hsb
1.: H, S, B
2.: Convert to hue, sat, bri
Running rgb2hsb
1.: H, S, B
2.: Convert to hue, sat, bri
Running rgb2hsb
1.: H, S, B
2.: Convert to hue, sat, bri
Running rgb2hsb
1.: H, S, B
2.: Convert to hue, sat, bri
Running rgb2hsb
1.: H, S, B
2.: Convert to hue, sat, bri
980682
{"groups":{},"scenes":{},"config":{"name":"hue emulator","swversion":"0.1","mac":"18:FE:34:FE:34:F3","dhcp":true,"ipaddress":"192.168.1.147","netmask":"255.255.255.0","gateway":"192.168.1.1","whitelist":{"api":{"name":"clientname#devicename"}},"swupdate":{"text":"","notify":false,"updatestate":0,"url":""}},"lights":{"1":{"type":"Extended color light","name":"Hue LightStrips 1","modelid":"LST001","state":{"on":false,"hue":0.00000,"bri":253.00000,"sat":0.00000,"xy":[0.00000,0.00000],"ct":500,"alert":"none","effect":"none","colormode":"hs","reachable":true}},"2":{"type":"Extended color light","name":"Hue LightStrips 2","modelid":"LST001","state":{"on":false,"hue":0.00000,"bri":253.00000,"sat":0.00000,"xy":[0.00000,0.00000],"ct":500,"alert":"none","effect":"none","colormode":"hs","reachable":true}},"3":{"type":"Extended color light","name":"Hue LightStrips 3","modelid":"LST001","state":{"on":false,"hue":0.00000,"bri":253.00000,"sat":0.00000,"xy":[0.00000,0.00000],"ct":500,"alert":"none","effect":"none","colormode":"hs","reachable":true}},"4":{"type":"Extended color light","name":"Hue LightStrips 4","modelid":"LST001","state":{"on":false,"hue":0.00000,"bri":253.00000,"sat":0.00000,"xy":[0.00000,0.00000],"ct":500,"alert":"none","effect":"none","colormode":"hs","reachable":true}},"5":{"type":"Extended color light","name":"Hue LightStrips 5","modelid":"LST001","state":{"on":false,"hue":0.00000,"bri":253.00000,"sat":0.00000,"xy":[0.00000,0.00000],"ct":500,"alert":"none","effect":"none","colormode":"hs","reachable":true}},"6":{"type":"Extended color light","name":"Hue LightStrips 6","modelid":"LST001","state":{"on":false,"hue":0.00000,"bri":253.00000,"sat":0.00000,"xy":[0.00000,0.00000],"ct":500,"alert":"none","effect":"none","colormode":"hs","reachable":true}},"7":{"type":"Extended color light","name":"Hue LightStrips 7","modelid":"LST001","state":{"on":false,"hue":0.00000,"bri":253.00000,"sat":0.00000,"xy":[0.00000,0.00000],"ct":500,"alert":"none","effect":"none","colormode":"hs","reachable":true}},"8":{"type":"Extend
980867
===
997892
requestedUri: /description.xml
<root><specVersion><major>1</major><minor>0</minor></specVersion><URLBase>http://192.168.1.147:80/</URLBase><device><deviceType>urn:schemas-upnp-org:device:Basic:1</deviceType><friendlyName>Philips hue (192.168.1.147)</friendlyName><manufacturer>Royal Philips Electronics</manufacturer><manufacturerURL>http://www.philips.com</manufacturerURL><modelDescription>Philips hue Personal Wireless Lighting</modelDescription><modelName>Philips hue bridge 2012</modelName><modelNumber>929000226503</modelNumber><modelURL>http://www.meethue.com</modelURL><serialNumber>00178817122c</serialNumber><UDN>uuid:2f402f80-da50-11e1-9b23-00178817122c</UDN><presentationURL>index.html</presentationURL><iconList><icon><mimetype>image/png</mimetype><height>48</height><width>48</width><depth>24</depth><url>hue_logo_0.png</url></icon><icon><mimetype>image/png</mimetype><height>120</height><width>120</width><depth>24</depth><url>hue_logo_3.png</url></icon></iconList></device></root>
I assume this is working since with this, Chroma for Hue finds a Bridge, so does the Hue iOS app. In constrast, without this they say no Bridge found.
997973
===
1003807
requestedUri: /api
CLIENT: 
api
[{"success":{"username": "api"}}]
1003814
===
1004821
requestedUri: /api/api/config
1004822
{"name":"hue emulator","swversion":"0.1","mac":"18:FE:34:FE:34:F3","dhcp":true,"ipaddress":"192.168.1.147","netmask":"255.255.255.0","gateway":"192.168.1.1","whitelist":{"api":{"name":"clientname#devicename"}},"swupdate":{"text":"","notify":false,"updatestate":0,"url":""}}
1004852
===
1004855
requestedUri: /api/api/config
1004856
{"name":"hue emulator","swversion":"0.1","mac":"18:FE:34:FE:34:F3","dhcp":true,"ipaddress":"192.168.1.147","netmask":"255.255.255.0","gateway":"192.168.1.1","whitelist":{"api":{"name":"clientname#devicename"}},"swupdate":{"text":"","notify":false,"updatestate":0,"url":""}}
1004875
===
1004882
requestedUri: /api/api/config
1004883
{"name":"hue emulator","swversion":"0.1","mac":"18:FE:34:FE:34:F3","dhcp":true,"ipaddress":"192.168.1.147","netmask":"255.255.255.0","gateway":"192.168.1.1","whitelist":{"api":{"name":"clientname#devicename"}},"swupdate":{"text":"","notify":false,"updatestate":0,"url":""}}
1004899
===
1004904
requestedUri: /api/api/config
1004905
{"name":"hue emulator","swversion":"0.1","mac":"18:FE:34:FE:34:F3","dhcp":true,"ipaddress":"192.168.1.147","netmask":"255.255.255.0","gateway":"192.168.1.1","whitelist":{"api":{"name":"clientname#devicename"}},"swupdate":{"text":"","notify":false,"updatestate":0,"url":""}}
1004926
===
1004930
requestedUri: /api/api/config
1004931
{"name":"hue emulator","swversion":"0.1","mac":"18:FE:34:FE:34:F3","dhcp":true,"ipaddress":"192.168.1.147","netmask":"255.255.255.0","gateway":"192.168.1.1","whitelist":{"api":{"name":"clientname#devicename"}},"swupdate":{"text":"","notify":false,"updatestate":0,"url":""}}
1004953
===
1004959
requestedUri: /api/api/config
1004960
{"name":"hue emulator","swversion":"0.1","mac":"18:FE:34:FE:34:F3","dhcp":true,"ipaddress":"192.168.1.147","netmask":"255.255.255.0","gateway":"192.168.1.1","whitelist":{"api":{"name":"clientname#devicename"}},"swupdate":{"text":"","notify":false,"updatestate":0,"url":""}}
1004985
===
1004989
requestedUri: /api/e5qGUywTisnjL1XU
Running rgb2hsb
1.: H, S, B
2.: Convert to hue, sat, bri
Running rgb2hsb
1.: H, S, B
2.: Convert to hue, sat, bri
Running rgb2hsb
1.: H, S, B
2.: Convert to hue, sat, bri
Running rgb2hsb
1.: H, S, B
2.: Convert to hue, sat, bri
Running rgb2hsb
1.: H, S, B
2.: Convert to hue, sat, bri
Running rgb2hsb
1.: H, S, B
2.: Convert to hue, sat, bri
Running rgb2hsb
1.: H, S, B
2.: Convert to hue, sat, bri
Running rgb2hsb
1.: H, S, B
2.: Convert to hue, sat, bri
1005023
{"groups":{},"scenes":{},"config":{"name":"hue emulator","swversion":"0.1","mac":"18:FE:34:FE:34:F3","dhcp":true,"ipaddress":"192.168.1.147","netmask":"255.255.255.0","gateway":"192.168.1.1","whitelist":{"api":{"name":"clientname#devicename"}},"swupdate":{"text":"","notify":false,"updatestate":0,"url":""}},"lights":{"1":{"type":"Extended color light","name":"Hue LightStrips 1","modelid":"LST001","state":{"on":false,"hue":0.00000,"bri":253.00000,"sat":0.00000,"xy":[0.00000,0.00000],"ct":500,"alert":"none","effect":"none","colormode":"hs","reachable":true}},"2":{"type":"Extended color light","name":"Hue LightStrips 2","modelid":"LST001","state":{"on":false,"hue":0.00000,"bri":253.00000,"sat":0.00000,"xy":[0.00000,0.00000],"ct":500,"alert":"none","effect":"none","colormode":"hs","reachable":true}},"3":{"type":"Extended color light","name":"Hue LightStrips 3","modelid":"LST001","state":{"on":false,"hue":0.00000,"bri":253.00000,"sat":0.00000,"xy":[0.00000,0.00000],"ct":500,"alert":"none","effect":"none","colormode":"hs","reachable":true}},"4":{"type":"Extended color light","name":"Hue LightStrips 4","modelid":"LST001","state":{"on":false,"hue":0.00000,"bri":253.00000,"sat":0.00000,"xy":[0.00000,0.00000],"ct":500,"alert":"none","effect":"none","colormode":"hs","reachable":true}},"5":{"type":"Extended color light","name":"Hue LightStrips 5","modelid":"LST001","state":{"on":false,"hue":0.00000,"bri":253.00000,"sat":0.00000,"xy":[0.00000,0.00000],"ct":500,"alert":"none","effect":"none","colormode":"hs","reachable":true}},"6":{"type":"Extended color light","name":"Hue LightStrips 6","modelid":"LST001","state":{"on":false,"hue":0.00000,"bri":253.00000,"sat":0.00000,"xy":[0.00000,0.00000],"ct":500,"alert":"none","effect":"none","colormode":"hs","reachable":true}},"7":{"type":"Extended color light","name":"Hue LightStrips 7","modelid":"LST001","state":{"on":false,"hue":0.00000,"bri":253.00000,"sat":0.00000,"xy":[0.00000,0.00000],"ct":500,"alert":"none","effect":"none","colormode":"hs","reachable":true}},"8":{"type":"Extend
1005210
===
probonopd commented 8 years ago

Just for comparison, try the official Hue iOS or Android app. This software is a proof-of-concept and far from real-world usability at this point.

Also try https://github.com/sticilface/Esp8266-Hue which is another version originally based on ESP8266HueEmulator but tremendously changed.

MusicLeecher commented 8 years ago

If I recall correctly, I had a similar issue and using the official hue app first and then the chroma app solved the connectivity issue! But later I started using the version mentioned above.. I believe I got similar results but I can't be precise because I've done it a while ago and in both cases did my on small changes to the codes

probonopd commented 7 years ago

@opticron can you have a look at this? I also cannot connect anymore, neither with the "old" iOS Hue app nor with the "new" iOS Hue app. The bridge is not found.

===
263293
requestedUri: /api/nouser/config
263294
{"name":"hue emulator","swversion":"001","portalservices":false,"linkbutton":false,"mac":"18:FE:xx:xx:xx:xx","dhcp":true,"ipaddress":"192.168.0.xx","netmask":"255.255.255.0","gateway":"192.168.0.1","whitelist":{"":{"name":"clientname#devicename"}},"swupda
263310
===

Note that the string ends with "swupda like it doesn't fit into some buffer...!

opticron commented 7 years ago

So that's a dead giveaway that the aJson buffer length either hasn't been modified or wasn't modified to be long enough. The response there is exactly 256 bytes which I assume is the default buffer length. There are a few comments in the code that say to tweak the internal aJson buffer length to 2048 or 4096 with the result really depending how my lights you need to expose. 2048 can expose 6-8 lights and 4096 can expose up to 14 lights (there's a bit of overhead to be accounted for). I guess those comments need to be a tad more prominent.

probonopd commented 7 years ago

So true @opticron. I guess that happens when you work on some code and then don't touch it in a year. Will update the documentation to make it more prominent. Thanks!

Can connect to the bridge now using the "old" iOS app as of 4a6897f6c2e18373079e2e40615e8d5e6370ad17.