Philips Android TV component

Sorry. 401 is unauthorized. Where did you get that number? Is it in home assistant logs? Or did you just try it manually with curl?

I am sorry meant 400 bad request.
Also see my post from some time ago, which did not get any response. Here are some more details.

I also tried with curl getting the same response

I’ve been using this component and the ambilight component for a while now, but since updating Home Assistant, it isn’t working anymore.

I’m getting these errors when checking the config:

Platform error media_player.philips_android_tv - Integration 'philips_android_tv' not found.
Platform error light.philips_ambilight - Integration 'philips_ambilight' not found.

The logs says this:

2021-06-05 13:26:09 WARNING (SyncWorker_3) [homeassistant.loader] We found a custom integration philips_ambilight which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant

2021-06-05 13:26:09 ERROR (SyncWorker_3) [homeassistant.loader] The custom integration 'philips_ambilight' does not have a valid version key (None) in the manifest file and was blocked from loading. See https://developers.home-assistant.io/blog/2021/01/29/custom-integration-changes#versions for more details

2021-06-05 13:26:09 WARNING (SyncWorker_2) [homeassistant.loader] We found a custom integration philips_android_tv which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant

2021-06-05 13:26:09 ERROR (SyncWorker_2) [homeassistant.loader] The custom integration 'philips_android_tv' does not have a valid version key (None) in the manifest file and was blocked from loading. See https://developers.home-assistant.io/blog/2021/01/29/custom-integration-changes#versions for more details

Do we need to wait for an update for the version key? Of can I fix it myself?

Does anyone have the same problem? Philips integration and protocol errors.

Logger: homeassistant
Source: components/philips_js/__init__.py:134
First occurred: 9:39:45 (4 occurrences)
Last logged: 9:46:46

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/anyio/streams/tls.py", line 102, in _call_sslobject_method
    result = func(*args)
  File "/usr/local/lib/python3.8/ssl.py", line 888, in read
    v = self._sslobj.read(len)
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2629)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/httpcore/_backends/anyio.py", line 59, in read
    return await self.stream.receive(n)
  File "/usr/local/lib/python3.8/site-packages/anyio/streams/tls.py", line 152, in receive
    data = await self._call_sslobject_method(self._ssl_object.read, max_bytes)
  File "/usr/local/lib/python3.8/site-packages/anyio/streams/tls.py", line 121, in _call_sslobject_method
    raise BrokenResourceError from exc
