Philips Android TV component

Hi everyone,
I have a 55POS9002 OLED TV bought in 2018.
I’m trying to pair the TV but I’m stuck : I get a “Connection refused” error.

Do you have some idea for me ? Thx

Model : 55POS9002
Firmware : TPM171E_R.107.001.101.002

Starting pairing request
Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.5/site-packages/urllib3/connection.py", line 171, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "/home/pi/.local/lib/python3.5/site-packages/urllib3/util/connection.py", line 79, in create_connection
    raise err
  File "/home/pi/.local/lib/python3.5/site-packages/urllib3/util/connection.py", line 69, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/home/pi/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 343, in _make_request
    self._validate_conn(conn)
  File "/home/pi/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 849, in _validate_conn
    conn.connect()
  File "/home/pi/.local/lib/python3.5/site-packages/urllib3/connection.py", line 314, in connect
    conn = self._new_conn()
  File "/home/pi/.local/lib/python3.5/site-packages/urllib3/connection.py", line 180, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0xb62f6d30>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.5/site-packages/requests/adapters.py", line 445, in send
    timeout=timeout
  File "/home/pi/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/home/pi/.local/lib/python3.5/site-packages/urllib3/util/retry.py", line 398, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='192.168.0.55', port=1926): Max retries exceeded with url: /6/pair/request (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0xb62f6d30>: Failed to establish a new connection: [Errno 111] Connection refused',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "philips.py", line 123, in <module>
    main()
  File "philips.py", line 90, in main
    pair(config)
  File "philips.py", line 41, in pair
    r = requests.post("https://" + config['address'] + ":1926/6/pair/request", json=data, verify=False)
  File "/home/pi/.local/lib/python3.5/site-packages/requests/api.py", line 112, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/home/pi/.local/lib/python3.5/site-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/pi/.local/lib/python3.5/site-packages/requests/sessions.py", line 512, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/pi/.local/lib/python3.5/site-packages/requests/sessions.py", line 622, in send
    r = adapter.send(request, **kwargs)
  File "/home/pi/.local/lib/python3.5/site-packages/requests/adapters.py", line 513, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='192.168.0.55', port=1926): Max retries exceeded with url: /6/pair/request (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0xb62f6d30>: Failed to establish a new connection: [Errno 111] Connection refused',))
pi@raspberrypi:~ $ python3 philips.py --host 192.168.0.55 pair
Starting pairing request
Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.5/site-packages/urllib3/connection.py", line 171, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "/home/pi/.local/lib/python3.5/site-packages/urllib3/util/connection.py", line 79, in create_connection
    raise err
  File "/home/pi/.local/lib/python3.5/site-packages/urllib3/util/connection.py", line 69, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/home/pi/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 343, in _make_request
    self._validate_conn(conn)
  File "/home/pi/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 849, in _validate_conn
    conn.connect()
  File "/home/pi/.local/lib/python3.5/site-packages/urllib3/connection.py", line 314, in connect
    conn = self._new_conn()
  File "/home/pi/.local/lib/python3.5/site-packages/urllib3/connection.py", line 180, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0xb6300d30>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.5/site-packages/requests/adapters.py", line 445, in send
    timeout=timeout
  File "/home/pi/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/home/pi/.local/lib/python3.5/site-packages/urllib3/util/retry.py", line 398, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='192.168.0.55', port=1926): Max retries exceeded with url: /6/pair/request (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0xb6300d30>: Failed to establish a new connection: [Errno 111] Connection refused',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "philips.py", line 123, in <module>
    main()
  File "philips.py", line 90, in main
    pair(config)
  File "philips.py", line 41, in pair
    r = requests.post("https://" + config['address'] + ":1926/6/pair/request", json=data, verify=False)
  File "/home/pi/.local/lib/python3.5/site-packages/requests/api.py", line 112, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/home/pi/.local/lib/python3.5/site-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/pi/.local/lib/python3.5/site-packages/requests/sessions.py", line 512, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/pi/.local/lib/python3.5/site-packages/requests/sessions.py", line 622, in send
    r = adapter.send(request, **kwargs)
  File "/home/pi/.local/lib/python3.5/site-packages/requests/adapters.py", line 513, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='192.168.0.55', port=1926): Max retries exceeded with url: /6/pair/request (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0xb6300d30>: Failed to establish a new connection: [Errno 111] Connection refused',))

Sorry to reply on an old comment, but I had some trouble myself too. During initial setup using https://github.com/suborb/philips_android_tv I got an error ‘connection refused 111’. Restarted the TV, no difference. Just before trying to do a factory reset, I realised I had also just installed the Android TV remote app on my phone, which I then disabled. And voilà: pairing succesful!

So, I seems that the API only accepts one connection at a time?

Anyway, I thought I would post this here for future reference…

Hi,
i have 55PUS6703 with same issue. Did you mange to solve your problem?

Sadly, I didn’t manage to make it work.
I’m still waiting for some help.

Hi Meyer,

I am still struggling but had the following two observations:

  1. By examining the network traffic from the “Philips Remote” app om my phone, I figured out that my tv runs on port 1925 instead of 1926. I replaced 1926 by 1925 the 4 places In the “philips.py” file and the connection error disappeared. So this might solve your problem.
  2. But I started facing other issues that I think are related to which version combination you are running: Python, OpenSSL, Requests and pycrypto. As I saw error regarding encryption, protocol etc. And post om the internet mentioning that you need specific combinations but these are now outdated as for example I couldn’t run python version 2.6 as it is not supported any mor. I hope someone can tell about a still running set up with which versions.

Even though I still can’t pair, I can for example use this address in a browser “http://192.168.0.61:1925/6/audio/volume” to fetch the volume from the TV. So I can communicate with the TV without pairing and using username and password. I am therefor trying to run the Philips_2014 custom component that runs without. I just saw that it seams to work but with very limited functionality, power on/off and controlling the volume.

I’ll continue my research and look forward to hear where changing the port number solved your issue.

I’ll post any progress and other observations :blush:

Hi Meyer,

Good news, I think i figured it out :blush:

This component is designed for android OS but not all Philips TVs run android and need pairing with username and password.

try the following: From a computer on the same network as your tv, in a browser go to

http://:192.168.0.55:1925/1/system and http://:192.168.0.55:1926/1/system

Hopefully one will return access denied and the other will return response with data.

if you get the response data, at the bottom you should see system feature. mine returns the following:

“pairing_type”: “none”,

“os_type”: “Linux”

therefor no need for username and password.

in this case you need to edit the medai_player.py file in the custom component in Hassio and replace all https by http and probably 1926 by 1926 depending on which url gave you a response with data

But make the first verification step and let me know, then I can guide you through the next steps

/Ghassan

1 Like

A few days ago, I had the television connected by wifi, now I have it by cable and the app did not work, in the end the problem I think was that it uses port 1925 for Wi-Fi and 1926 for cable

I am experiencing problems connecting the TV from the “Philips TV Remote” app. It says invalid IP address and then i fails to connect from HASSIO too.

Could be related to conflicts between connection from HASSIO through this component.

Power off the tv (take out from the wall outlet) , waiting for 5 minutes to reset, and power on again, does not help every time.

I am not able to connect right now.

Anyone have similar experience or knowledge about this?

Hi all, I also had connectivity issues with my 55pus7304 and now there is a workaround for this, making the status unknown when the connection drops so the automations only triggers when goes from off to on…

Also I found that the dropouts may be caused by too many calls to the api, as before I had hass and homebridge at the same time and it was failing way more times than now that I have only hass

Should pairing be done from the same device the plugin is installed on?
I’m running HassIO but it doesn’t allow me to clone repo’s and run python scripts as instructed.

Hi @schumi2004,

As I understand it, the pairing process is separate with the only purpose to get the username and password. This need not be run from the same device running HASSIO. You can do it from at Mac, Windows PC or other devices. You just need to have python running with the needed prerequisites and be on the same network as your tv.

/Ghassan

Hello,

is it possible to use adb command ?

action:
  service: androidtv.adb_command
  data:
    entity_id: media_player.philips_tv
    command: "LEFT"

I would like to create buttons to navigate in the interface.

I tried but it did not work.

thank you and stay safe!

@maxime.vilmay try

command: "input keyevent KEYCODE_SOFT_LEFT"

https://developer.android.com/reference/android/view/KeyEvent#KEYCODE_SOFT_LEFT

Hi an20dei,

I Have no trouble running the philips.py if I use my desktop. But on hassio I get an error (Terminal)
“-bash: python: command not found”
Do I need to install python? I assumed it is already installed since it already runs python scripts

Is there a way to do this on hassio? I can run the philips.py but it complains that I’m missing the import requests library. Normally I would do pio installl requests. But I can not do this on hassio.

Is there some other way?

Sorry for the stupid question,
my Philips OLED TV is connected via lan cable and everythink it’s work ok.
But if I don’t send commend for a certain time, the TV is not answer anymore.
If I try to ping the TV ip is not answer.
But if I PowerOn and StandBy again it return to answer again. (also at ping command)

So is there some think do to in order always on on my LAN IP please ?

Thanks a lot all
Denis

Pairing with the tv, but this is based on a raspberry, i have Home Assistant on a Synology (docker) how do i got the script then?

What to do if you don’t have a Raspberry but Hassio on a Docker in Synology?

@Ghassan Ghassan Christensen wrote:
As I understand it, the pairing process is separate with the only purpose to get the username and password. This need not be run from the same device running HASSIO. You can do it from at Mac, Windows PC or other devices. You just need to have python running with the needed prerequisites and be on the same network as your tv.

I don’t have a Raspberry, used it in the past always trouble with the cards after a while, i use Hassio in Docker on Synology,
I dit copy philips.py to my user directory, then on Terminal (Putty on Mac)
python philips.py --host 192.168.1.106 pair where 192.168.1.106 is my Philips 7354 Android TV. Too bad i got: Traceback (most recent call last):
File “philips.py”, line 6, in
import requests What is the exact row to type in?

Hi Bob,

Are you sure your TV runs android?
Se my post for details her:

Mine for example runs Linux and can/need not be paired.
So, try the following two links from any browser on same network as your TV:

http://:192.168.1.106:1925/1/system
http://:192.168.1.106:1926/1/system

Notice which one gives a response
and examine the system details you get