supersaiyanmode / PyWebOSTV

Python API for controlling LG TVs (Web OS)
MIT License
261 stars 50 forks source link

Empty app.list_apps() after init of a 2nd client. #19

Closed kilian579 closed 5 years ago

kilian579 commented 5 years ago

So I tried to create a client discarding it and creating a second client.

client = WebOSClient(ip)
client.connect()

client2 = WebOSClient(ip)
client2.connect()

The second client will connect to the TV, it is able to send commands, but the list of apps from

app = ApplicationControl(client)
apps = app.list_apps()

will be empty, so starting an app from there won't work.

Traceback (most recent call last): File "webos_testsheet.py", line 138, in controlPrompt(client2) File "webos_testsheet.py", line 41, in controlPrompt apps = app.list_apps() File "C:\Users\vvvbb\Dropbox\Dinter\SmartTv\src\pywebostv\controls.py", line 117, in request_func status, message = response_valid(payload) File "C:\Users\vvvbb\Dropbox\Dinter\SmartTv\src\pywebostv\controls.py", line 44, in standard_validation if not payload.pop("returnValue"): KeyError: 'returnValue'

On other tries i just got an empty list and a NoneType Error

supersaiyanmode commented 5 years ago

I thought that was fixed in this commit: https://github.com/supersaiyanmode/PyWebOSTV/commit/8e4e3f11eb73c137b126b2d58de2520e62c337c4. Are you using the latest version?

supersaiyanmode commented 5 years ago

On closer reading I see standard_validation in your stacktrace. IIRC, that came after that commit -- this is weird. Can I perhaps suggest logging the payload in the standard_validation(..) and pasting the response here?

Also, I see one potential issue: We need to change payload.pop("returnValue") -> payload.pop("returnValue", None). Would you want to send a PR seeing as you surfaced it?