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] pylips dies on 55OLED754/12 (apiversion 6.1.0) because http://x.x.x.x:1925/6/activities/current does not exist #39

Closed marcelser closed 4 years ago

marcelser commented 5 years ago

Describe the bug The new Philips 55OLED754/12 reports as apiversion it's 6.1.0 but it does not support the /6/activites/current endpoint. This makes the use of pylips mostly impossible especially in MQTT mode which I wanted to use because it just dies because it tries to query activities as soon as the tv is in mode Powerstate "on"

To Reproduce 1.) configure mqtt settings in settings.ini 2.) start pylips in MQTT mode (so without any parameters) 3.) pylips dies as soon as it tries ti query activities

Expected behavior there ahould at least be a possibility to skip this query or not do a fatal call Probably script should go on on every "Not Found" answer.

eslavnov commented 5 years ago

Thanks for the report! Do you get any kind of an error message (you might have to specify 'verbose' as True in the settings)?

eslavnov commented 5 years ago

Also, please attach the results of https://ip-address:1926/6/system (or http://ip-address:1925/6/system if the first does not work). Thanks!

marcelser commented 5 years ago

The error is this one: Sending GET request to http://192.168.10.78:1925/6/activities/current Request sent!

Not FoundNot Found

Traceback (most recent call last): File "pylips.py.backup", line 453, in pylips = Pylips(os.path.dirname(os.path.realpath(file))+"/settings.ini") File "pylips.py.backup", line 97, in init self.start_mqtt_updater(self.verbose) File "pylips.py.backup", line 447, in start_mqtt_updater self.mqtt_update_app() File "pylips.py.backup", line 413, in mqtt_update_app actv_status=json.loads(actv_status) File "/usr/lib/python3.6/json/init.py", line 354, in loads return _default_decoder.decode(s) File "/usr/lib/python3.6/json/decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Here's the output of the /6/system output { "menulanguage": "German", "name": "55OLED754/12", "country": "Switzerland", "serialnumber_encrypted": "K2kseVsmQFgkd15gKkJ+aqKgAW0YsiYm18R34DasGA4=", "softwareversion_encrypted": "K2kseVsmQFgkd15gKkJ+amueMe3DHAmDQ8d/R/pbq76od3Wmqm0WSs8gfLFv0gbo", "model_encrypted": "K2kseVsmQFgkd15gKkJ+aoVYVbm8KvlYgfINFpkYHig=", "deviceid_encrypted": "K2kseVsmQFgkd15gKkJ+aoHwEy/f1mmf7qHz4lUYUPU=", "nettvversion": "4.6.0.1", "epgsource": "no_epg", "api_version": { "Major": 6, "Minor": 1, "Patch": 0 }, "featuring": { "jsonfeatures": { "recordings": [ "List", "Schedule", "Manage" ], "ambilight": [ "Hue", "HueStreaming", "Ambilight" ], "textentry": [ "context_based", "initial_string_available" ], "inputkey": [ "key", "unicode" ], "pointer": [ "context_based" ], "activities": [ "browser" ] }, "systemfeatures": { "tvtype": "consumer", "content": [ "dmr" ], "pairing_type": "none", "companion_screen": true, "os_type": "Linux" } } }

BTW: I commented out the call to activities and set the return value to 'None'. Then I ran into this error:

Sending POST request to http://192.168.10.78:1925/6/menuitems/settings/current Request sent! { "version": 1, "values": [ { "value": {

                    }
            }
    ]

}

Traceback (most recent call last): File "pylips.py.fixed_act", line 454, in pylips = Pylips(os.path.dirname(os.path.realpath(file))+"/settings.ini") File "pylips.py.fixed_act", line 97, in init self.start_mqtt_updater(self.verbose) File "pylips.py.fixed_act", line 450, in start_mqtt_updater self.mqtt_update_ambihue() File "pylips.py.fixed_act", line 405, in mqtt_update_ambihue ambihue = ambihue_status["values"][0]["value"]["data"]["value"] KeyError: 'data'

So I also had to comment out the call to the ambilight because the return value did not expect the returned json value. So I commented out this call as well in the same manner. So currently my pylips is running with some ugly hacks. Would be nice to have a proper detection of this case.

PPS: The system call needs to go to port 1925 because this TV runs on Philips SAPHI OS instead of Android.

It seems that some other URLs also don't work or have changed in SAPHI. For example I can turn on/off the ambilight in the Philips TV Remote App but not in pylips.

eslavnov commented 5 years ago

Thanks, this is very useful!

Did not know about the SAPHI OS (it flew completely under my radar), and it seems to behave slightly differently than Android/old non-Android TVs. That's why some endpoints like activities fail (it's for Android TVs) and the errors are not handled correctly (they are different from non-Android TVs).

Since I don't have such a TV to reverse-engineer it, the best I can do for now is basically repeat your hack - e.g. just skip the endpoints that don't return the expected data. However, if you install Charles and send me the captured traffic between the TV and Philips TV Remote App, then I'll be able to add support for SAPHI TVs.

albertomarrod commented 4 years ago

Thanks, this is very useful!

Did not know about the SAPHI OS (it flew completely under my radar), and it seems to behave slightly differently than Android/old non-Android TVs. That's why some endpoints like activities fail (it's for Android TVs) and the errors are not handled correctly (they are different from non-Android TVs).

Since I don't have such a TV to reverse-engineer it, the best I can do for now is basically repeat your hack - e.g. just skip the endpoints that don't return the expected data. However, if you install Charles and send me the captured traffic between the TV and Philips TV Remote App, then I'll be able to add support for SAPHI TVs.

Hi! Maybe I can "help" you with this. I am a Saphi TV owner and I have no idea how to add the support for SAPHI TVs.

I guess I should install Charles on my laptop and then listen the ports of the TV. If I am wrong just tell me how to help you with this.

BTW: Thank you so much for your effort and for such a great work you made

eslavnov commented 4 years ago

Hey @albertomarrod,

Thanks for offering your help! To add support for SAPHI OS, I would require the following: 1) List of pylips commands that do not work as expected on SAPHI OS 2) For each of this commands, I'll need a saved Charles session with you using these commands via the Philips mobile remote app. Then I can take a look at the sent packets and reverse-engineer such commands.

If you choose to do it, please split these commands into different Charles sessions (otherwise it can be hard to figure out which request triggers which command)!

albertomarrod commented 4 years ago

Hey @albertomarrod,

Thanks for offering your help! To add support for SAPHI OS, I would require the following:

  1. List of pylips commands that do not work as expected on SAPHI OS
  2. For each of this commands, I'll need a saved Charles session with you using these commands via the Philips mobile remote app. Then I can take a look at the sent packets and reverse-engineer such commands.

If you choose to do it, please split these commands into different Charles sessions (otherwise it can be hard to figure out which request triggers which command)

Hy @eslavnov,

I just start trying pylips and I am having the same issue than people on here https://github.com/eslavnov/pylips/issues/62.

I attached the issue I am getting... Maybe you will be able to help me more.

Thanks!

Pylips

Edit: My TV model is 65PUS6703

emivaljr commented 4 years ago

@albertomarrod I had the same issue on my Saphi OS TV and the solution is to enable WoWLAN option: Network -> Switch on with Wi-FI(WoWLAN). It comes by default off. After that, I was able to call the API on 1925 port.