eslavnov / pylips

Control Philips TVs (2015+) and Ambilight (+ Hue) through their reverse-engineered API (+ MQTT support!)
MIT License
342 stars 60 forks source link

[BUG] Can't launch Netflix (Philips TV POS9002) #40

Closed CodySummers closed 4 years ago

CodySummers commented 4 years ago

Describe the bug Might be a new user error, when I try the example code to launch netflix, amazon prime etc I can't.

This is the message I get back when using it.

Traceback (most recent call last): File "pylips.py", line 453, in pylips = Pylips(os.path.dirname(os.path.realpath(file))+"/settings.ini") File "pylips.py", line 109, in init self.run_command(args.command,body, self.verbose) File "pylips.py", line 311, in run_command return self.post(self.available_commands["post"][command]["path"], body,verbose, callback) File "pylips.py", line 265, in post body = json.loads(body) File "C:\Python34\lib\json__init__.py", line 318, in loads return _default_decoder.decode(s) File "C:\Python34\lib\json\decoder.py", line 343, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "C:\Python34\lib\json\decoder.py", line 361, in raw_decode raise ValueError(errmsg("Expecting value", s, err.value)) from None ValueError: Expecting value: line 1 column 1 (char 0)

To Reproduce Use this in CMD:

python pylips.py --command launch_app --body '{"id":"com.amazon.amazonvideo.livingroom","order":0,"intent":{"action":"Intent{act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=com.amazon.amazonvideo.livingroom }","component":{"packageName":"com.amazon.amazonvideo.livingroom","className":"com.amazon.ignition.IgnitionActivity"}},"label":"Prime Video"}'

Expected behavior Opens Amazon Prime

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Probably a new user error.

eslavnov commented 4 years ago

Hi, thanks for reporting this. Do other commands work for you (like volume or power off, for example)?

CodySummers commented 4 years ago

Hi, yes I've got a few of the commands setup through my google home and work really well.

Just launching apps doesn't work, and turning on after a off for a while but I think that the TV going into a deep sleep.

eslavnov commented 4 years ago

Yeah, turning on after off is indeed a deep sleep issue. Could you please locate line 265 in Pylips.py (body = json.loads(body)) and add print(body) before it? Then try to launch Amazon again and share the output here. Thanks!

CodySummers commented 4 years ago

This is what I get with print added.

'{id:com.amazon.amazonvideo.livingroom,order:0,intent:{action:Intent{act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=com.amazon.amazonvideo.livingroom },component:{packageName:com.amazon.amazonvideo.livingroom,className:com.amazon.ignition.IgnitionActivity}},label:Prime Video}' Traceback (most recent call last): File "pylips.py", line 453, in pylips = Pylips(os.path.dirname(os.path.realpath(file))+"/settings.ini") File "pylips.py", line 109, in init self.run_command(args.command,body, self.verbose) File "pylips.py", line 311, in run_command return self.post(self.available_commands["post"][command]["path"], body,verbose, callback) File "pylips.py", line 265, in post print(body) (body = json.loads(body)) File "C:\Python34\lib\json__init__.py", line 318, in loads return _default_decoder.decode(s) File "C:\Python34\lib\json\decoder.py", line 343, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "C:\Python34\lib\json\decoder.py", line 361, in raw_decode raise ValueError(errmsg("Expecting value", s, err.value)) from None ValueError: Expecting value: line 1 column 1 (char 0)

eslavnov commented 4 years ago

Your body argument is not properly formatted (id:com.amazon.amazonvideo.livingroom instead of "id":"com.amazon.amazonvideo.livingroom", and so on...). This works on my TV:

python pylips.py --command launch_app --body '{"id":"com.amazon.amazonvideo.livingroom","order":0,"intent":{"action":"Intent{act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=com.amazon.amazonvideo.livingroom }","component":{"packageName":"com.amazon.amazonvideo.livingroom","className":"com.amazon.ignition.IgnitionActivity"}},"label":"Prime Video"}'

CodySummers commented 4 years ago

What I type in has the " the version without the speechmarks get printed when I add print(body) to line 265.

I copied and pasted your code snippet to double check and got the same error:

Traceback (most recent call last):
  File "pylips.py", line 453, in <module>
    pylips = Pylips(os.path.dirname(os.path.realpath(__file__))+"/settings.ini")
  File "pylips.py", line 109, in __init__
    self.run_command(args.command,body, self.verbose)
  File "pylips.py", line 311, in run_command
    return self.post(self.available_commands["post"][command]["path"], body,verbose, callback)
  File "pylips.py", line 265, in post
    body = json.loads(body)
  File "C:\Python34\lib\json\__init__.py", line 318, in loads
    return _default_decoder.decode(s)
  File "C:\Python34\lib\json\decoder.py", line 343, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Python34\lib\json\decoder.py", line 361, in raw_decode
    raise ValueError(errmsg("Expecting value", s, err.value)) from None
ValueError: Expecting value: line 1 column 1 (char 0)

Might just be a slight API variation, thanks for your help.