probonopd / ESP8266HueEmulator

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

Logitech Harmony Hub unable to control HUE. #105

Closed gibman closed 6 years ago

gibman commented 6 years ago

hi.

I have the logitech hub running f/w 4.14.123. Currently using the logitech harmony android app to control the ESP hue emulator. The logitech software is able to find and pair with the hue just fine. But when I try and control it afterwards either turning in on/off or trying to dim +/- I get the same result. Nothing happens. Logitech says not connected in the UI.

I can control the hue from any number of android apps. including the official one. Something in the protocol / comm. exchange apparently pisses off the logitech firmware.

I haven't looked at any logs from the ESP yet. I could try and enable debug and capture some of it.

Otherwise it's time to capture the traffic using wireshark on a PC. In order to capture all traffic I guess I have to install something like virtual router on a wifi enabled laptop. https://archive.codeplex.com/?p=virtualrouter

then have both the ESP and the logitech hub/smartphone connect to the virtual router on the PC.

edit: added logs from the ESP. ESP has ip: 192.168.1.74 Smartphone ip: 192.168.1.127

.......Starting HTTP at 192.168.1.74:80 Starting SSDP... SSDP UUID: 38323636-4558-4dda-9188-a020a621c3b0 SSDP Started FS Starting initializeGroupSlots() Sending Notify to 239.255.255.250:1900 initializeSceneSlots() 18:58:38 05/02/2018 Found unknown header 'HOST' Value for unkown header: 239.255.255.250:1900 MAN: "ssdp:discover" REJECT: urn:dial-multiscreen-org:service:dial:1 Sending Response to 192.168.1.51:37506 Found unknown header 'HOST' Value for unkown header: 239.255.255.250:1900 MAN: "ssdp:discover" REJECT: urn:dial-multiscreen-org:service:dial:1 Sending Response to 192.168.1.51:37506 Found unknown header 'HOST' Value for unkown header: 239.255.255.250:1900 MAN: "ssdp:discover" REJECT: urn:dial-multiscreen-org:service:dial:1 Sending Response to 192.168.1.51:37506 REJECT: upnp:rootdevice MAN: "ssdp:discover" Found unknown header 'User-Agent' Value for unkown header: UPnP/1.0 DLNADOC/1.50 Kodi Found unknown header 'Connection' Value for unkown header: close Found unknown header 'Host' Value for unkown header: 239.255.255.250:1900 Sending Response to 192.168.1.115:3195 Found unknown header 'HOST' Value for unkown header: 239.255.255.250:1900 MAN: "ssdp:discover" REJECT: urn:dial-multiscreen-org:service:dial:1 Sending Response to 192.168.1.51:42362 Found unknown header 'HOST' Value for unkown header: 239.255.255.250:1900 MAN: "ssdp:discover" REJECT: urn:dial-multiscreen-org:service:dial:1 Sending Response to 192.168.1.51:42362 Found unknown header 'HOST' Value for unkown header: 239.255.255.250:1900 MAN: "ssdp:discover" REJECT: urn:dial-multiscreen-org:service:dial:1 Sending Response to 192.168.1.51:42362 Found unknown header 'HOST' Value for unkown header: 239.255.255.250:1900 MAN: "ssdp:discover" REJECT: urn:dial-multiscreen-org:service:dial:1 Sending Response to 192.168.1.51:45397 Found unknown header 'HOST' Value for unkown header: 239.255.255.250:1900 MAN: "ssdp:discover" REJECT: urn:dial-multiscreen-org:service:dial:1 Sending Response to 192.168.1.51:45397 Found unknown header 'SERVER' Value for unkown header: JRiver DLNA Found unknown header 'HOST' Value for unkown header: 239.255.255.250:1900 MAN: "ssdp:discover" REJECT: urn:schemas-upnp-org:device:MediaRenderer:1 Found unknown header 'Date' Value for unkown header: Mon, 5 Feb 2018 18:59:10 GMT Sending Response to 192.168.1.127:52100 <?xml version="1.0" ?><root xmlns="urn:schemas-upnp-org:device-1-0"><specVersion><major>1</major><minor>0</minor></specVersion><URLBase>http://192.168.1.74:80/</URLBase><device><deviceType>urn:schemas-upnp-org:device:Basic:1</deviceType><friendlyName>Philips hue (192.168.1.74)</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>a020a621c3b0</serialNumber><UDN>uuid:2f402f80-da50-11e1-9b23-a020a621c3b0</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> Found unknown header 'SERVER' Value for unkown header: JRiver DLNA Found unknown header 'HOST' Value for unkown header: 239.255.255.250:1900 MAN: "ssdp:discover" REJECT: urn:schemas-upnp-org:device:MediaServer:1 Found unknown header 'Date' Value for unkown header: Mon, 5 Feb 2018 18:59:10 GMT Sending Response to 192.168.1.127:52100 <?xml version="1.0" ?><root xmlns="urn:schemas-upnp-org:device-1-0"><specVersion><major>1</major><minor>0</minor></specVersion><URLBase>http://192.168.1.74:80/</URLBase><device><deviceType>urn:schemas-upnp-org:device:Basic:1</deviceType><friendlyName>Philips hue (192.168.1.74)</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>a020a621c3b0</serialNumber><UDN>uuid:2f402f80-da50-11e1-9b23-a020a621c3b0</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> Found unknown header 'HOST' Value for unkown header: 239.255.255.250:1900 MAN: "ssdp:discover" REJECT: urn:dial-multiscreen-org:service:dial:1 Sending Response to 192.168.1.51:36785 45996 [{"success":{"username":"api"}}] Found unknown header 'HOST' Value for unkown header: 239.255.255.250:1900 MAN: "ssdp:discover" REJECT: urn:dial-multiscreen-org:service:dial:1 46147 {"1":{"type":"Extended color light","manufacturername":"OpenSource","swversion":"0.1","name":"Hue LightStrips 1","uniqueid":"A0:20:A6:21:C3:B0-1","modelid":"LST001","state":{"on":false,"bri":0,"xy":[0.00000,0.00000],"colormode":"hs","effect":"none","ct":500,"hue":0,"sat":0,"alert":"none","reachable":true}},"2":{"type":"Extended color light","manufacturername":"OpenSource","swversion":"0.1","name":"Hue LightStrips 2","uniqueid":"A0:20:A6:21:C3:B0-2","modelid":"LST001","state":{"on":false,"bri":0,"xy":[0.00000,0.00000],"colormode":"hs","effect":"none","ct":500,"hue":0,"sat":0,"alert":"none","reachable":true}}} Sending Response to 192.168.1.51:36785 Found unknown header 'HOST' Value for unkown header: 239.255.255.250:1900 MAN: "ssdp:discover" REJECT: urn:dial-multiscreen-org:service:dial:1 Sending Response to 192.168.1.51:36785 Found unknown header 'HOST' Value for unkown header: 239.255.255.250:1900 Found unknown header 'USER-AGENT' Value for unkown header: UPnP/1.0 DLNADOC/1.50 Platinum/1.0.4.2 MAN: "ssdp:discover" 46456 {} 46595 {} 47077 {"1":{"type":"Extended color light","manufacturername":"OpenSource","swversion":"0.1","name":"Hue LightStrips 1","uniqueid":"A0:20:A6:21:C3:B0-1","modelid":"LST001","state":{"on":false,"bri":0,"xy":[0.00000,0.00000],"colormode":"hs","effect":"none","ct":500,"hue":0,"sat":0,"alert":"none","reachable":true}},"2":{"type":"Extended color light","manufacturername":"OpenSource","swversion":"0.1","name":"Hue LightStrips 2","uniqueid":"A0:20:A6:21:C3:B0-2","modelid":"LST001","state":{"on":false,"bri":0,"xy":[0.00000,0.00000],"colormode":"hs","effect":"none","ct":500,"hue":0,"sat":0,"alert":"none","reachable":true}}} Sending Response to 192.168.1.127:62538 Found unknown header 'HOST' Value for unkown header: 239.255.255.250:1900 MAN: "ssdp:discover" REJECT: urn:dial-multiscreen-org:service:dial:1 Sending Response to 192.168.1.51:43975 Found unknown header 'HOST' Value for unkown header: 239.255.255.250:1900 MAN: "ssdp:discover" REJECT: urn:dial-multiscreen-org:service:dial:1 Sending Response to 192.168.1.51:43975 Found unknown header 'HOST' Value for unkown header: 239.255.255.250:1900 MAN: "ssdp:discover" REJECT: urn:dial-multiscreen-org:service:dial:1 Sending Response to 192.168.1.51:43975 58497 {"1":{"type":"Extended color light","manufacturername":"OpenSource","swversion":"0.1","name":"Hue LightStrips 1","uniqueid":"A0:20:A6:21:C3:B0-1","modelid":"LST001","state":{"on":false,"bri":0,"xy":[0.00000,0.00000],"colormode":"hs","effect":"none","ct":500,"hue":0,"sat":0,"alert":"none","reachable":true}},"2":{"type":"Extended color light","manufacturername":"OpenSource","swversion":"0.1","name":"Hue LightStrips 2","uniqueid":"A0:20:A6:21:C3:B0-2","modelid":"LST001","state":{"on":false,"bri":0,"xy":[0.00000,0.00000],"colormode":"hs","effect":"none","ct":500,"hue":0,"sat":0,"alert":"none","reachable":true}}} Found unknown header 'HOST' Value for unkown header: 239.255.255.250:1900 MAN: "ssdp:discover" REJECT: urn:dial-multiscreen-org:service:dial:1 Found unknown header 'USER-AGENT' Value for unkown header: Google Chrome/63.0.3239.132 Windows Sending Response to 192.168.1.72:54408 Found unknown header 'HOST' Value for unkown header: 239.255.255.250:1900 MAN: "ssdp:discover" REJECT: urn:dial-multiscreen-org:service:dial:1 Found unknown header 'USER-AGENT' Value for unkown header: Google Chrome/63.0.3239.132 Windows Sending Response to 192.168.1.72:54408 Found unknown header 'HOST' Value for unkown header: 239.255.255.250:1900 MAN: "ssdp:discover" REJECT: urn:dial-multiscreen-org:service:dial:1 Sending Response to 192.168.1.51:48133 Found unknown header 'HOST' Value for unkown header: 239.255.255.250:1900 MAN: "ssdp:discover" REJECT: urn:dial-multiscreen-org:service:dial:1 Sending Response to 192.168.1.51:48133 Found unknown header 'HOST' Value for unkown header: 239.255.255.250:1900 MAN: "ssdp:discover" REJECT: urn:dial-multiscreen-org:service:dial:1 Found unknown header 'USER-AGENT' Value for unkown header: Google Chrome/63.0.3239.132 Windows Sending Response to 192.168.1.72:54408 Found unknown header 'HOST' Value for unkown header: 239.255.255.250:1900 MAN: "ssdp:discover" REJECT: urn:dial-multiscreen-org:service:dial:1 Sending Response to 192.168.1.51:48133 <?xml version="1.0" ?><root xmlns="urn:schemas-upnp-org:device-1-0"><specVersion><major>1</major><minor>0</minor></specVersion><URLBase>http://192.168.1.74:80/</URLBase><device><deviceType>urn:schemas-upnp-org:device:Basic:1</deviceType><friendlyName>Philips hue (192.168.1.74)</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>a020a621c3b0</serialNumber><UDN>uuid:2f402f80-da50-11e1-9b23-a020a621c3b0</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> 68797 {"1":{"type":"Extended color light","manufacturername":"OpenSource","swversion":"0.1","name":"Hue LightStrips 1","uniqueid":"A0:20:A6:21:C3:B0-1","modelid":"LST001","state":{"on":false,"bri":0,"xy":[0.00000,0.00000],"colormode":"hs","effect":"none","ct":500,"hue":0,"sat":0,"alert":"none","reachable":true}},"2":{"type":"Extended color light","manufacturername":"OpenSource","swversion":"0.1","name":"Hue LightStrips 2","uniqueid":"A0:20:A6:21:C3:B0-2","modelid":"LST001","state":{"on":false,"bri":0,"xy":[0.00000,0.00000],"colormode":"hs","effect":"none","ct":500,"hue":0,"sat":0,"alert":"none","reachable":true}}} REJECT: upnp:rootdevice MAN: "ssdp:discover" Found unknown header 'User-Agent' Value for unkown header: UPnP/1.0 DLNADOC/1.50 Kodi Found unknown header 'Connection' Value for unkown header: close Found unknown header 'Host' Value for unkown header: 239.255.255.250:1900 77251 [{"error":{"type":2,"address":"/api/api/lights/1/state","description":"Bad JSON body in request"}}] 77747 [{"error":{"type":2,"address":"/api/api/lights/1/state","description":"Bad JSON body in request"}}] Sending Response to 192.168.1.115:3195 78170 [{"error":{"type":2,"address":"/api/api/lights/1/state","description":"Bad JSON body in request"}}] 81067 [{"error":{"type":2,"address":"/api/api/lights/1/state","description":"Bad JSON body in request"}}] 81497 [{"error":{"type":2,"address":"/api/api/lights/1/state","description":"Bad JSON body in request"}}] 81917 [{"error":{"type":2,"address":"/api/api/lights/1/state","description":"Bad JSON body in request"}}] Found unknown header 'HOST' Value for unkown header: 239.255.255.250:1900 MAN: "ssdp:discover" REJECT: urn:dial-multiscreen-org:service:dial:1 Sending Response to 192.168.1.51:55214 91017 {"1":{"type":"Extended color light","manufacturername":"OpenSource","swversion":"0.1","name":"Hue LightStrips 1","uniqueid":"A0:20:A6:21:C3:B0-1","modelid":"LST001","state":{"on":false,"bri":0,"xy":[0.00000,0.00000],"colormode":"hs","effect":"none","ct":500,"hue":0,"sat":0,"alert":"none","reachable":true}},"2":{"type":"Extended color light","manufacturername":"OpenSource","swversion":"0.1","name":"Hue LightStrips 2","uniqueid":"A0:20:A6:21:C3:B0-2","modelid":"LST001","state":{"on":false,"bri":0,"xy":[0.00000,0.00000],"colormode":"hs","effect":"none","ct":500,"hue":0,"sat":0,"alert":"none","reachable":true}}} Found unknown header 'HOST' Value for unkown header: 239.255.255.250:1900 MAN: "ssdp:discover" REJECT: urn:dial-multiscreen-org:service:dial:1 Sending Response to 192.168.1.51:34664 Found unknown header 'HOST' Value for unkown header: 239.255.255.250:1900 MAN: "ssdp:discover" REJECT: urn:dial-multiscreen-org:service:dial:1 Sending Response to 192.168.1.51:34664 Found unknown header 'HOST' Value for unkown header: 239.255.255.250:1900 MAN: "ssdp:discover" REJECT: urn:dial-multiscreen-org:service:dial:1 Sending Response to 192.168.1.51:34664 Found unknown header 'HOST' Value for unkown header: 239.255.255.250:1900 MAN: "ssdp:discover" REJECT: urn:dial-multiscreen-org:service:dial:1 Found unknown header 'USER-AGENT' Value for unkown header: Google Chrome/63.0.3239.132 Windows Sending Response to 192.168.1.71:58105 Found unknown header 'HOST' Value for unkown header: 239.255.255.250:1900 MAN: "ssdp:discover" REJECT: urn:dial-multiscreen-org:service:dial:1 Found unknown header 'USER-AGENT' Value for unkown header: Google Chrome/63.0.3239.132 Windows Sending Response to 192.168.1.71:58105 Found unknown header 'HOST' Value for unkown header: 239.255.255.250:1900 MAN: "ssdp:discover" REJECT: urn:dial-multiscreen-org:service:dial:1 Found unknown header 'USER-AGENT' Value for unkown header: Google Chrome/63.0.3239.132 Windows Sending Response to 192.168.1.71:58105 101318

yeah, sure enough each time I try to toggle the lights on/off I get this: [{"error":{"type":2,"address":"/api/api/lights/1/state","description":"Bad JSON body in request"}}]

running latest ESP code and ino file without anything changed other than wifi pass and sid.

Ill try and log the erronous response out

gibman commented 6 years ago

Further logging added reveals that the Body content is indeed empty. Thats why JSON parsing fails.

On working hue clients I get stuff like this: { "on": true }

but apparently not on the logitech remote.

case HTTP_POST: case HTTP_PUT: { fails here => aJsonObject parsedRoot = aJson.parse( (char) HTTP->arg("plain").c_str());

gibman commented 6 years ago

loaded fiddler with the capture file from wireshark.

interestingly the body does contain stuff.

in more details:

Request:

PUT /api/api/lights/1/state HTTP/1.1 user-agent: LuaSocket 2.0.2 content-length: 19 content-type: application/json

body: {"on":true,"bri":0}

Response: [{"error":{"type":2,"address":"/api/api/lights/1/state","description":"Bad JSON body in request"}}]

more debugging needed..

gibman commented 6 years ago

found issue.

It seems vers. 2.3 of the ESP8266 lib which I had installed is case sensitive when it comes to reading those header values. Namely the content-length header.

The logitech harmony hub sends the header values as lower cased, which causes the ESP8266WebServer to not be able to pick up these values.

version 2.3 of ESP lib has this in parsing.cpp:
else if (headerName == "Content-Length"){

thus it being case sensitive

then we have the current master branch which have: https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WebServer/src/Parsing.cpp#L172 case insensitive

Ive changed the the ESP lib to 2.4rc2.

fixed it :)

It's still useful info for the WIKI I think. If you dont have the newer one installed its really up to the HUE device (in this case logitech) if it works or not. Some vendors send in lowercase while others dont.

Make sure you do use the ESP lib. of newer date. !! simple as that. I have confirmed 2.4rc2 working.

Another nice tip is. Once you have captured the wireshark logs, you can import those in fiddler for easier viewing.