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] pairing 55PUS7394/12 (2019) fails (part 2) #51

Closed domcross closed 4 years ago

domcross commented 4 years ago

(...follow up to #41 as I couldn't reopen the issue...)

I updated the TVs Android software and successfully paired it with the iOS remote app, but the app doesn't do too much (ratings in the app store complain about missing/broken functionality with the latest app version).

After rebooting the TV now I get following:

python3 pylips.py 
Checking API version and port...
Trying http://IP.OF.MY.TV:1925/6/system
Connection refused
Trying http://IP.OF.MY.TV:1925/5/system
Connection refused
Trying http://IP.OF.MY.TV:1925/1/system
Connection refused
PING IP.OF.MY.TV (IP.OF.MY.TV) 56(84) bytes of data.
64 bytes from IP.OF.MY.TV: icmp_seq=1 ttl=64 time=0.597 ms

--- IP.OF.MY.TV ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.597/0.597/0.597/0.000 ms
IP IP.OF.MY.TV is online, but no known API is found. Exiting...

When I open the URL http://IP.OF.MY.TV:1925/6/system in my browser the result is

{"notifyChange":"http","menulanguage":"German","name":"55PUS7394-12","country":"Germany","serialnumber_encrypted":"H0HR6EHZSqqWtybuK40VCrnDxto62F89nqinyiuKo8A=\n","softwareversion_encrypted":"HUUPMg2cTvN\/QxSl+S+1x3LDy\/rpbDcYCScz\/pD42bjcp9kbObXMYLF7gEfGNXYK\n","model_encrypted":"x378brSX+8m4vCn29qtoG6a7g4l1YG3eX8XDWCDesZ4=\n","deviceid_encrypted":"hzu0wwK8b2wml0HUPWJz3tkNCxAuEqgRji79EOR\/yKI=\n","nettvversion":"8.2.0","epgsource":"no_epg","api_version":{"Major":6,"Minor":1,"Patch":0},"featuring":{"jsonfeatures":{"editfavorites":["TVChannels","SatChannels"],"recordings":["List","Schedule","Manage"],"ambilight":["LoungeLight","Hue","Ambilight","HueStreaming"],"menuitems":["Setup_Menu"],"textentry":["not_available"],"applications":["TV_Apps","TV_Games","TV_Settings"],"pointer":["not_available"],"inputkey":["key"],"activities":["intent"],"channels":["preset_string"],"mappings":["server_mapping"]},"systemfeatures":{"tvtype":"consumer","content":["dmr","pvr"],"tvsearch":"intent","pairing_type":"digest_auth_pairing","secured_transport":"true","companion_screen":"true"}},"os_type":"MSAF_2019_P"}

The other URLs do not return anything.

mebe1012 commented 4 years ago

Hi, I'm maintaining the new philips tv binding for openHAB and stumbled over this issue as my users with 2019er models experience the same problem. It seems that something at the API changed for 2019er models, since the Philips TV Remote App also doesn't work anymore. Even though compared to @domcross they recieve an ERROR 500 if they try to access http://IP.OF.MY.TV:1925/6/system. Known models with this problem: 43PUS7354/12 and 55PUS7304

Hope you guys are able to find out more, Cheers

eslavnov commented 4 years ago

Hey guys,

Yep, it does indeed look like Philips has changed something in 2019 models, which is both frustrating and quite expected :)

The best bet would be to wait for the Philips TV Remote App to support these models - then I can easily capture the traffic and find what exactly has changed. Until this happens, there is not much I can do since I don't own a 2019 model and flying completely blind here :(

SchmuFoo commented 4 years ago

(jFYI for other users than the previous two who are already aware of the following, f.e. cause of https://github.com/lucasvdh/codes.lucasvdh.philips-jointspace/issues/6)

Cant agree on that cause I have a 2019 device and most of the time it is running ;) With most I mean:

Sometime both API Ports are not open any more, then also the official Philips Remote App is not working any more. Didnt found a solution for that, only can wait then always until they are up again.

Working

On my 7304 from 2019 there IS an response (most of the time) on: http://IP:1925/system https://IP:1926/system http://IP:1925/6/system https://IP:1926/6/system

