home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
69.94k stars 29.03k forks source link

Latest fix to IAquakink (2023.2.4) has not resolved issue #88033

Closed LGH531 closed 1 year ago

LGH531 commented 1 year ago

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

home-assistant[bot] commented 1 year ago

Hey there @flz, mind taking a look at this issue as it has been labeled with an integration (iaqualink) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `iaqualink` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Change the title of the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign iaqualink` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


iaqualink documentation iaqualink source (message by IssueLinks)

flz commented 1 year ago

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

LGH531 commented 1 year ago

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

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

harrynrobinson commented 1 year ago

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

smshapiro85 commented 1 year ago

Thank you @flz! Really appreciate you all of the work you do to maintain this.

yuckypants commented 1 year ago

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.

devMarcus commented 1 year ago

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!

chilipeppr commented 1 year ago

Yeah, I'm finding the same error. If I reboot Home Assistant, the iAqualink component works fine, but then stops working within a day or so.

chilipeppr commented 1 year ago

When I try to toggle something like the Pool Light, which I have as part of a daily automation for my yard lighting... image

Here's the error I get inside the Home Assistant UI. image

Noodleheader commented 1 year ago

Sending some more love to the team! This integration is core to my HA setup, so thank you for your efforts!

devMarcus commented 1 year ago

Same symptoms.

So, I am curious. Overall, is this an issue with the Jandy API, the implementation within python, or what?

Thank you!

Sent from my iPad

On Feb 16, 2023, at 12:10 PM, Noodleheader @.***> wrote:



Sending some more love to the team! This integration is core to my HA setup, so thank you for your efforts!

— Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/88033#issuecomment-1433425079, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ARBHCMFU3ZA7FY4EANFE6V3WXZNQTANCNFSM6AAAAAAU2XPYHU. You are receiving this because you commented.Message ID: @.***>

yuckypants commented 1 year ago

For the record, updated yesterday to 2023.2.5 and still no dice. I know @flz didn't say the last fix was uploaded, but I did see a comment in the release notes. Just like @devMarcus, still experiencing same symptoms.

michaelyork commented 1 year ago

Thanks for your help @flz! 🙏

devMarcus commented 1 year ago

Definitely - Thank you….

Anything you need from us? Chocolates, tea, doritos? Developers like doritos…

Sent from my iPad

On Feb 16, 2023, at 5:28 PM, Michael York @.***> wrote:



Thanks for your help @flzhttps://github.com/flz! 🙏

— Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/88033#issuecomment-1433800359, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ARBHCMBTEIXIPKU3FB667G3WX2SXFANCNFSM6AAAAAAU2XPYHU. You are receiving this because you were mentioned.Message ID: @.***>

matthewhadley commented 1 year ago

Same symptoms. So, I am curious. Overall, is this an issue with the Jandy API, the implementation within python, or what?

I am interested to know this too. For me, when the integration fails, reloading the integration just puts it in an unavailable state and subsequent attempts to reload the integration cause a UI popup saying "Restart Home Assistant to finish reloading this integration". So the entire Home Assistant needs to be restarted to get the integration back (until it fails again).

ffpllc commented 1 year ago

I also updated to 2023.2.5 and am still getting the error. A reboot fixes it for a little while, but for me it stops working a couple of hours later.

smshapiro85 commented 1 year ago

Just wanted to note something to the group that I just realized regarding automations after scratching my head for a few days- I have an automation that turns off my pool lights at 10:15pm every day, and the action to turn off the pool lights is ~#25 in a list of ~30 actions. So once the automation reached the pool lights and errored out, the remaining actions did not trigger. For now I have moved the pool light action to the end of the list.

image

devMarcus commented 1 year ago

Guys,

I do not have any automations or anything, and just let it sit and it will error out. My hunch is that it looses its connection to the cloud. Not 100% certain. If needed I can troubleshoot to the nth degree. But have not done that as it seemed that @FLZ was working on a fix.

Sent from my iPhone

On Feb 19, 2023, at 12:14 PM, smshapiro85 @.***> wrote:



Just wanted to note something to the group that I just realized regarding automations after scratching my head for a few days- I have an automation that turns off my pool lights at 10:15pm every day, and the action to turn off the pool lights is ~#25https://github.com/home-assistant/core/pull/25 in a list of ~30 actions. So once the automation reached the pool lights and errored out, the remaining actions did not trigger. For now I have moved the pool light action to the end of the list.

[image]https://user-images.githubusercontent.com/41717535/219963541-32421b82-d548-4fcf-ad68-d244dfdcbbfb.png

— Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/88033#issuecomment-1436041804, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ARBHCMBDCTYTUD6P5XH2CWDWYJIFNANCNFSM6AAAAAAU2XPYHU. You are receiving this because you were mentioned.Message ID: @.***>

devMarcus commented 1 year ago

My limited analysis is that this is a result of an authentication issue. Jandy used to keep alive for a ridiculous amount of time the auth token, and now it expires within what I am guessing to be 12 or so hours. Can’t remember how long I had my C# code running. It might have been as little as 3-4 hours.

This change on the cloud infrastructure is a step towards better security! Guessing that the integration does not attempt to get a new token – or that it chokes when the cloud infrastructure gives it {"status":"Service"},{"response":"Error"}.

Thinking that all you need to do is re-login and authenticate, and use the new auth token for all subsequent requests until the cloud requires re-authentication again?

Am I on the right track? I’ll have to use network analysis tools to confirm this hypothesis.

rcork commented 1 year ago

I noticed after enable debug logging that the integration was calling the aqualink API every 5 seconds. Even after just restarting HA, i would see that every few calls to the API would fail and i wondered if it was trying to call before the prior call had completed. Checking in const.py i see that the update interval is set to 15 seconds so it shouldn't update every 5 seconds. I manually changed the update interval in init.py and i'm not seeing the random connection errors. I'm going to let it run like this for the next 24 hours and see if still has an issue.

rcork commented 1 year ago

Well after just an hour, its not working again so the update interval isn't the issue. I did managed to hit the login REST API and in the response object, under the "UserPoolOAuth" section, along with the Access Token, there's a key called "ExpiresIn" and the value is set to 3600. Assuming this is likely seconds, that equates to 1 hour at which point the token expires. So it appears the fix is to reauthenticate every hour to refresh the access token.

devMarcus commented 1 year ago

Yep - that is what I thought.. Auth issue and that Jandy changed the token expiration to a shorter time where before it was a very long time. I would think that someone with python skills should be able to fix this - at least on a temporary basis to complete the proof of concept.

Curious - where are these files CONST.PY, etc located on the device?

Sent from my iPad

On Feb 20, 2023, at 2:44 PM, rcork @.***> wrote:



Well after just an hour, its not working again so the update interval isn't the issue. I did managed to hit the login REST API and in the response object, under the "UserPoolOAuth" section, along with the Access Token, there's a key called "ExpiresIn" and the value is set to 3600. Assuming this is likely seconds, that equates to 1 hour at which point the token expires. So it appears the fix is to reauthenticate every hour to refresh the access token.

— Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/88033#issuecomment-1437481273, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ARBHCMHGYMIXPQPJ5JNNQLTWYPCQBANCNFSM6AAAAAAU2XPYHU. You are receiving this because you were mentioned.Message ID: @.***>

rcork commented 1 year ago

I'm running in a docker image so it might be different but i found them under /usr/src/homeassistant/homeassistant/components/iaqualink

I'm editing the code directly to try to log back in when it gets the connection error. If that works i'll post back my results. I'm not great at python but know enough to hack my way around.

matthewhadley commented 1 year ago

The integration source code is here: https://github.com/home-assistant/core/tree/dev/homeassistant/components/iaqualink

The integration offloads the actual work for talking to the iaqualink API to this library: https://github.com/flz/iaqualink-py

Interestingly there is an open PR for refreshing the access token: https://github.com/flz/iaqualink-py/pull/19 But this was opened Feb '22, mentions an 8 hour expiry, and it's unclear if the PR works as intended.

matthewhadley commented 1 year ago

@rcork if it's easier you can create your own custom component - a copy of the existing iaqualink - using steps here: https://github.com/home-assistant/core/issues/82336#issuecomment-1383011017

gdoerr commented 1 year ago

I'm not sure if this was a change by Jandy or if it is the result of a change to use the httpx library. @flz mentioned something about that in some of the previous attempts to fix this.

In the mean time, I've been able to mitigate this by using an automation to have HA reload the configuration once an hour.

alias: Reload Jandy iAqualink every hour
description: ""
trigger:
  - platform: time_pattern
    hours: "*"
    minutes: "10"
    seconds: "0"
condition: []
action:
  - service: homeassistant.reload_config_entry
    data:
      entry_id: 78756025d03c7b811db07b8be7a9ed12
mode: single

I'm not sure if the config_entry_id is the same for everyone but you can find yours here.

ffpllc commented 1 year ago

That doesn't do the trick for me. When I reload the config entry all the iAqualink functions become unavailable in lovelace.


From: Greg Doerr @.> Sent: Monday, February 20, 2023 3:57 PM To: home-assistant/core @.> Cc: ffpllc @.>; Comment @.> Subject: Re: [home-assistant/core] Latest fix to IAquakink (2023.2.4) has not resolved issue (Issue #88033)

I'm not sure if this was a change by Jandy or if it is the result of a change to use the httpx library. @flzhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fflz&data=05%7C01%7C%7C4d5f16a1ff174f9497ef08db13852393%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638125234785438274%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=w3vFbXBJr3Xod1CxITHw3jeDFQ%2Fd6l%2Bbh4iziefI%2B6Q%3D&reserved=0 mentioned something about that in some of the previous attempts to fix this.

In the mean time, I've been able to mitigate this by have HA reload the configuration once an hour. `alias: Reload Jandy iAqualink every hour description: "" trigger:

I'm not sure if the config_entry_id is the same for everyone but you can find yours herehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.home-assistant.io%2Ft%2Fhow-to-find-config-entry-id-to-reload-via-service-call%2F451053%2F2&data=05%7C01%7C%7C4d5f16a1ff174f9497ef08db13852393%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638125234785438274%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=UsS56k02jVjNYo86l9qykjENR4TyE18Un2BYJ2fo4AQ%3D&reserved=0.

— Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fhome-assistant%2Fcore%2Fissues%2F88033%23issuecomment-1437535569&data=05%7C01%7C%7C4d5f16a1ff174f9497ef08db13852393%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638125234785594512%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=cdYfud%2BurO4d4CSW0XjkS73wIFXtNqYBhPxtkjVMLfI%3D&reserved=0, or unsubscribehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAXQVQUHSFA267OLBCNV6OQTWYPLFFANCNFSM6AAAAAAU2XPYHU&data=05%7C01%7C%7C4d5f16a1ff174f9497ef08db13852393%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638125234785594512%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=ty0yjc2Bw5j9PKayCcL2e0y5xs%2B3W%2FvxJr5K85BVw5s%3D&reserved=0. You are receiving this because you commented.Message ID: @.***>

smshapiro85 commented 1 year ago

I'm not sure if this was a change by Jandy or if it is the result of a change to use the httpx library. @flz mentioned something about that in some of the previous attempts to fix this.

In the mean time, I've been able to mitigate this by using an automation to have HA reload the configuration once an hour.

alias: Reload Jandy iAqualink every hour
description: ""
trigger:
  - platform: time_pattern
    hours: "*"
    minutes: "10"
    seconds: "0"
condition: []
action:
  - service: homeassistant.reload_config_entry
    data:
      entry_id: 78756025d03c7b811db07b8be7a9ed12
mode: single

I'm not sure if the config_entry_id is the same for everyone but you can find yours here.

Thank you I am going to try this out as well. My config_entry_id is different FWIW.

Also it looks like you have it set to refresh every 10 minutes? I am not really familiar with automations so maybe the "*" in the hours field means something different.

smshapiro85 commented 1 year ago

That doesn't do the trick for me. When I reload the config entry all the iAqualink functions become unavailable in lovelace. ____ From: Greg Doerr @.> Sent: Monday, February 20, 2023 3:57 PM To: home-assistant/core @.> Cc: ffpllc @.>; Comment @.> Subject: Re: [home-assistant/core] Latest fix to IAquakink (2023.2.4) has not resolved issue (Issue #88033) I'm not sure if this was a change by Jandy or if it is the result of a change to use the httpx library. @flzhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fflz&data=05%7C01%7C%7C4d5f16a1ff174f9497ef08db13852393%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638125234785438274%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=w3vFbXBJr3Xod1CxITHw3jeDFQ%2Fd6l%2Bbh4iziefI%2B6Q%3D&reserved=0 mentioned something about that in some of the previous attempts to fix this. In the mean time, I've been able to mitigate this by have HA reload the configuration once an hour. alias: Reload Jandy iAqualink every hour description: "" trigger: * platform: time_pattern hours: "*" minutes: "10" seconds: "0" condition: [] action: * service: homeassistant.reload_config_entry data: entry_id: 78756025d03c7b811db07b8be7a9ed12 mode: single I'm not sure if the config_entry_id is the same for everyone but you can find yours herehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.home-assistant.io%2Ft%2Fhow-to-find-config-entry-id-to-reload-via-service-call%2F451053%2F2&data=05%7C01%7C%7C4d5f16a1ff174f9497ef08db13852393%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638125234785438274%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=UsS56k02jVjNYo86l9qykjENR4TyE18Un2BYJ2fo4AQ%3D&reserved=0. — Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fhome-assistant%2Fcore%2Fissues%2F88033%23issuecomment-1437535569&data=05%7C01%7C%7C4d5f16a1ff174f9497ef08db13852393%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638125234785594512%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=cdYfud%2BurO4d4CSW0XjkS73wIFXtNqYBhPxtkjVMLfI%3D&reserved=0, or unsubscribehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAXQVQUHSFA267OLBCNV6OQTWYPLFFANCNFSM6AAAAAAU2XPYHU&data=05%7C01%7C%7C4d5f16a1ff174f9497ef08db13852393%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638125234785594512%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=ty0yjc2Bw5j9PKayCcL2e0y5xs%2B3W%2FvxJr5K85BVw5s%3D&reserved=0. You are receiving this because you commented.Message ID: @.***>

