Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Philips TV crashes and shows unavailable #49801

Closed
baccaglini-fabio opened this issue Apr 28, 2021 · 66 comments
Closed

Philips TV crashes and shows unavailable #49801

baccaglini-fabio opened this issue Apr 28, 2021 · 66 comments

Comments

@baccaglini-fabio
Copy link

The problem

no longer recognizes the TV on

What is version of Home Assistant Core has the issue?

2021.4.6

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Core

Integration causing the issue

Philips TV

Link to integration documentation on our website

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.components.philips_js
Source: components/philips_js/__init__.py:175 
Integration: Philips TV (documentation, issues) 
First occurred: 26 aprile 2021, 8:41:24 (11 occurrences) 
Last logged: 7:16:47

Unexpected error fetching philips_js data: can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.9/site-packages/httpx/_exceptions.py", line 326, in map_exceptions
    yield
  File "/srv/homeassistant/lib/python3.9/site-packages/httpx/_client.py", line 1492, in _send_single_request
    (status_code, headers, stream, ext) = await transport.arequest(
  File "/srv/homeassistant/lib/python3.9/site-packages/httpx/_transports/default.py", line 169, in arequest
    return await self._pool.arequest(
  File "/srv/homeassistant/lib/python3.9/site-packages/httpcore/_async/connection_pool.py", line 218, in arequest
    response = await connection.arequest(
  File "/srv/homeassistant/lib/python3.9/site-packages/httpcore/_async/connection.py", line 106, in arequest
    return await self.connection.arequest(method, url, headers, stream, ext)
  File "/srv/homeassistant/lib/python3.9/site-packages/httpcore/_async/http11.py", line 72, in arequest
    ) = await self._receive_response(timeout)
  File "/srv/homeassistant/lib/python3.9/site-packages/httpcore/_async/http11.py", line 133, in _receive_response
    event = await self._receive_event(timeout)
  File "/srv/homeassistant/lib/python3.9/site-packages/httpcore/_async/http11.py", line 169, in _receive_event
    event = self.h11_state.next_event()
  File "/usr/local/lib/python3.9/contextlib.py", line 135, in __exit__
    self.gen.throw(type, value, traceback)
  File "/srv/homeassistant/lib/python3.9/site-packages/httpcore/_exceptions.py", line 12, in map_exceptions
    raise to_exc(exc) from None
httpcore.RemoteProtocolError: can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE

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

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.9/site-packages/haphilipsjs/__init__.py", line 462, in getReq
    resp = await self.session.get(self._url(path), timeout=TIMEOUT)
  File "/srv/homeassistant/lib/python3.9/site-packages/httpx/_client.py", line 1539, in get
    return await self.request(
  File "/srv/homeassistant/lib/python3.9/site-packages/httpx/_client.py", line 1361, in request
    response = await self.send(
  File "/srv/homeassistant/lib/python3.9/site-packages/httpx/_client.py", line 1396, in send
    response = await self._send_handling_auth(
  File "/srv/homeassistant/lib/python3.9/site-packages/httpx/_client.py", line 1434, in _send_handling_auth
    response = await self._send_handling_redirects(
  File "/srv/homeassistant/lib/python3.9/site-packages/httpx/_client.py", line 1466, in _send_handling_redirects
    response = await self._send_single_request(request, timeout)
  File "/srv/homeassistant/lib/python3.9/site-packages/httpx/_client.py", line 1492, in _send_single_request
    (status_code, headers, stream, ext) = await transport.arequest(
  File "/usr/local/lib/python3.9/contextlib.py", line 135, in __exit__
    self.gen.throw(type, value, traceback)
  File "/srv/homeassistant/lib/python3.9/site-packages/httpx/_exceptions.py", line 343, in map_exceptions
    raise mapped_exc(message, **kwargs) from exc  # type: ignore
httpx.RemoteProtocolError: can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE

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

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/update_coordinator.py", line 173, in _async_refresh
    self.data = await self._async_update_data()
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/philips_js/__init__.py", line 175, in _async_update_data
    await self.api.update()
  File "/srv/homeassistant/lib/python3.9/site-packages/haphilipsjs/__init__.py", line 621, in update
    await self.getAmbilightMode()
  File "/srv/homeassistant/lib/python3.9/site-packages/haphilipsjs/__init__.py", line 946, in getAmbilightMode
    data = await self.getReq("ambilight/mode")
  File "/srv/homeassistant/lib/python3.9/site-packages/haphilipsjs/__init__.py", line 475, in getReq
    raise GeneralFailure(err) from err
haphilipsjs.GeneralFailure: can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE

Additional information

No response

@probot-home-assistant
Copy link

philips_js documentation
philips_js source
(message by IssueLinks)

@elupus
Copy link
Contributor

elupus commented Apr 28, 2021

Your tv has likely crashed.

@elupus
Copy link
Contributor

elupus commented Apr 28, 2021

By that i mean can you restart your tv completely. Pull the power plug on it for half a minute.

@baccaglini-fabio
Copy link
Author

I tried to unplug the tv and set it up again but nothing.

It always worked, only with the latest version I had problems.

@elupus
Copy link
Contributor

elupus commented Apr 29, 2021

What TV model is it?
What API version did you choose?
You didn't mention a working version in the report. So i assumed it never worked?

@baccaglini-fabio
Copy link
Author

my tv is a 46PFL4468H / 12 and I use version 1 of the api. I had version 2021.4.4 and it worked then I upgraded to 2021.4.6 and it didn't connect anymore

@elupus
Copy link
Contributor

elupus commented Apr 29, 2021

Can you turn on debug logging for "haphilipsjs" and for "homeassistant.components.philips_js"

@elupus
Copy link
Contributor

elupus commented Apr 29, 2021

are you sure it was 2021.4.4? it should be identical to 2021.4.6. 2021.4.3 was a bit different

@klatka
Copy link

klatka commented Apr 30, 2021

I am experiencing the same issue:

Logger: homeassistant.components.philips_js
Source: components/philips_js/__init__.py:175
Integration: Philips TV (documentation, issues)
First occurred: 20:34:56 (1 occurrences)
Last logged: 20:34:56

Unexpected error fetching philips_js data:
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/httpx/_exceptions.py", line 326, in map_exceptions
    yield
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1492, in _send_single_request
    (status_code, headers, stream, ext) = await transport.arequest(
  File "/usr/local/lib/python3.8/site-packages/httpx/_transports/default.py", line 169, in arequest
    return await self._pool.arequest(
  File "/usr/local/lib/python3.8/site-packages/httpcore/_async/connection_pool.py", line 218, in arequest
    response = await connection.arequest(
  File "/usr/local/lib/python3.8/site-packages/httpcore/_async/connection.py", line 106, in arequest
    return await self.connection.arequest(method, url, headers, stream, ext)
  File "/usr/local/lib/python3.8/site-packages/httpcore/_async/http11.py", line 72, in arequest
    ) = await self._receive_response(timeout)
  File "/usr/local/lib/python3.8/site-packages/httpcore/_async/http11.py", line 133, in _receive_response
    event = await self._receive_event(timeout)
  File "/usr/local/lib/python3.8/site-packages/httpcore/_async/http11.py", line 172, in _receive_event
    data = await self.socket.read(self.READ_NUM_BYTES, timeout)
  File "/usr/local/lib/python3.8/site-packages/httpcore/_backends/asyncio.py", line 157, in read
    raise
  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/httpcore/_exceptions.py", line 12, in map_exceptions
    raise to_exc(exc) from None
httpcore.ReadTimeout

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 462, in getReq
    resp = await self.session.get(self._url(path), timeout=TIMEOUT)
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1539, in get
    return await self.request(
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1361, in request
    response = await self.send(
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1396, in send
    response = await self._send_handling_auth(
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1434, in _send_handling_auth
    response = await self._send_handling_redirects(
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1466, in _send_handling_redirects
    response = await self._send_single_request(request, timeout)
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1492, in _send_single_request
    (status_code, headers, stream, ext) = await transport.arequest(
  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/_exceptions.py", line 343, in map_exceptions
    raise mapped_exc(message, **kwargs) from exc  # type: ignore
httpx.ReadTimeout

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

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 173, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/components/philips_js/__init__.py", line 175, in _async_update_data
    await self.api.update()
  File "/usr/local/lib/python3.8/site-packages/haphilipsjs/__init__.py", line 619, in update
    await self.getContext()
  File "/usr/local/lib/python3.8/site-packages/haphilipsjs/__init__.py", line 705, in getContext
    r = cast(Optional[ContextType], await self.getReq(f"context"))
  File "/usr/local/lib/python3.8/site-packages/haphilipsjs/__init__.py", line 475, in getReq
    raise GeneralFailure(err) from err
haphilipsjs.GeneralFailure

@elupus
Copy link
Contributor

elupus commented Apr 30, 2021

@klatka what model tv, what version. Your issued look different. You get a read timeout on the context endpoint. While @baccaglini-fabio seem to get something different on the ambilight/mode endpoint.

@klatka
Copy link

klatka commented Apr 30, 2021

This is from the TV:

Model: 65PUS8102/12
Version: TPM171E_R.107.001.136.003
Versionshinweise: Philips/PH7M_EU_5596/PH7M_EU_5596:8.0.0/OC/4708:user/release-keys
Erstelldatum: Tue Dec 1 20:11:52 CST 2020

I think this is API version 6
I can ping the TV

@baccaglini-fabio
Copy link
Author

sei sicuro che fosse 2021.4.4? dovrebbe essere identico a 2021.4.6. 2021.4.3 era leggermente diverso

yes it's true, I had read that the .4 had problems with the updates of the .5 on facebook and I waited for the .6 .. I had the .3 version!

@elupus
Copy link
Contributor

elupus commented Apr 30, 2021

@klatka your issue is different then. First fully restart your tv. They are so crash prone

@baccaglini-fabio okey, then it makes more sense. I need those debug logs.

@baccaglini-fabio
Copy link
Author

Here is the code: (my menu lang is italian not Ukrainian)

2021-04-30 22:06:49 DEBUG (MainThread) [haphilipsjs] Get succeded: system -> {
"menulanguage": "Ukrainian",
"name": "PHILIPS TV",
"country": "Other",
"serialnumber": "",
"softwareversion": "TBD",
"model": "PHILIPS_2K13_HT_SVT_DL"
}
2021-04-30 22:06:50 DEBUG (MainThread) [haphilipsjs] Get succeded: sources -> {
"tv": {
"name": "Watch TV"
},
"satellite": {
"name": "Watch Satellite"
},
"hdmi1": {
"name": "HDMI 1"
},
"hdmi2": {
"name": "HDMI 2"
},
"hdmi3": {
"name": "HDMI 3"
},
"hdmiside": {
"name": "HDMI Side"
},
"ext1": {
"name": "CVI"
},
"ext2": {
"name": "AVI"
},
"ypbpr": {
"name": "YPbPr"
},
"vga": {
"name": "VGA"
}
}
2021-04-30 22:06:51 DEBUG (MainThread) [haphilipsjs] Get failed: channels -> 404 <title>Not Found</title>Not Found
2021-04-30 22:06:52 DEBUG (MainThread) [haphilipsjs] Get succeded: audio/volume -> {
"muted": false,
"current": 0,
"min": 0,
"max": 60
}
2021-04-30 22:06:53 DEBUG (MainThread) [haphilipsjs] Get succeded: sources/current -> {
"id": "tv"
}
2021-04-30 22:06:53 DEBUG (MainThread) [haphilipsjs] Get succeded: channels/current -> {
"id": "10758529"
}
2021-04-30 22:06:53 DEBUG (MainThread) [haphilipsjs] Get succeded: ambilight/mode -> {
"current": "internal"
}
2021-04-30 22:06:53 ERROR (MainThread) [homeassistant.components.philips_js] Unexpected error fetching philips_js data: can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.9/site-packages/httpx/_exceptions.py", line 326, in map_exceptions
yield
File "/srv/homeassistant/lib/python3.9/site-packages/httpx/_client.py", line 1492, in _send_single_request
(status_code, headers, stream, ext) = await transport.arequest(
File "/srv/homeassistant/lib/python3.9/site-packages/httpx/_transports/default.py", line 169, in arequest
return await self._pool.arequest(
File "/srv/homeassistant/lib/python3.9/site-packages/httpcore/_async/connection_pool.py", line 218, in arequest
response = await connection.arequest(
File "/srv/homeassistant/lib/python3.9/site-packages/httpcore/_async/connection.py", line 106, in arequest
return await self.connection.arequest(method, url, headers, stream, ext)
File "/srv/homeassistant/lib/python3.9/site-packages/httpcore/_async/http11.py", line 72, in arequest
) = await self._receive_response(timeout)
File "/srv/homeassistant/lib/python3.9/site-packages/httpcore/_async/http11.py", line 133, in _receive_response
event = await self._receive_event(timeout)
File "/srv/homeassistant/lib/python3.9/site-packages/httpcore/_async/http11.py", line 169, in _receive_event
event = self.h11_state.next_event()
File "/usr/local/lib/python3.9/contextlib.py", line 135, in exit
self.gen.throw(type, value, traceback)
File "/srv/homeassistant/lib/python3.9/site-packages/httpcore/_exceptions.py", line 12, in map_exceptions
raise to_exc(exc) from None
httpcore.RemoteProtocolError: can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.9/site-packages/haphilipsjs/init.py", line 462, in getReq
resp = await self.session.get(self._url(path), timeout=TIMEOUT)
File "/srv/homeassistant/lib/python3.9/site-packages/httpx/_client.py", line 1539, in get
return await self.request(
File "/srv/homeassistant/lib/python3.9/site-packages/httpx/_client.py", line 1361, in request
response = await self.send(
File "/srv/homeassistant/lib/python3.9/site-packages/httpx/_client.py", line 1396, in send
response = await self._send_handling_auth(
File "/srv/homeassistant/lib/python3.9/site-packages/httpx/_client.py", line 1434, in _send_handling_auth
response = await self._send_handling_redirects(
File "/srv/homeassistant/lib/python3.9/site-packages/httpx/_client.py", line 1466, in _send_handling_redirects
response = await self._send_single_request(request, timeout)
File "/srv/homeassistant/lib/python3.9/site-packages/httpx/_client.py", line 1492, in _send_single_request
(status_code, headers, stream, ext) = await transport.arequest(
File "/usr/local/lib/python3.9/contextlib.py", line 135, in exit
self.gen.throw(type, value, traceback)
File "/srv/homeassistant/lib/python3.9/site-packages/httpx/_exceptions.py", line 343, in map_exceptions
raise mapped_exc(message, **kwargs) from exc # type: ignore
httpx.RemoteProtocolError: can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/update_coordinator.py", line 173, in _async_refresh
self.data = await self._async_update_data()
File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/philips_js/init.py", line 175, in _async_update_data
await self.api.update()
File "/srv/homeassistant/lib/python3.9/site-packages/haphilipsjs/init.py", line 622, in update
await self.getAmbilightCached()
File "/srv/homeassistant/lib/python3.9/site-packages/haphilipsjs/init.py", line 1010, in getAmbilightCached
r = await self.getReq("ambilight/cached")
File "/srv/homeassistant/lib/python3.9/site-packages/haphilipsjs/init.py", line 475, in getReq
raise GeneralFailure(err) from err
haphilipsjs.GeneralFailure: can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE
2021-04-30 22:06:53 DEBUG (MainThread) [homeassistant.components.philips_js] Finished fetching philips_js data in 6.630 seconds

@elupus
Copy link
Contributor

elupus commented Apr 30, 2021

So your tv breaks down when we grab ambilight data.. christ how many bugs can philips get into their API's.

@chillkiller
Copy link

I have also an issue with the philips tv integration and the tv in general... dont know what happens:

`> /usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py:1013: InsecureRequestWarning: Unverified HTTPS request is being made to host '192.168.1.8'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings

warnings.warn(

2021-05-01 10:43:36 ERROR (MainThread) [homeassistant.components.philips_js] Unexpected error fetching philips_js data: Authenticaion failed to device
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 173, in _async_refresh
self.data = await self._async_update_data()
File "/usr/src/homeassistant/homeassistant/components/philips_js/init.py", line 175, in _async_update_data
await self.api.update()
File "/usr/local/lib/python3.8/site-packages/haphilipsjs/init.py", line 609, in update
await self.getChannelLists()
File "/usr/local/lib/python3.8/site-packages/haphilipsjs/init.py", line 726, in getChannelLists
r = cast(ChannelDbTv, await self.getReq("channeldb/tv"))
File "/usr/local/lib/python3.8/site-packages/haphilipsjs/init.py", line 464, in getReq
raise AutenticationFailure("Authenticaion failed to device")
haphilipsjs.AutenticationFailure: Authenticaion failed to device`

/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py:1013: InsecureRequestWarning: Unverified HTTPS request is being made to host '192.168.1.8'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings warnings.warn( 2021-05-01 11:37:06 ERROR (MainThread) [homeassistant.helpers.entity] Update for light.wohnzimmer_ambilight fails Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 292, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 490, in async_device_update raise exc File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/philips_ambilight/light.py", line 253, in update self.getState() File "/config/custom_components/philips_ambilight/light.py", line 187, in getState fullstate = self._getReq('ambilight/currentconfiguration') File "/config/custom_components/philips_ambilight/light.py", line 299, in _getReq return json.loads(resp.text) File "/usr/local/lib/python3.8/json/__init__.py", line 357, in loads return _default_decoder.decode(s) File "/usr/local/lib/python3.8/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/local/lib/python3.8/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

@elupus
Copy link
Contributor

elupus commented May 1, 2021

You have a custom component that is logging errors. And the built in component have authentication errors.

Remove the custom component and readd the built in config entry.

@baccaglini-fabio
Copy link
Author

@elupus the TV is now a few years old, I change it and choose another brand .. maybe it's better!

@chillkiller
Copy link

You have a custom component that is logging errors. And the built in component have authentication errors.

Remove the custom component and readd the built in config entry.

fixed it.... Hope you also merge it with https://github.com/jomwells/ambihue and https://github.com/jomwells/ambilights to get my automations work again ;)

@Tof-le-Chauve
Copy link

Hello,

I have also an issue with the philips tv 65oled935/12
core-2021.4.1
Home Assistant Container

Logger: aiohttp.server
Source: components/philips_js/config_flow.py:85
First occurred: 0:57:04 (1 occurrences)
Last logged: 0:57:04

Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/httpx/_exceptions.py", line 326, in map_exceptions
yield
File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1492, in _send_single_request
(status_code, headers, stream, ext) = await transport.arequest(
File "/usr/local/lib/python3.8/site-packages/httpx/_transports/default.py", line 169, in arequest
return await self._pool.arequest(
File "/usr/local/lib/python3.8/site-packages/httpcore/_async/connection_pool.py", line 218, in arequest
response = await connection.arequest(
File "/usr/local/lib/python3.8/site-packages/httpcore/_async/connection.py", line 93, in arequest
self.socket = await self._open_socket(timeout)
File "/usr/local/lib/python3.8/site-packages/httpcore/_async/connection.py", line 119, in _open_socket
return await self.backend.open_tcp_stream(
File "/usr/local/lib/python3.8/site-packages/httpcore/_backends/auto.py", line 44, in open_tcp_stream
return await self.backend.open_tcp_stream(
File "/usr/local/lib/python3.8/site-packages/httpcore/_backends/asyncio.py", line 270, in open_tcp_stream
return SocketStream(
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/httpcore/_exceptions.py", line 12, in map_exceptions
raise to_exc(exc) from None
httpcore.ConnectTimeout

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

Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
resp = await self._request_handler(request)
File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle
resp = await handler(request)
File "/usr/local/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 119, in impl
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 56, in security_filter_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 18, in request_context_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 74, in ban_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 129, in auth_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 131, in handle
result = await result
File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 155, in post
return await super().post(request, flow_id)
File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 60, in wrapper
result = await method(view, request, *args, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 107, in post
result = await self._flow_mgr.async_configure(flow_id, data)
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 156, in async_configure
result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 214, in _async_handle_step
result: dict = await getattr(flow, method)(user_input)
File "/usr/src/homeassistant/homeassistant/components/philips_js/config_flow.py", line 148, in async_step_user
return await self.async_step_pair()
File "/usr/src/homeassistant/homeassistant/components/philips_js/config_flow.py", line 85, in async_step_pair
self._pair_state = await self._hub.pairRequest(
File "/usr/local/lib/python3.8/site-packages/haphilipsjs/init.py", line 359, in pairRequest
resp = await self.session.post(self._url("pair/request"), json=data, auth=None)
File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1624, in post
return await self.request(
File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1361, in request
response = await self.send(
File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1396, in send
response = await self._send_handling_auth(
File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1434, in _send_handling_auth
response = await self._send_handling_redirects(
File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1466, in _send_handling_redirects
response = await self._send_single_request(request, timeout)
File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1492, in _send_single_request
(status_code, headers, stream, ext) = await transport.arequest(
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/_exceptions.py", line 343, in map_exceptions
raise mapped_exc(message, **kwargs) from exc # type: ignore
httpx.ConnectTimeout

Thx

@klatka
Copy link

klatka commented May 2, 2021

@klatka your issue is different then. First fully restart your tv. They are so crash prone

After a full restart the TV is available in HA but only for 5 Minutes. Then the ambilight integration stops and also the TV is unavailable.

Logger: homeassistant.components.philips_js
Source: components/philips_js/init.py:175
Integration: Philips TV (documentation, issues)
First occurred: 30. April 2021, 20:34:56 (6 occurrences)
Last logged: 21:06:22

Unexpected error fetching philips_js data:
Unexpected error fetching philips_js data: can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/httpx/_exceptions.py", line 326, in map_exceptions
yield
File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1492, in _send_single_request
(status_code, headers, stream, ext) = await transport.arequest(
File "/usr/local/lib/python3.8/site-packages/httpx/_transports/default.py", line 169, in arequest
return await self._pool.arequest(
File "/usr/local/lib/python3.8/site-packages/httpcore/_async/connection_pool.py", line 218, in arequest
response = await connection.arequest(
File "/usr/local/lib/python3.8/site-packages/httpcore/_async/connection.py", line 106, in arequest
return await self.connection.arequest(method, url, headers, stream, ext)
File "/usr/local/lib/python3.8/site-packages/httpcore/_async/http11.py", line 72, in arequest
) = await self._receive_response(timeout)
File "/usr/local/lib/python3.8/site-packages/httpcore/_async/http11.py", line 133, in _receive_response
event = await self._receive_event(timeout)
File "/usr/local/lib/python3.8/site-packages/httpcore/_async/http11.py", line 172, in _receive_event
data = await self.socket.read(self.READ_NUM_BYTES, timeout)
File "/usr/local/lib/python3.8/site-packages/httpcore/_backends/asyncio.py", line 157, in read
raise
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/httpcore/_exceptions.py", line 12, in map_exceptions
raise to_exc(exc) from None
httpcore.ReadTimeout

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 462, in getReq
resp = await self.session.get(self._url(path), timeout=TIMEOUT)
File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1539, in get
return await self.request(
File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1361, in request
response = await self.send(
File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1396, in send
response = await self._send_handling_auth(
File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1434, in _send_handling_auth
response = await self._send_handling_redirects(
File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1466, in _send_handling_redirects
response = await self._send_single_request(request, timeout)
File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1492, in _send_single_request
(status_code, headers, stream, ext) = await transport.arequest(
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/_exceptions.py", line 343, in map_exceptions
raise mapped_exc(message, **kwargs) from exc # type: ignore
httpx.ReadTimeout

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

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 173, in _async_refresh
self.data = await self._async_update_data()
File "/usr/src/homeassistant/homeassistant/components/philips_js/init.py", line 175, in _async_update_data
await self.api.update()
File "/usr/local/lib/python3.8/site-packages/haphilipsjs/init.py", line 619, in update
await self.getContext()
File "/usr/local/lib/python3.8/site-packages/haphilipsjs/init.py", line 705, in getContext
r = cast(Optional[ContextType], await self.getReq(f"context"))
File "/usr/local/lib/python3.8/site-packages/haphilipsjs/init.py", line 475, in getReq
raise GeneralFailure(err) from err
haphilipsjs.GeneralFailure

@elupus
Copy link
Contributor

elupus commented May 2, 2021

I just got a crash on my tv too now. I think grabbing ambilight data might be crashing it. I will post an updated lib without that later.

@elupus elupus mentioned this issue May 8, 2021
21 tasks
@elupus
Copy link
Contributor

elupus commented May 8, 2021

This is likely the background crash in the SSL engine on the TV: restlet/restlet-framework-java#852

@elupus elupus changed the title Philips Tv Philips TV crashes and shows unavailable May 23, 2021
@labaland
Copy link

Same probs here :P

@henriklund
Copy link

This is likely the background crash in the SSL engine on the TV: restlet/restlet-framework-java#852

I have a similar experience (that the SSL fails to work) as mentioned in the link. However, in my case the SSL already stops after the TV sends its SYN ACK, and fails to respond on the CLIENT HELLO (part of the SSL handshake). From WireShark it looks as if TV believes it has not received a CLIENT HELLO whereas the client awaits the SERVER HELLO. The interesting part here is that there is no pattern in when this occurs. Power cycling the TV will get things back online. Powering TV ON / OFF through Home Assistant may work for a number of times. Leaving the TV off for hours, then power it on could in some cases cause this behaviour. In other cases, leaving the TV running for hours (and using Home Assistant to change channels, volume etc.) would work, and then all of a sudden the SSL connection would start to act up (especially seen the TV had been turnoff).

Currently I have a support case running against Philips for this. Unfortunately the push-back I get is that 'we do not really see the problem as the JointSpace queries only are defined for port 1925' :/

Ideas:
Previously I have successfully used an unofficial component. The difference I note is that the Philips TV integration queries Ambilight. Question is if would be / is possible to make querying this optional? Secondly, I note that all states are still queried even if PowerState goes to Standby (ie. when I turn it off). Question is if this is on purpose, or if such should be avoided (to limit the 'stress' on the TV)?

@Emrvb
Copy link

Emrvb commented Oct 1, 2021

You can tell httpx which backend to use with something like this:

    self.session = httpx.AsyncClient(limits=limits, timeout=timeout,
        mounts = {
            "all://": httpx.AsyncHTTPTransport(backend="asyncio", verify=False),
        }
    )

I'm at work now, so I cant directly copy and paste my modifications, there could be an error in there.

Regarding to closing of connections, in my opinion this has always been the responsibility of the layer that created the socket. I see the httpx client has several calls to close on exceptions but apparently they missed at least one.

I would suggest you explicitly close the connection after every update (not necessarily every request in update, but I suspect the TVs are rather eager on closing the connection) or notifyChange, especially if an exception was caught.

@Emrvb
Copy link

Emrvb commented Oct 3, 2021

I have a disappointing update to report. Changing the backend doesn't really help. I seems my TV was just in a good mood that evening and the following 24 hours. I guess its just another exception that needs to be caught with anyio backend and then ignored.
It raises the suspicion that XTV closes the connection before it sends a reply. This could be intentional of course but it could also be that they just forget to wait for the buffer to be flushed. Closing the connection seems to be intentional according to the logs.

Again I noticed that the https endpoint will become available again if you stop trying to access it for long enough. But as far as I can tell it isn't caused by a specific number of connections. A certain request causes a deadlock and follow up requests seems to exacerbate the issue. Maybe a timer/time variable that is shared between threads?

Also the unannounced switching to deep sleep is really bad for the reliability. I would have expected a notification for the powerstate but there doesn't seem to be one. I'm really curious how the app handles that, or is it just as unreliable? I tried settings up a mitm proxy with an emulator but couldn't get the app to pair yet.

@nikrays
Copy link

nikrays commented Nov 7, 2021

There is a solution?

@elupus
Copy link
Contributor

elupus commented Nov 9, 2021

@Emrvb i might have found a culprit. See mentioned pull request above. Without that sockets are leaked on some types of exceptions.

@Emrvb
Copy link

Emrvb commented Nov 10, 2021

Nice find. It should at least increase stability.

I still suspect something is causing a deadlock on the tv side (in my case). I haven't had time yet to properly monitor it. I still havent had any bright ideas about the deep sleep issue. There should be a proper way to handle that. That XTV service cant be that bad.

@nikrays
Copy link

nikrays commented Nov 10, 2021

it turns out that we are waiting for a fix in the next build ha core 21.11.3?

@elupus
Copy link
Contributor

elupus commented Nov 10, 2021

No. This is a fix that is needed in httpcore project. After which a chance in home assistant core is needed.

@nikrays
Copy link

nikrays commented Nov 10, 2021

Then we are waiting, thank you for not leaving the project!

@elupus
Copy link
Contributor

elupus commented Nov 26, 2021

Fixed by #59723 please open new issue and link to this after the release if problem persist.

@elupus elupus closed this as completed Nov 26, 2021
@nikrays
Copy link

nikrays commented Nov 26, 2021

Is the problem fixed or not? how do i make the integration work?

@elupus
Copy link
Contributor

elupus commented Nov 26, 2021

It should be fixed by the mentioned merged pull request. Which will be part of next release of home assistant. So report back if you still have issues after that is released and you have tested it or if you can test dev branch of home assistant.

@nikrays
Copy link

nikrays commented Nov 26, 2021

I understand, I'm waiting for the update of the home assistant, after, of course, I will unsubscribe if there are problems and provide the logs

@nikrays
Copy link

nikrays commented Nov 27, 2021

How to call the YouTube application from the library through the service? Or, for example, the "right" button? Send command doesn't work ..

@luiscoutinh
Copy link

I still have the same problem.

Home Assistant: core-2021.12.2
TV: 55OLED805/12

Error: Falha ao chamar o serviço remote/send_command. can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE

@luiscoutinh
Copy link

How to call the YouTube application from the library through the service? Or, for example, the "right" button? Send command doesn't work ..

tap_action:
  action: call-service
  service: media_player.play_media
  service_data:
    entity_id: media_player.**your_tv_entity**
    media_content_id: >-
      com.google.android.apps.youtube.tv.activity.ShellActivity-com.google.android.youtube.tv
    media_content_type: app

@elupus
Copy link
Contributor

elupus commented Dec 16, 2021

Yes issue remain. There is another issue for this still open. #57093 (comment) Waiting for a fix in httpcore library #60150

@elupus
Copy link
Contributor

elupus commented Dec 16, 2021

encode/httpcore#443

@nikrays
Copy link

nikrays commented Dec 17, 2021

How to call the YouTube application from the library through the service? Or, for example, the "right" button? Send command doesn't work ..

tap_action:
  action: call-service
  service: media_player.play_media
  service_data:
    entity_id: media_player.**your_tv_entity**
    media_content_id: >-
      com.google.android.apps.youtube.tv.activity.ShellActivity-com.google.android.youtube.tv
    media_content_type: app

Thanks! It worked for me! But let's say YouTube kids can't start this way, I do it like this:
media_content_id:> -
com.google.android.apps.youtube.tvkids.activity.ShellActivity-com.google.android.youtube.tvkids

@elupus elupus reopened this Dec 21, 2021
@elupus
Copy link
Contributor

elupus commented Dec 21, 2021

Please refrain from support discussions in issues.

@elupus
Copy link
Contributor

elupus commented Apr 5, 2022

This specific issue should no longer be a problem. It was due to leaking connections. I will close this for now.

@elupus elupus closed this as completed Apr 5, 2022
@github-actions github-actions bot locked and limited conversation to collaborators May 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests