hyperion-project / hyperion.ng

The successor to Hyperion aka Hyperion Next Generation
https://hyperion-project.org/
MIT License
3.09k stars 384 forks source link

Invalid response from Philips Hue API #310

Closed janpfischer closed 7 years ago

janpfischer commented 7 years ago
"device" :
        {
                "name"       : "DefaultHyperionConfig",
                "type"       : "philipshue",
                "output":"192.168.0.176",
                "lightIds":[5],
                "username"     : "xxxxxxxxxxx",
                "rate"       : 1000000,
                "colorOrder" : "rgb",
                "switchOffOnBlack":false
        }

When I start hyperion I get following error: [HYPERIOND LedDevice] saveStates(nLights=1): got no state for light from http://192.168.0.176/api/d50ctoU/lights/5 [HYPERIOND LedDevice] saveStates(nLights=1): got invalid response from light http://192.168.0.176/api/d50ctoU/lights/5.

But when I open the link in my browser I get a respone: {"state":{"on":true,"bri":104,"hue":39392,"sat":13,"effect":"none","xy":[0.3691,0.3719],"ct":231,"alert":"none","colormode":"xy","reachable":true},"type":"Extended color light","name":"Computer","modelid":"LST002","manufacturername":"Philips","uniqueid":"00:17:88:01:01:1f:4b:29-0b","swversion":"5.50.2.19072"}

Some an idea?

brindosch commented 7 years ago

@ntim the Hue Guy :) Would be great if you could check against current development.

redPanther commented 7 years ago

It is possible, that something went wrong when migrating this to new qt json api

penfold42 commented 7 years ago

@b1rdhous3

Does running with --debug provide more output ?

redPanther commented 7 years ago

we can add better error output: in LedDevicePhilipsHue.cpp line 373 Error(... replace it with:

            Error(_log, "saveStates(nLights=%d): got invalid response from light %s. (error:%s, offset:%d)",
              nLights, getUrl(getRoute(lightIds.at(i))).toStdString().c_str(), error.errorString().toLocal8Bit().constData(), error.offset );
janpfischer commented 7 years ago

No more output with debug. I will compile and run it again @redPanther

redPanther commented 7 years ago

thx for helping to find the bug :+1:

janpfischer commented 7 years ago
saveStates(nLights=1): got invalid response from light http://192.168.0.176/api/d50ctoH6nu8hwbzMLQMa7ASjYX06EU/lights/5. (error:illegal value, offset:0) I only got "invalid response" once. The other error is happening all the time.
Paulchen-Panther commented 7 years ago

Es könnte sein das sich bei der Übersetzung von JsonCPP zu QTJson ein Fehler in der Hue Device Class eingeschlichen hat. Dies war am schwersten zu übersetzen. Werde demnächst noch mal über die Class schauen. Da ich leider keine Hues besitze kann ich die sache nicht testen. Sorry

Paulchen-Panther commented 7 years ago

Can you please insert this :

json = reader.object();

in LedDevicePhilipsHue.cpp on Line 369

janpfischer commented 7 years ago

Kein Problem, danke dass du dich kümmerst @Paulchen-Panther . ZUm testen bin ich ja da.

janpfischer commented 7 years ago

No changes with that line of code

ntim commented 7 years ago

I will try the new code at home

ntim commented 7 years ago

Works fine on my RPi3 with OSMC and 2 lights. Can you log the raw response in line 373? Not the parsed object since that obviously failed. It might not look the same as in your browser.

janpfischer commented 7 years ago

@ntim thank you for your answer but sadly I don't know how to display the raw data (var response?) at that point. I always get errors while compiling if i try

Can you please provide the line? Thanks!

ntim commented 7 years ago

Ok, will look into it tomorrow.

janpfischer commented 7 years ago

Thanks!

ntim commented 7 years ago

Hi, I put the following code after line 366:

std::cout << response.constData() << std::endl;

This gives me e.g. the following output:

{"state":{"on":true,"bri":254,"hue":13768,"sat":56,"effect":"none","xy":[0.4578,0.4142],"alert":"none","colormode":"xy","reachable":true},"type":"Color light","name":"LivingColors Links","modelid":"LLC011","manufacturername":"Philips","uniqueid":"00:17:88:01:00:c1:63:5d-0b","swversion":"5.23.1.13452"}

Today I also got the same problem, it says, the problem is that in this loop the retrieval of the json object is missing. Fixed it and submitted a pull request.

janpfischer commented 7 years ago

Hm, that it the same @Paulchen-Panther suggested and I tried that as well with no effect. I will check that again and also the logging. I will come back to this.

ntim commented 7 years ago

It is definitely missing anyway, may not be the fix to your problem after all but with the additional logging we should get going in the right direction .

redPanther commented 7 years ago

@b1rdhous3 has state changed here? if not, can you provide logs?

e.g.

Hi, I put the following code after line 366: std::cout << response.constData() << std::endl;

janpfischer commented 7 years ago

Havn't tested it yet. Will do in the next days.

redPanther commented 7 years ago

And how the tests going on? Would be good to know if hues work again

brindosch commented 7 years ago

@b1rdhous3 i consider to close this issue :)

redPanther commented 7 years ago

I close the issue. If we have trouble here we can make a new issue with latest info's