Yea unfortunately I am seeing the same thing.

gdoerr commented 1 year ago

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

devMarcus commented 1 year ago

Yes, the issue is due to expired token. Token now expires in 1 hour where before I recall it never expiring or not expiring for a very long time. A step in the right direction in terms of cloud security, but unfortunately breaks this code.

Today I restarted Home Assistant and at 18:03 the integration performed the https “post” to login to the cloud. Then it was able to perform periodic information polls to get pool information, and then at 19:03 it started erroring out because the cloud infrastructure is requiring re-authentication.

Appears that the integration does not know how to re-authenticate to get new token and go on its merry way.

Unfortunately, restarting the integration every 10 or 30 minutes does not work for me either.

Note: For those of you that are posting your log information. Be careful as it may contain your device serial number that is used as part of the cloud registration process to remotely control your pool.

Hoping that the author(s) of this integration can update to add the re-authentication steps once token is expired.

Thank you.

cryptomania135 commented 1 year ago

Is there anyway to donate to speed up the update? Like others, this is a core to my setup and would love to get it updated!!

chasut commented 1 year ago

Thank you for the reload automation, that is keeping things working well enough until we get a proper fix. For anyone else attempting to use that trick, you definitely need to dig into the .storage/core_config_entries file to get the entry_id. I think the odds of it being the same as the example posted are long at best, mine was certainly different.

yuckypants commented 1 year ago

@chasut & @gdoerr, thank you both. I saw @smshapiro85's reply saying it didn't work, so I didn't bother continuing. I just added the automation and will be watching to verify.

Is the 10 minutes required? Why not 30 mins if it times out every hour?

gdoerr commented 1 year ago

The automation as documented above, runs once an hour at 10 minutes past the top of the hour. I've been running this for several days and it's working fine. You could argue to have it run every 30 minutes but I'm going to leave it.

PRGeno commented 1 year ago

