core: WebOS Integration not working since Update of WebOS

The problem

I have an LG OLED B2, since an Update of WebOS the Integration in Home Assistant is not working. previous Firmware: 03.21.20 current Firmware: 03.30.14

I already removed my device from Home Assistant and if i try to add the TV I just get an Unknown Error and no Notification on the TV. I added the Error from the log.

What version of Home Assistant Core has the issue?

2022.12.9

What was the last working version of Home Assistant Core?

2022.12.9

What type of installation are you running?

Home Assistant Container

Integration causing the issue

LG WebOS Smart TV

Link to integration documentation on our website

https://www.home-assistant.io/integrations/webostv

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: aiohttp.server
Source: components/webostv/__init__.py:133
First occurred: 16:05:47 (1 occurrences)
Last logged: 16:05:47

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/websockets/legacy/client.py", line 138, in read_http_response
    status_code, reason, headers = await read_response(self.reader)
  File "/usr/local/lib/python3.10/site-packages/websockets/legacy/http.py", line 120, in read_response
    status_line = await read_line(stream)
  File "/usr/local/lib/python3.10/site-packages/websockets/legacy/http.py", line 194, in read_line
    line = await stream.readline()
  File "/usr/local/lib/python3.10/asyncio/streams.py", line 525, in readline
    line = await self.readuntil(sep)
  File "/usr/local/lib/python3.10/asyncio/streams.py", line 617, in readuntil
    await self._wait_for_data('readuntil')
  File "/usr/local/lib/python3.10/asyncio/streams.py", line 502, in _wait_for_data
    await self._waiter
  File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 854, in _read_ready__data_received
    data = self._sock.recv(self.max_size)
ConnectionResetError: [Errno 104] Connection reset by peer

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 222, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 81, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 136, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 180, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 73, in wrapper
    result = await method(view, request, data, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 281, in async_configure
    result = await self._async_handle_step(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 368, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/usr/src/homeassistant/homeassistant/components/webostv/config_flow.py", line 98, in async_step_pairing
    client = await async_control_connect(self._host, None)
  File "/usr/src/homeassistant/homeassistant/components/webostv/__init__.py", line 133, in async_control_connect
    await client.connect()
  File "/usr/local/lib/python3.10/site-packages/aiowebostv/webos_client.py", line 73, in connect
    return await self.connect_result
  File "/usr/local/lib/python3.10/site-packages/aiowebostv/webos_client.py", line 105, in connect_handler
    main_ws = await asyncio.wait_for(
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 445, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 650, in _wrap_awaitable
    return (yield from awaitable.__await__())
  File "/usr/local/lib/python3.10/site-packages/websockets/legacy/client.py", line 659, in __await_impl_timeout__
    return await asyncio.wait_for(self.__await_impl__(), self.open_timeout)
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 445, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.10/site-packages/websockets/legacy/client.py", line 666, in __await_impl__
    await protocol.handshake(
  File "/usr/local/lib/python3.10/site-packages/websockets/legacy/client.py", line 326, in handshake
    status_code, response_headers = await self.read_http_response()
  File "/usr/local/lib/python3.10/site-packages/websockets/legacy/client.py", line 144, in read_http_response
    raise InvalidMessage("did not receive a valid HTTP response") from exc
websockets.exceptions.InvalidMessage: did not receive a valid HTTP response

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 1
  • Comments: 55 (11 by maintainers)

Most upvoted comments

Just after updating HA to 2023.1.4 my TV with 3.30.14 is working again from HA. Many thanks again to all that contributed to solve this issue!

  File "/usr/local/lib/python3.9/dist-packages/aiowebostv/webos_client.py", line 105, in connect_handler
    main_ws = await asyncio.wait_for(

This line number indicates you are running main branch off that repo which is not the patched one. Switch to a correct branch using git checkout try-ssl

I have uploaded aiowebostv version which should start without SSL and fallback to SSL if non-SSL connections are not permitted. This is the quickest way to do it since new firmware reply instantly when SSL is enforced.

To test:

pip uninstall aiowebostv -y
git clone --branch ssl-fallback https://github.com/home-assistant-libs/aiowebostv.git
cd aiowebostv

# replace 10.0.0.186 with TV IP (or edit examples/basic.py)
sed -i 's/192.168.1.39/10.0.0.186/g' examples/basic.py 

pip install --upgrade .
python examples/basic.py

If you get the pairing prompt on the TV (or a valid reply if you supplied a valid client key) it is working correctly, please report if you tested on newer firmware which enforce SSL or older device which doesn’t support SSL. Thanks 👍

thumb_image

After updating I initially had issues pairing but after a few times it worked, then the logs show:

  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 988, in _wrap_create_connection
    raise ClientConnectorCertificateError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host 10.0.0.186:3001 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)')]

The problem is with fetching images from the TV, see https://github.com/home-assistant/core/issues/85814, I am trying to think how to fix it as it fails outside of the webOS integration.

Indeed an android app pairing request results in a pairing code popup and after that code is used, the interaction works fine. I’m trying to get some TCP traffic visible to see what different request there might behind it, but need to change a few things before i can capture it right.

For the ‘downgrade’ firmware, there is a manual with steps described, I was not eager to follow that yet. If someone else dare to give it a try and inform here if it was succesfilm, pls be my guest… firmware are here: https://www.lge.co.kr/support/product-manuals?title=driver&mktModel (used translate from chrome to make it readable)