core: Latest fix to IAquakink (2023.2.4) has not resolved issue

The problem

Logger: homeassistant.components.iaqualink Source: components/iaqualink/init.py:151 Integration: Jandy iAqualink (documentation, issues) First occurred: 11:54:33 AM (189 occurrences) Last logged: 12:41:33 PM

Failed to refresh system XXXXXXXXXXX state: <ConnectionTerminated error_code:ErrorCodes.NO_ERROR, last_stream_id:961, additional_data:None>

(actual system ID has been replaced with "X"s.)

What version of Home Assistant Core has the issue?

2023.2.4

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

No response

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.components.websocket_api.http.connection
Source: components/iaqualink/utils.py:14
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 12:27:54 PM (1 occurrences)
Last logged: 12:27:54 PM

[139775231935392] <ConnectionTerminated error_code:ErrorCodes.NO_ERROR, last_stream_id:961, additional_data:None>
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/h2/connection.py", line 224, in process_input
    func, target_state = self._transitions[(self.state, input_)]
KeyError: (<ConnectionState.CLOSED: 3>, <ConnectionInputs.SEND_HEADERS: 0>)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/httpcore/_async/http2.py", line 106, in handle_async_request
    await self._send_request_headers(request=request, stream_id=stream_id)
  File "/usr/local/lib/python3.10/site-packages/httpcore/_async/http2.py", line 203, in _send_request_headers
    self._h2_state.send_headers(stream_id, headers, end_stream=end_stream)
  File "/usr/local/lib/python3.10/site-packages/h2/connection.py", line 766, in send_headers
    self.state_machine.process_input(ConnectionInputs.SEND_HEADERS)
  File "/usr/local/lib/python3.10/site-packages/h2/connection.py", line 228, in process_input
    raise ProtocolError(
h2.exceptions.ProtocolError: Invalid input ConnectionInputs.SEND_HEADERS in state ConnectionState.CLOSED

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/httpx/_transports/default.py", line 60, in map_httpcore_exceptions
    yield
  File "/usr/local/lib/python3.10/site-packages/httpx/_transports/default.py", line 353, in handle_async_request
    resp = await self._pool.handle_async_request(req)
  File "/usr/local/lib/python3.10/site-packages/httpcore/_async/connection_pool.py", line 253, in handle_async_request
    raise exc
  File "/usr/local/lib/python3.10/site-packages/httpcore/_async/connection_pool.py", line 237, in handle_async_request
    response = await connection.handle_async_request(request)
  File "/usr/local/lib/python3.10/site-packages/httpcore/_async/connection.py", line 90, in handle_async_request
    return await self._connection.handle_async_request(request)
  File "/usr/local/lib/python3.10/site-packages/httpcore/_async/http2.py", line 139, in handle_async_request
    raise RemoteProtocolError(self._connection_error_event)
httpcore.RemoteProtocolError: <ConnectionTerminated error_code:ErrorCodes.NO_ERROR, last_stream_id:961, additional_data:None>

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

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 200, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1787, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1824, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 680, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 968, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 720, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 571, in async_handle_light_on_service
    await light.async_turn_on(**filter_turn_on_params(light, params))
  File "/usr/src/homeassistant/homeassistant/components/switch_as_x/entity.py", line 80, in async_turn_on
    await self.hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1787, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1824, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 680, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 968, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 720, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/iaqualink/__init__.py", line 192, in wrapper
    await func(self, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/components/iaqualink/switch.py", line 59, in async_turn_on
    await await_or_reraise(self.dev.turn_on())
  File "/usr/src/homeassistant/homeassistant/components/iaqualink/utils.py", line 14, in await_or_reraise
    await awaitable
  File "/usr/local/lib/python3.10/site-packages/iaqualink/systems/iaqua/device.py", line 130, in turn_on
    await self._toggle()
  File "/usr/local/lib/python3.10/site-packages/iaqualink/systems/iaqua/device.py", line 147, in _toggle
    await self.system.set_aux(self.data["aux"])
  File "/usr/local/lib/python3.10/site-packages/iaqualink/systems/iaqua/system.py", line 174, in set_aux
    r = await self._send_session_request(aux)
  File "/usr/local/lib/python3.10/site-packages/iaqualink/systems/iaqua/system.py", line 72, in _send_session_request
    return await self.aqualink.send_request(url)
  File "/usr/local/lib/python3.10/site-packages/iaqualink/client.py", line 98, in send_request
    r = await self._client.request(
  File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1533, in request
    return await self.send(request, auth=auth, follow_redirects=follow_redirects)
  File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1620, in send
    response = await self._send_handling_auth(
  File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1648, in _send_handling_auth
    response = await self._send_handling_redirects(
  File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1685, in _send_handling_redirects
    response = await self._send_single_request(request)
  File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1722, in _send_single_request
    response = await transport.handle_async_request(request)
  File "/usr/local/lib/python3.10/site-packages/httpx/_transports/default.py", line 352, in handle_async_request
    with map_httpcore_exceptions():
  File "/usr/local/lib/python3.10/contextlib.py", line 153, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/usr/local/lib/python3.10/site-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.RemoteProtocolError: <ConnectionTerminated error_code:ErrorCodes.NO_ERROR, last_stream_id:961, additional_data:None>

Additional information

No response

About this issue

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

Most upvoted comments

Apologies for the radio silence. I’m away from home and with limited free time.

This hasn’t been an issue that’s easy to reproduce. I appreciate everyone’s willingness to troubleshoot. Identifying that the issue was related to the token expiring after an hour saved a lot of time and also explained why I couldn’t reproduce the issue running a test instance for 30 minutes…

Looks like I missed one. Will try and set a fix later.

Thanks @flz … very much appreciate your efforts to support this integration…

Looks like I missed one. Will try and send a fix later.

I’ve submitted the temporary diff that I suggested a few days ago as a stop-gap. A proper fix in the library would have similar logic but I will have to add proper unit-testing and will require more time.

At least in the meantime, home-assistant instances will work again.

Just want to say that I’m thankful for everyone here. I did the update earlier and found it wasn’t working, too - and then here we are, a fix already in the works. Amazing.

Highly valued integration in our house. Looking forward to the fix and thanks again.

BTW, it works for a while upon restart of HomeAssistant, but within a few hours loses synch with the iaqualink cloud due to error. So, you may want to test for a day or so, and ensure that throughout your test period you can control pool pump or pool lights. My personal experience is that after some time it stops responding and then see errors in the log.

Yes - I believe got same issue here. Thank you for your efforts!

Thank you! We appreciate your efforts!

Unfortunately, I was not able to get the workaround working. So, very appreciative of your extra work. I think that I got everything packaged up correctly for the workaround, but after restarting HA the integration was unavailable. Same as if I restarted the integration every 30 minutes. Not going to worry about the workaround if the “fix” (even if it is a patch) is in process.

Just keep in mind that you’re not alone in this endeavor. Let us know how we can help!

Again, many thank you’s from this household!

Hi All,

I am in the process of testing the PR for https://github.com/flz/iaqualink-py/pull/19 currently. It seems to have fixed the HA issue for me for the last hour of testing. Here is a quick fix if anyone else wants to test it as well. Create a custom component from https://github.com/home-assistant/core/tree/dev/homeassistant/components/iaqualink and then update the manifest.json file with the following. Until the PR gets merged into the main python branch, this is the easiest fix.

{
  "domain": "iaqualink",
  "name": "Jandy iAqualink",
  "codeowners": ["@flz"],
  "config_flow": true,
  "documentation": "https://www.home-assistant.io/integrations/iaqualink/",
  "iot_class": "cloud_polling",
  "loggers": ["iaqualink"],
  "version": "0.0.1",
  "requirements": ["git+https://github.com/jbronikowski/iaqualink-py@master#iaqualink", "h2==4.1.0"]
}

The two key components needed are

  "version": "0.0.1",
  "requirements": ["git+https://github.com/jbronikowski/iaqualink-py@master#iaqualink", "h2==4.1.0"]

You might try calling the config reload service manually through “Dev Tools” when the iAqualink service isn’t working. If that works, then an automation will work. If that doesn’t work, then I’m at a loss. It does work for me.

For the time_pattern, minutes: 10 means run when the time unit, minutes in this case, equals 10. Asterisk matches all hours. You can also omit the hours reference which is the same thing. minutes: /10 would match every 10 minutes

HA Time Patterns