I have found 10 minutes to be too often for refreshing. There is short delay while it refreshes and with having it happen 6 times per hour there is a better chance an automation will trigger and fail right in the middle of that delay.

After some testing, in my case, refreshing every 59 minutes has proven to be the sweet spot as a much more reliable refresh cycle.

yuckypants commented 1 year ago

Oh! I misunderstood, I thought it was running once every 10 minutes. Thank you for the clarification.

yuckypants commented 1 year ago

So, it does not work for me. I manually triggered after a restart and everything just goes unavailable. I manually triggered by triggering the reload of the service via DevTools and watched it reset the service - and then crash. When I try to restart the integration, from DevTools, I get "Failed to call service homeassistant.reload_config_entry. The config entry (iaqualink with entry_id cannot be unloaded because it's not in a recoverable state (ConfigEntryState.FAILED_UNLOAD).

Yay. Oh well.

image

devMarcus commented 1 year ago

Guys –

Seems like a lot of screwing around – JUST because it doesn’t login when the token expires. Seems very silly!

If it was C# I would fix it. Since it is python, what can we do about it? Surely someone is able to fix this.

Trap the error, if error is because of token expired, then re-log in.. Can’t be that difficult!

chasut commented 1 year ago

Based upon that error, the error description, the config may be too far gone for this to work. I did get one of those on the first attempt I think. I would suggest doing a full system restart and then try again. Other than that, I always drop into YAML mode as I don't fully trust the UI version.

yuckypants commented 1 year ago

Thanks @chasut, but already tried both. Just hoping we have a fix soon - this is a relatively popular integration (#383 out of 978) with 226 installs, so I can't imagine it's going to be ignored.

Vortec4800 commented 1 year ago

Has anyone tried to run the code in the PR here? It should work in theory...

https://github.com/flz/iaqualink-py/pull/19

devMarcus commented 1 year ago

Yes, conceptually that is what should work. Now unfortunately I am not that familiar with python.. But now seeing the light… So not sure how all of the pieces need to fit together.

Out of respect for @FLZ and his code, don’t want to muck it up! I figure that he is not ignoring us, but we all know how life can get to anyone and make them busy.

Patiently waiting…



Has anyone tried to run the code in the PR here? It should work in theory...

flz/iaqualink-py#19https://github.com/flz/iaqualink-py/pull/19

— Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/88033#issuecomment-1439321580, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ARBHCMHZGDBV4V5Q3VE3OC3WYVVZJANCNFSM6AAAAAAU2XPYHU. You are receiving this because you were mentioned.Message ID: @.***>

Rampoozal commented 1 year ago

That PR is on the exo branch which I believe is not used in the current Home Assistant integration. I could be wrong but I think that is the case as I really want that exo functionality in HA.

flz commented 1 year ago

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...

smshapiro85 commented 1 year ago

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...

All good @flz we are cheering you on. Really appreciate the update.

devMarcus commented 1 year ago

Sure. We understand. We are in all of this together.

What are your thoughts in terms of uploading a fix? We will test for you.

….

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...

— Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/88033#issuecomment-1439402521, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ARBHCMADYTITSBGF4ZO5M3DWYWEUFANCNFSM6AAAAAAU2XPYHU. You are receiving this because you were mentioned.Message ID: @.**@.>>

bboi69 commented 1 year ago

I just setup an automation to reload Aqualink every 59 minutes. Hope it helps until there's a real fix.

wheindl commented 1 year ago

Yeah, I'm finding the same error. If I reboot Home Assistant, the iAqualink component works fine, but then stops working within a day or so.

In my own experience restarting HA solves it, but it breaks within a few minutes to a few hours.

devMarcus commented 1 year ago

@FLZ -

When do you think that you will be able to work on this? Trying to assess if we should wait until you are available, or if we should abandon and find alternative options?

I figure (not expert) that it should take you at most 1 to 2 hours to update the code to trap the error condition when the integration loses connection to the cloud due to the expired token and then re-authenticate.

Once this is done, then you will have to upload to github, but how does the fix then get downloaded to our machines? Does the fix have to depend on an update to Home Assistant? I think not, but more curious than anything in terms of next steps once you have addressed the issue.

Thank you.