probonopd / ESP8266HueEmulator

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

HueEmulator not picked up by Quby (Toon eneco dutch) mabey others ? #76

Open foen opened 7 years ago

foen commented 7 years ago

it dosnt pickup the emulator the problem is the broadcast is not like a real hue this is a sample of how it should be

These are broadcasts, groups of 6 (3 doubles of different UPnP devices), with an interval of approx. 1 minute:

NOTIFY * HTTP/1.1 HOST: 239.255.255.250:1900 CACHE-CONTROL: max-age=100 LOCATION: http://192.168.2.102:80/description.xml SERVER: FreeRTOS/6.0.5, UPnP/1.0, IpBridge/0.1 NTS: ssdp:alive NT: upnp:rootdevice USN: uuid:2f402f80-da50-11e1-9b23-00178818572b::upnp:rootdevice

NOTIFY * HTTP/1.1 HOST: 239.255.255.250:1900 CACHE-CONTROL: max-age=100 LOCATION: http://192.168.2.102:80/description.xml SERVER: FreeRTOS/6.0.5, UPnP/1.0, IpBridge/0.1 NTS: ssdp:alive NT: upnp:rootdevice USN: uuid:2f402f80-da50-11e1-9b23-00178818572b::upnp:rootdevice

NOTIFY * HTTP/1.1 HOST: 239.255.255.250:1900 CACHE-CONTROL: max-age=100 LOCATION: http://192.168.2.102:80/description.xml SERVER: FreeRTOS/6.0.5, UPnP/1.0, IpBridge/0.1 NTS: ssdp:alive NT: uuid:2f402f80-da50-11e1-9b23-00178818572b USN: uuid:2f402f80-da50-11e1-9b23-00178818572b

NOTIFY * HTTP/1.1 HOST: 239.255.255.250:1900 CACHE-CONTROL: max-age=100 LOCATION: http://192.168.2.102:80/description.xml SERVER: FreeRTOS/6.0.5, UPnP/1.0, IpBridge/0.1 NTS: ssdp:alive NT: uuid:2f402f80-da50-11e1-9b23-00178818572b USN: uuid:2f402f80-da50-11e1-9b23-00178818572b

NOTIFY * HTTP/1.1 HOST: 239.255.255.250:1900 CACHE-CONTROL: max-age=100 LOCATION: http://192.168.2.102:80/description.xml SERVER: FreeRTOS/6.0.5, UPnP/1.0, IpBridge/0.1 NTS: ssdp:alive NT: urn:schemas-upnp-org:device:basic:1 USN: uuid:2f402f80-da50-11e1-9b23-00178818572b

NOTIFY * HTTP/1.1 HOST: 239.255.255.250:1900 CACHE-CONTROL: max-age=100 LOCATION: http://192.168.2.102:80/description.xml SERVER: FreeRTOS/6.0.5, UPnP/1.0, IpBridge/0.1 NTS: ssdp:alive NT: urn:schemas-upnp-org:device:basic:1 USN: uuid:2f402f80-da50-11e1-9b23-00178818572b

some more details https://raw.githubusercontent.com/ewjmulder/program-your-home/master/eneco-toon/IDEAS.txt

SanderV4n commented 6 years ago

Hey Foen,

My Toon picks the hueEmulator up just fine, maybe you can test with the latest version?

mariusmotea commented 6 years ago

Hi,

I believe not all Toon devices use upnp discovery of hue bridge. As you can see there is an issue opened also on ha-bridge and for some users is working for others not. I spent hours to solve this issue for an user with Toon without luck. This user also buy an original Hue Bridge to sniff the traffic during pair process and in the end we come to conclusion that is using the cloud service detection (https://www.meethue.com/api/nupnp) Entire chat and sniff informations are here Marius.

foen commented 6 years ago

Back in day this emu only send out one NOTIFY did not test this code anymore i rewrote it for myself and made it output all the NOTIFYs like i posted in the opening post. And that fixed the issue for me make sure its in the same order and all toons pick it up!

kurniawan77 commented 6 years ago

Nope.. not working with my toon here

probonopd commented 6 years ago

@foen thanks for the progress you are making. Please do send GitHub pull requests. Or please upload your rewrite to GitHub, so that we can all learn from it.

Thank you!

https://help.github.com/articles/creating-a-pull-request/

foen commented 6 years ago

include`

include

include

ESP8266WebServer HTTP(80);

char ssid[] = "LinksysC7926"; char password[] = "1EC57AFF";

WiFiUDP UDPTestServer; unsigned int UDPPort = 1900; IPAddress BroadcastIP(239, 255, 255, 250); // where xx is the desired IP Address

static const char* _ssdp_schema_template = "<?xml version=\"1.0\"?>" "<root xmlns=\"urn:schemas-upnp-org:device-1-0\">" "" "1" "0" "" "http://192.168.1.124:80/" // WiFi.localIP(), _port "" //"<pnpx:X_deviceCategory xmlns:pnpx=\"http://schemas.microsoft.com/windows/pnpx/2005/11\">HomeAutomation</pnpx:X_deviceCategory>" //HomeAutomation catogory "urn:schemas-upnp-org:device:rootdevice:1" "Philips hue (192.168.2.124)" "Royal Philips Electronics" "http://www.philips.com" "Philips hue Personal Wireless Lighting" "Philips hue bridge 2012" "929000226503" "http://www.meethue.com" "00178818572b" "uuid:2f402f80-da50-11e1-9b23-00178818572b" "index.html" "" "" "image/png" "48" "48" "24" "hue_logo_0.png" "" "" "image/png" "120" "120" "24" "hue_logo_3.png" "" "" "" "";

void setup() { Serial.begin(115200); delay(200); Serial.println(); UDPTestServer.begin(UDPPort); UDPTestServer.beginMulticast(WiFi.localIP(), BroadcastIP, UDPPort); HTTP.on("/description.xml", HTTP_GET, []() { HTTP.send(200, "application/xml", _ssdp_schema_template); //'http://192.168.1.143/description.xml }); HTTP.begin(); Serial.print("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, password);

}

static const char Msg1 = "NOTIFY HTTP/1.1\r\n" // SSDP_INTERVAL "HOST: 239.255.255.250:1900\r\n" // _modelName, _modelNumber "USN: uuid:%s\r\n" // _uuid "CACHE-CONTROL: max-age=100\r\n" // "NT" or "ST", _deviceType "LOCATION: http://192.168.1.124:80/description.xml\r\n" // WiFi.localIP(), _port, _schemaURL "SERVER: FreeRTOS/6.0.5, UPnP/1.0, IpBridge/0.1\r\n" // WiFi.localIP(), _port, _schemaURL "NTS: ssdp:alive\r\n" // WiFi.localIP(), _port, _schemaURL "NT: upnp:rootdevice\r\n" // WiFi.localIP(), _port, _schemaURL "USN: uuid:2f402f80-da50-11e1-9b23-00178818572b::upnp:rootdevice\r\n" // WiFi.localIP(), _port, _schemaURL "\r\n";

static const char Msg2 = "NOTIFY HTTP/1.1\r\n" // SSDP_INTERVAL "HOST: 239.255.255.250:1900\r\n" // _modelName, _modelNumber "USN: uuid:%s\r\n" // _uuid "CACHE-CONTROL: max-age=100\r\n" // "NT" or "ST", _deviceType "LOCATION: http://192.168.1.124:80/description.xml\r\n" // WiFi.localIP(), _port, _schemaURL "SERVER: FreeRTOS/6.0.5, UPnP/1.0, IpBridge/0.1\r\n" // WiFi.localIP(), _port, _schemaURL "NTS: ssdp:alive\r\n" // WiFi.localIP(), _port, _schemaURL "NT: uuid:2f402f80-da50-11e1-9b23-00178818572b\r\n" // WiFi.localIP(), _port, _schemaURL "USN: uuid:2f402f80-da50-11e1-9b23-00178818572b\r\n" // WiFi.localIP(), _port, _schemaURL "\r\n";

static const char Msg3 = "NOTIFY HTTP/1.1\r\n" // SSDP_INTERVAL "HOST: 239.255.255.250:1900\r\n" // _modelName, _modelNumber "USN: uuid:%s\r\n" // _uuid "CACHE-CONTROL: max-age=100\r\n" // "NT" or "ST", _deviceType "LOCATION: http://192.168.1.124:80/description.xml\r\n" // WiFi.localIP(), _port, _schemaURL "SERVER: FreeRTOS/6.0.5, UPnP/1.0, IpBridge/0.1\r\n" // WiFi.localIP(), _port, _schemaURL "NTS: ssdp:alive\r\n" // WiFi.localIP(), _port, _schemaURL "NT: urn:schemas-upnp-org:device:basic:1\r\n" // WiFi.localIP(), _port, _schemaURL "USN: uuid:2f402f80-da50-11e1-9b23-00178818572b\r\n" // WiFi.localIP(), _port, _schemaURL "\r\n";

//M-SEARCH HTTP/1.1 awnser static const char awnser = "HTTP/1.1 200 OK\r\n" // SSDP_INTERVAL "CACHE-CONTROL: max-age=100\r\n" // _modelName, _modelNumber "EXT: \r\n" // _uuid "LOCATION: http://192.168.1.124:80/description.xml\r\n" // WiFi.localIP(), _port, _schemaURL "SERVER: FreeRTOS/6.0.5, UPnP/1.0, IpBridge/0.1\r\n" // WiFi.localIP(), _port, _schemaURL "ST: upnp:rootdevice\r\n" // WiFi.localIP(), _port, _schemaURL "USN: uuid:2f402f80-da50-11e1-9b23-00178818572b::upnp:rootdevice\r\n" // WiFi.localIP(), _port, _schemaURL "\r\n";

void loop() { SendUDPNotify(); HTTP.handleClient(); // }

void SendUDPNotify() { static const unsigned long REFRESH_INTERVAL = 5 * 1000; // ms static unsigned long lastRefreshTime = 0;

if (millis() - lastRefreshTime >= REFRESH_INTERVAL) { lastRefreshTime += REFRESH_INTERVAL; IPAddress broadcastIp(239, 255, 255, 250); //IPAddress broadcastIp(255, 255, 255, 255); UDPTestServer.beginPacketMulticast(broadcastIp, UDPPort, WiFi.localIP()); //UDPTestServer.beginPacket(broadcastIp, UDPPort); UDPTestServer.write(Msg1); UDPTestServer.endPacket(); delay(10);

UDPTestServer.beginPacketMulticast(broadcastIp, UDPPort, WiFi.localIP());
//UDPTestServer.beginPacket(broadcastIp, UDPPort);
UDPTestServer.write(Msg2);
UDPTestServer.endPacket();
delay(10);
UDPTestServer.beginPacketMulticast(broadcastIp, UDPPort, WiFi.localIP());
//UDPTestServer.beginPacket(broadcastIp, UDPPort);
UDPTestServer.write(Msg3);
UDPTestServer.endPacket();

} }

I made this really quick and this make toon detect the hue should be easy to intergrate good luck ! more info is here https://github.com/ewjmulder/hue-bridge-simulator/blob/master/README.md

probonopd commented 6 years ago

Thanks @foen. Did you really hardcode IP addresses? This is pretty much guaranteed not to work for other people then...

foen commented 6 years ago

@probonopd its just example not ready for copy paste. :) toon finds the esp after It got those NOTIFY's I did not my build my project around this "ESP8266HueEmulator" so don't have copy and paste ready update for you