Closed janus-reith closed 7 years ago
Can you send a pull request that presses the emulated button automagically?
I have to dig into the code first, as I don't have profound knowledge about the hue api yet
Do you have a reference code of how the hue bridge works?
Because i just tried this Java based Hue Bridge Emulator on my computer, and it behaved strange:
It does have an implementation to emulate the press the Link Button, however the 2. gen Hue App didn't find it at all.
The 1. gen Hue App found it, but then asked to push the Link Button: So I (virtually) pressed the button, and it connected and worked afterwards.
When i use the ESP8266 based bridge with the 1. gen App, it doesnt ask for the press of the Link button, so I wonder if there already is some kind of implementation for that here?
I also mainly studied the Java based Hue Bridge Emulator. Philips has some documentation, too.
Seems to be working with both iOS apps as of 1ad3705
I have an issue with this with the original android app..
Could you help me?
Please describe the issue in detail, and state the exact app version.
No of the apps i tried are working (able to pair).. They discover the hue bridge but are not able to pair.. The original hue app (https://play.google.com/store/apps/details?id=com.philips.lighting.hue2) requests me to push "link button".. but there is no such thing in code.. I'm not sure if there is some external button that i need to connect.
I'm using esp-12e
Hello, i did some research and i found that the linking works in the way that the HUE app sends post request to http://[IP]/api
After that the HUE bridge must respond with a username which the app can use to access the bridge.. in this case
[{"success":{"username":"api"}}]
so i constructed following html:
<form action="http://[IP]/api" method="POST">
<input type="submit" value="Submit">
</form>
if i launch this html in browser on my phone and hit submit i get an url not available error. If i enter the same url to a browser (e.g. do a GET request) http://[IP]/api i will get a response so the esp is available on network.
If i try the same page on my PC it works as expected, [{"success":{"username":"api"}}] is returned
I was thinking that some csrf policy on android might be the problem but the HUE app probably does not use a browser to execute the post..
Any ideas on what could block the post request?
Hello, any new ideas on this??
I tried this myself, for some reason my Android phone can't connect to http://[IP]/api
with a standard GET request using Chrome but my macOS laptop can.
I've no ideas, but at least this is triaged.
Hm.. OK.. probably the phone/network or ESP8266WebServer is the issue here.. I just opened the HelloServer sketch..
the page looks like this
<form action="http://192.168.254.15/api" method="POST">
<input type="submit" value="Submit">
</form>
From pc it works fine From android the page is unavailable..
It does not matter if i enter a port after the IP
I will try to do a post from java by android app and let you know what error code will be returned
Very strange, potentially a bug in the ESP8266WebServer? But Chrome is crosscompiled, so the results should not be different.
Could you try with Firefox on Android?
The android test was done using webview only.. i can't launch it with ff or chrome.. let me try
chrome from android works, default browser also (not htmlview)
Now let's switch to the hueEmulator sketch and see if it logs a request
Mkay.. so with Chrome this works on Android.. it might be something completely different :(( Aaaaaaaaaaaaaaaaggghhhrrrrr!
This is weird, I'll try again when I'm back home with Chrome on Android as it didn't work for me before.
Calling the api GET now works for me using Chrome on Android, WebView (Chrome) and Firefox...
Get works as expected.. that was never an issue... Also the put method fails only in webview.. chrome for android works ok...
I'm not sure now if the post for /api never gets send from the app or what. There is nothing being logged to console if i put serial.print into the auth method of lightservice.. i was reading the HUE api spec but i dont know if there is s9mething failing before that..
Ok.. so i put Serial debug info into every single function.. and this is what i get when i try to pair the bridge to official hue app: After i hit search: configFn GET 274163 {"name":"hue emulator","swversion":"81012917","bridgeid":"18FE34FFFED2C582","portalservices":false,"linkbutton":true,"mac":"18:FE:34:D2:C5:82","dhcp":true,"ipaddress":"192.168.254.37","netmask":"255.255.255.0","gateway":"192.168.254.1","apiversion":"1.3.0
After that no requests are being made.. so it seems that the app does not try the authFn.. after a while i get descriptionFn
.. but that is just some software pinging the ip (i guess)..
What methods should be called in order for the app to connect?
I'm not sure why the json is not ending with } ,... is this just stripped?
Mkay .. now we are getting somewhere.. The json from /api/config is stripped! Why?
also the wholeConfigFn returns stripped json (invalid)
Ah crap! I had 2 aJson libraries.. one on my lib folder and one in documents (without the 4096 byte modification as specified in the sketch)..
So after i fixed the lib, everything works as expected!
Thanx everyone for help.. Nice coding exercise 🐇
@janus-reith is it also working for you now, so that we can close this issue?
Yes, you can.. thank you!
Just a note for others.
HUE ap looks for the bridge usind SSDP protocol. This worked ok.. and returns bridge ip. After that it makes a get request to /api to retreive bridge capabilities. This returned incomplete json. Unfortunately no error was displayed in app.
This caused the app never calling the auth (post to /api)
New Apps, like the 2. gen Android App find the bridge, but won't get past waiting for the user to press the Push-Link-Button on the Bridge.
Same happens for the Luminance Hue App for Linux(relies on phue Phyton library), which throws an exception at the Push-Link screen: http.client.RemoteDisconnected: Remote end closed connection without response