root@loxberry:/opt/loxberry# nmap -sT -P0 philipstv -p 1925,1926
Starting Nmap 7.40 ( https://nmap.org ) at 2019-12-25 00:51 CET
Nmap scan report for philipstv (192.168.178.75)
Host is up (0.0026s latency).
rDNS record for 192.168.178.75: PhilipsTV.fritz.box
PORT     STATE SERVICE
1925/tcp open  discovery-port
1926/tcp open  egs
// 20191225010153
// http://philipstv:1925/6/system

{
  "notifyChange": "http",
  "menulanguage": "German",
  "name": "58PUS7304/12",
  "country": "Germany",
  "serialnumber_encrypted": "jr4ZwfkbO4+72qJ7myyZmFFNHBV8zPLQz1WysjAqUio=\n",
  "softwareversion_encrypted": "lhhhHuMvLA/1vGNXQIftYWEFflgOIzeWb9iWlVGtriVTE1w82OkWbmp+8xuvaw9T\n",
  "model_encrypted": "A8aDp3Pn1TDmf18e53F2Vx02NQzRafnNqRMey1BJnQ8=\n",
  "deviceid_encrypted": "CwMywQQpxuR4GVd30PexMVbEl0MS5T4rOTIYnnosdi8=\n",
  "nettvversion": "8.2.0",
  "epgsource": "no_epg",
  "api_version": {
    "Major": 6,
    "Minor": 1,
    "Patch": 0
  },
  "featuring": {
    "jsonfeatures": {
      "editfavorites": [
        "TVChannels",
        "SatChannels"
      ],
      "recordings": [
        "List",
        "Schedule",
        "Manage"
      ],
      "ambilight": [
        "LoungeLight",
        "Hue",
        "Ambilight",
        "HueStreaming"
      ],
      "menuitems": [
        "Setup_Menu"
      ],
      "textentry": [
        "not_available"
      ],
      "applications": [
        "TV_Apps",
        "TV_Games",
        "TV_Settings"
      ],
      "pointer": [
        "not_available"
      ],
      "inputkey": [
        "key"
      ],
      "activities": [
        "intent"
      ],
      "channels": [
        "preset_string"
      ],
      "mappings": [
        "server_mapping"
      ]
    },
    "systemfeatures": {
      "tvtype": "consumer",
      "content": [
        "dmr",
        "pvr"
      ],
      "tvsearch": "intent",
      "pairing_type": "digest_auth_pairing",
      "secured_transport": "true",
      "companion_screen": "true"
    }
  },
  "os_type": "MSAF_2019_P"
}`

P.S.: My focus is controlling the Ambilight which works fine, but what is not working is POST Standby and GETing Powerstate (This is only working on 1926 with digest-auth)

Ambilight

loxberry@loxberry:~ $ curl -v -s -X POST -d {"power":"Off"} http://192.168.178.75:1925/6/ambilight/power
*   Trying 192.168.178.75...
* TCP_NODELAY set
* Connected to 192.168.178.75 (192.168.178.75) port 1925 (#0)
> POST /6/ambilight/power HTTP/1.1
> Host: 192.168.178.75:1925
> User-Agent: curl/7.52.1
> Accept: */*
> Content-Length: 11
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 11 out of 11 bytes
< HTTP/1.1 200 OK
< Date: Wed, 25 Dec 2019 22:03:49 GMT
< Accept-Ranges: bytes
< Server: Restlet-Framework/2.3.12
< Access-Control-Allow-Origin: *
< Content-Length: 0
<
* Curl_http_done: called premature == 0
* Connection #0 to host 192.168.178.75 left intact
loxberry@loxberry:~ $ curl -v -s -X POST -d {"power":"On"} http://192.168.178.75:1925/6/ambilight/power
*   Trying 192.168.178.75...
* TCP_NODELAY set
* Connected to 192.168.178.75 (192.168.178.75) port 1925 (#0)
> POST /6/ambilight/power HTTP/1.1
> Host: 192.168.178.75:1925
> User-Agent: curl/7.52.1
> Accept: */*
> Content-Length: 10
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 10 out of 10 bytes
< HTTP/1.1 200 OK
< Date: Wed, 25 Dec 2019 22:04:00 GMT
< Accept-Ranges: bytes
< Server: Restlet-Framework/2.3.12
< Access-Control-Allow-Origin: *
< Content-Length: 0
<
* Curl_http_done: called premature == 0
* Connection #0 to host 192.168.178.75 left intact
loxberry@loxberry:~ $

GETing Powerstate

loxberry@loxberry:~ $ curl -v -s http://192.168.178.75:1925/6/powerstate
*   Trying 192.168.178.75...
* TCP_NODELAY set
* Connected to 192.168.178.75 (192.168.178.75) port 1925 (#0)
> GET /6/powerstate HTTP/1.1
> Host: 192.168.178.75:1925
> User-Agent: curl/7.52.1
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Date: Wed, 25 Dec 2019 22:05:45 GMT
< Accept-Ranges: bytes
< Server: Restlet-Framework/2.3.12
< Content-Length: 439
< Content-Type: text/html; charset=UTF-8
<
<html>
<head>
   <title>Status page</title>
</head>
<body style="font-family: sans-serif;">
<p style="font-size: 1.2em;font-weight: bold;margin: 1em 0px;">Not Found</p>
<p>The server has not found anything matching the request URI</p>
<p>You can get technical details <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5">here</a>.<br>
Please continue your visit at our <a href="/">home page</a>.
</p>
</body>
</html>
* Curl_http_done: called premature == 0
* Connection #0 to host 192.168.178.75 left intact

Standby

​​​​​​​loxberry@loxberry:~ $ curl -v -s -X POST -d {"key":"Standby"} http://192.168.178.75:1925/6/input/key
*   Trying 192.168.178.75...
* TCP_NODELAY set
* Connected to 192.168.178.75 (192.168.178.75) port 1925 (#0)
> POST /6/input/key HTTP/1.1
> Host: 192.168.178.75:1925
> User-Agent: curl/7.52.1
> Accept: */*
> Content-Length: 13
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 13 out of 13 bytes
< HTTP/1.1 404 Not Found
< Date: Wed, 25 Dec 2019 22:07:19 GMT
< Accept-Ranges: bytes
< Server: Restlet-Framework/2.3.12
< Content-Length: 439
< Content-Type: text/html; charset=UTF-8
<
<html>
<head>
   <title>Status page</title>
</head>
<body style="font-family: sans-serif;">
<p style="font-size: 1.2em;font-weight: bold;margin: 1em 0px;">Not Found</p>
<p>The server has not found anything matching the request URI</p>
<p>You can get technical details <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5">here</a>.<br>
Please continue your visit at our <a href="/">home page</a>.
</p>
</body>
</html>
* Curl_http_done: called premature == 0
* Connection #0 to host 192.168.178.75 left intact

Non working

`loxberry@loxberry:~ $ nmap -sT -P0 philipstv
Starting Nmap 7.40 ( https://nmap.org ) at 2020-01-12 20:26 CET
Nmap scan report for philipstv (192.168.178.75)
Host is up (0.0019s latency).
rDNS record for 192.168.178.75: PhilipsTV.fritz.box
Not shown: 995 closed ports
PORT      STATE SERVICE
8008/tcp  open  http
8009/tcp  open  ajp13
8443/tcp  open  https-alt
9000/tcp  open  cslistener
49153/tcp open  unknown

Nmap done: 1 IP address (1 host up) scanned in 0.34 seconds
loxberry@loxberry:~ $ nmap -sT -P0 philipstv -p 1925,1926
loxberry@loxberry:~ $ nmap -sT -P0 philipstv -p 1925,1926

Starting Nmap 7.40 ( https://nmap.org ) at 2020-01-12 20:09 CET
Nmap scan report for philipstv (192.168.178.75)
Host is up (0.00053s latency).
rDNS record for 192.168.178.75: PhilipsTV.fritz.box
PORT     STATE  SERVICE
1925/tcp closed discovery-port
1926/tcp closed egs

Nmap done: 1 IP address (1 host up) scanned in 0.23 seconds
SchmuFoo commented 4 years ago

Now it is working again after hours of closed ports :o)

loxberry@loxberry:~ $ nmap -sT -P0 philipstv -p 1925,1926

Starting Nmap 7.40 ( https://nmap.org ) at 2020-01-12 20:40 CET
Nmap scan report for philipstv (192.168.178.75)
Host is up (0.00066s latency).
rDNS record for 192.168.178.75: PhilipsTV.fritz.box
PORT     STATE SERVICE
1925/tcp open  discovery-port
1926/tcp open  egs

Nmap done: 1 IP address (1 host up) scanned in 0.20 seconds

P.S.: When someone is knowing why the API is not online sometimes (although TV is pingable), I would realy appreciate more details ;)

eslavnov commented 4 years ago

Hey @SchmuFoo, thanks for your input! Regarding the API stopping to respond sometimes: have you tried the latest version of Pylips (1.1.0, published yesterday)? It should help in some cases...