seydx / homebridge-sonybravia-platform

Sony Android TV Platform for Homebridge
MIT License
22 stars 0 forks source link

Plugin doesn't allow homebridge to launch while TV is off #6

Closed epheterson closed 6 years ago

epheterson commented 6 years ago

It seems that getting the app list on my Sony requires it to be awake. I've set the always-on IP mode on the TV, and the plugin is able to turn the TV on while it's off. In spite of that, if I launch homebridge while the TV is off, it gets stuck looking for apps. I have Sony model KDL40W600B.

It just prints this in a loop: [2018-3-23 04:31:48] [Sony] Sony: TypeError: Cannot read property '0' of undefined - Trying again [2018-3-23 04:31:58] [Sony] Getting apps... [2018-3-23 04:31:58] [Sony] Sony: TypeError: Cannot read property '0' of undefined - Trying again

seydx commented 6 years ago

Normally the State of the TV dont disturb the Plugin or getting the App list

Can you try following curl Command and Post the Output here pls

curl -s -X POST -d "{\"id\":3,\"method\":\"getContentList\",\"version\":\"1.0\",\"params\":[{\"source\":\"tv:dvbt\"}]}" "http://IPADRESSEHERE/sony/avContent" -H "X-Auth-PSK: PSKHERE"

seydx commented 6 years ago

thats curious... i dont have any problems with starting homebridge when the tv is off... can you post the full log pls? maybe its not coming from apps

you can try the above command to check if the app service is causing the error

just turn off the tv, post the command above and look if you get apps in your output or an error with "illegal argument" or "display is off"

epheterson commented 6 years ago

Yeah I have no problem turning it on while it's off, I just tried with this command:

curl -H "Content-Type: application/json" \
  -H "X-Auth-PSK: xxx" \
  -X POST \
  -d '{"id": 20, "method": "setPowerStatus", "version": "1.0", "params": [{"status":true}]}' \
  http://192.168.0.18/sony/system

I see homebridge show this, looping: [2018-3-23 23:27:32] [Sony] Sony: TypeError: Cannot read property '0' of undefined - Trying again [2018-3-23 23:27:42] [Sony] Getting apps... [2018-3-23 23:27:42] [Sony] Sony: TypeError: Cannot read property '0' of undefined - Trying again ...

Is there another log somewhere?

epheterson commented 6 years ago

When I manually try commands like this, I hit:

curl -H "Content-Type: application/json" \
                      -H "X-Auth-PSK: xxx" \
                      -X POST \
                      -d '{"id": 20, "method": "setPowerSyncMode", "version": "1.0", "params": [{"sinkPowerOffSync":true,"sourcePowerOnSync":true}]}' \
                      http://192.168.0.18/sony/cec

{"error":[7,"not power-on"],"id":20}

I think it'd be best if this plugin could cache information once, and not query it each time it starts. Or, it's okay to try, but back off if this message is returned?

Same command works fine after powering it on: {"id":20,"result":[]}

seydx commented 6 years ago

Very strange, ok i will add a cache function, and if cache is empty, the plugin will output a message to turn on the tv first before try a new request

epheterson commented 6 years ago

Thanks! I've been looking for a homebridge solution for my TV for a while, and this is the first one that works at all. Save these few small faults, it's awesome how many features you've got!

seydx commented 6 years ago

should be fixed with v2.3 can you try and give some feedback pls

epheterson commented 6 years ago

Unfortunately it still behaves the same way, it does realize the TV is off, but doesn't use a cache:

[2018-3-25 22:00:04] [Sony] An error occured by getting application list!
[2018-3-25 22:00:04] [Sony] Please turn on the TV! Trying again...
[2018-3-25 22:00:14] [Sony] Getting apps...
seydx commented 6 years ago

I did not use a cache so that the plugin can see the installed apps every time I restart homebridge. Otherwise we had the problem with "new" installed apps, because it would always read from cache

seydx commented 6 years ago

cache function for apps added in v2.3.1 can you try the latest version and give some feedback pls

epheterson commented 6 years ago

Hey, working great! I'd like to mention that it may be worth attempting to update the cache, but if the TV is determined to be off after one attempt, then just use the cache. That, or, the next time the plugin notices the TV is on, it can update the cache then.

seydx commented 6 years ago

I think it is ok if the user store manually the applist to the cache with i.e. Elgato EVE app (the button for Applist in the app output the apps to the log AND store the new applist to the cache). Otherwise it will always make a new request if the TV is on

seydx commented 6 years ago

I think i can close this issue? Or do you have problems with starting HB while TV is off?

epheterson commented 6 years ago

All good, thanks a lot!