anyio.BrokenResourceError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/httpx/_transports/default.py", line 61, in map_httpcore_exceptions
    yield
  File "/usr/local/lib/python3.8/site-packages/httpx/_transports/default.py", line 277, in handle_async_request
    ) = await self._pool.handle_async_request(
  File "/usr/local/lib/python3.8/site-packages/httpcore/_async/connection_pool.py", line 237, in handle_async_request
    response = await connection.handle_async_request(
  File "/usr/local/lib/python3.8/site-packages/httpcore/_async/connection.py", line 148, in handle_async_request
    return await self.connection.handle_async_request(
  File "/usr/local/lib/python3.8/site-packages/httpcore/_async/http11.py", line 128, in handle_async_request
    ) = await self._receive_response(timeout)
  File "/usr/local/lib/python3.8/site-packages/httpcore/_async/http11.py", line 189, in _receive_response
    event = await self._receive_event(timeout)
  File "/usr/local/lib/python3.8/site-packages/httpcore/_async/http11.py", line 225, in _receive_event
    data = await self.socket.read(self.READ_NUM_BYTES, timeout)
  File "/usr/local/lib/python3.8/site-packages/httpcore/_backends/anyio.py", line 63, in read
    raise ReadError from exc
httpcore.ReadError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/haphilipsjs/__init__.py", line 504, in postReq
    resp = await self.session.post(self._url(path), json=data, timeout=timeout)
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1747, in post
    return await self.request(
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1426, in request
    response = await self.send(
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1511, in send
    response = await self._send_handling_auth(
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1546, in _send_handling_auth
    response = await self._send_handling_redirects(
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1580, in _send_handling_redirects
    response = await self._send_single_request(request, timeout)
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1621, in _send_single_request
    ) = await transport.handle_async_request(
  File "/usr/local/lib/python3.8/site-packages/httpx/_transports/default.py", line 272, in handle_async_request
    (
  File "/usr/local/lib/python3.8/contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "/usr/local/lib/python3.8/site-packages/httpx/_transports/default.py", line 78, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ReadError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/philips_js/__init__.py", line 134, in _notify_task
    res = await self.api.notifyChange(130)
  File "/usr/local/lib/python3.8/site-packages/haphilipsjs/__init__.py", line 1197, in notifyChange
    result = await self.postReq("notifychange", data=data, timeout=timeout_ctx)
  File "/usr/local/lib/python3.8/site-packages/haphilipsjs/__init__.py", line 522, in postReq
    raise GeneralFailure(err) from err
haphilipsjs.GeneralFailure

More than 100X appears in 2 hours of watching TV

I still lose connection after the newest updates.
Also somehow once in a while the ambilight now turns on and immediately turns off again.

edit: I know the reason why now. When I turn off the Ambilight even though it’s already off, the light turns on and immidiately off again.

Hi man, Was this the fix?

I don’t know if you changed anything in the back but the integration doesn’t lose connection for me anymore after days and I even restarted my tv in between.

@elupus is it possible to see the state of an app? e.g. playing, paused, stopped, idle, etc.

It doesn’t use notifications unless you opt into it from config entry options.

So it’s slower to react to changes.

No playing state doesn’t work for apps at all. The current intent data from the API is utterly unreliable.

1 Like

ah that’s too bad because your integration reacts so much faster than the Android ADB integration.
Anyway I’m really glad the connection is stable now. Thanks for your work!

If it’s possible for the ambilight integration to not turn on the light during a turn off call (even though it’s already off) then that would be perfect for me.

The ambilight solution in the tv is stupidly buggy. Maybe controlling it over the menu:s is less buggy. Might be worth a shot.

1 Like

sometimes I’m wondering what the development department of Philips TVs looks like.

1 Like

How is your Philips TV integration working?

For the last month or so, this integration only works for like 20-30 min after I restart HA. After that i loose “connection”. Don’t know if this started with 2021.7 or 2021.8.
Are there more people that experience this behaviour, or is something wrong with my system?

@Kardesken same problem

Hello, I also have a problem when I integrate Philips TV, everything works for about 4 days, then the TV is already in HA offline. It will only help to turn off the TV from 230. The problem will probably be with the API,
the original mobile application is still functional, only HA will lose communication.

does anyone have the same problem?

Very similar experience when TV becomes randomly unavailable in HA and can be fixed by only restarting HA or the TV itself.
Also, it seems that in such case the official component gives an error “TV unavailable” during an attempt e.g. turn on/off ambilight or the TV itself. This error breaks further execution of any automation or script that called such command.
Previously I used custom Philips TV component that didn’t have all features from the official one but was reliable in terms of keeping connection with TV and reporting on/off status.

I only need to report the ON / OF status

manual how do i do it?

I have temporarily disabled the official Philips TV integration, as it is too unreliable for any automation at the moment.

So I’ve returned back to the custom integration for now. This will give me an reliable feedback on the On/Off status of the TV.

how did you do that?custom integration you send the manual?

You’ll find Philips Android TV component if you search in HACS.
It’s also more or less what this thread is (or was) all about :grin:.

But the thread is long, so here is the link: Philips Android TV

1 Like

I still have a mistake
works ip address http://192.168.2.51:1925/ Forbidden ok
192.168.2.51’, port=1926 cannot be opened on the web

Starting pairing request
Traceback (most recent call last):
File “/home/pc/.local/lib/python3.8/site-packages/requests/packages/urllib3/connection.py”, line 140, in _new_conn
conn = connection.create_connection(
File “/home/pc/.local/lib/python3.8/site-packages/requests/packages/urllib3/util/connection.py”, line 83, in create_connection
raise err
File “/home/pc/.local/lib/python3.8/site-packages/requests/packages/urllib3/util/connection.py”, line 73, 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/pc/.local/lib/python3.8/site-packages/requests/packages/urllib3/connectionpool.py”, line 597, in urlopen
httplib_response = self._make_request(conn, method, url,
File “/home/pc/.local/lib/python3.8/site-packages/requests/packages/urllib3/connectionpool.py”, line 345, in _make_request
self._validate_conn(conn)
File “/home/pc/.local/lib/python3.8/site-packages/requests/packages/urllib3/connectionpool.py”, line 844, in _validate_conn
conn.connect()
File “/home/pc/.local/lib/python3.8/site-packages/requests/packages/urllib3/connection.py”, line 284, in connect
conn = self._new_conn()
File “/home/pc/.local/lib/python3.8/site-packages/requests/packages/urllib3/connection.py”, line 149, in _new_conn
raise NewConnectionError(
requests.packages.urllib3.exceptions.NewConnectionError: <requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f1d6ad30340>: 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/pc/.local/lib/python3.8/site-packages/requests/adapters.py”, line 413, in send
resp = conn.urlopen(
File “/home/pc/.local/lib/python3.8/site-packages/requests/packages/urllib3/connectionpool.py”, line 648, in urlopen
retries = retries.increment(method, url, error=e, _pool=self,
File “/home/pc/.local/lib/python3.8/site-packages/requests/packages/urllib3/util/retry.py”, line 376, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host=‘192.168.2.51’, port=1926): Max retries exceeded with url: /6/pair/request (Caused by NewConnectionError(‘<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f1d6ad30340>: 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 140, in
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/pc/.local/lib/python3.8/site-packages/requests/api.py”, line 110, in post
return request(‘post’, url, data=data, json=json, **kwargs)
File “/home/pc/.local/lib/python3.8/site-packages/requests/api.py”, line 56, in request
return session.request(method=method, url=url, **kwargs)
File “/home/pc/.local/lib/python3.8/site-packages/requests/sessions.py”, line 488, in request
resp = self.send(prep, **send_kwargs)
File “/home/pc/.local/lib/python3.8/site-packages/requests/sessions.py”, line 609, in send
r = adapter.send(request, **kwargs)
File “/home/pc/.local/lib/python3.8/site-packages/requests/adapters.py”, line 487, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host=‘192.168.2.51’, port=1926): Max retries exceeded with url: /6/pair/request (Caused by NewConnectionError(‘<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f1d6ad30340>: Failed to establish a new connection: [Errno 111] Connection refused’))

i’m seeing the same errors even though my TV doesn’t lose connection anymore.