LG WebOS integration unknown error

Hi everyone,

I’d need some help.
I’ve had this working perfectly before, but recently, it fell off my HA map and I haven’t been able to get it to work again. I’ve removed the integration but when trying to reestablish it, I get the error below. The TV already has a static IP, which I’ve also tried changing but it did nothing. The LG app on my phone works fine. I’m not sure what to try.

Thanks!!

Logger: aiohttp.server
Source: components/webostv/__init__.py:143
First occurred: 12:02:53 PM (2 occurrences)
Last logged: 12:07:31 PM
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 100, 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 82, 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 280, in async_configure
    result = await self._async_handle_step(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, 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 143, 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

Reset the TV to factory settings, updated HA to latest version, SOLVED
Not the best solution, but it worked.

The last version of HA have a lot of pieces for the LG WebOS TV and before that there were a bug with the LG WebOS TV pairing, so it was probably the updated HA that did the trick. :slight_smile: