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

Solax remains in initialization on reboot #99421

Closed
DeltaFox0018 opened this issue Aug 31, 2023 · 8 comments
Closed

Solax remains in initialization on reboot #99421

DeltaFox0018 opened this issue Aug 31, 2023 · 8 comments

Comments

@DeltaFox0018
Copy link

The problem

When I run the server restart, the Solax integration stays in the initialization state and then goes to error
I am forced to deactivate it, restart the server and reactivate it

What version of Home Assistant Core has the issue?

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

solax

Link to integration documentation on our website

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

Diagnostics information

home-assistant_solax_2023-08-31T19-08-13.872Z.log

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2023-08-31 21:07:50.843 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry AA292C39 for solax
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 388, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/solax/__init__.py", line 18, in async_setup_entry
    api = await real_time_api(
          ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/solax/__init__.py", line 35, in real_time_api
    i = await discover(ip_address, port, pwd)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/solax/discovery.py", line 102, in discover
    await discover_state.discover(host, port, pwd)
  File "/usr/local/lib/python3.11/site-packages/solax/discovery.py", line 81, in discover
    await asyncio.sleep(0.5)
  File "/usr/local/lib/python3.11/asyncio/tasks.py", line 639, in sleep
    return await future
           ^^^^^^^^^^^^
asyncio.exceptions.CancelledError: Global task timeout
2023-08-31 21:07:50.855 WARNING (MainThread) [homeassistant.bootstrap] Setup timed out for stage 2 - moving forward
2023-08-31 21:07:52.825 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback DiscoveryState._task_handler(<Task finishe...imeoutError()>)
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/local/lib/python3.11/site-packages/solax/discovery.py", line 57, in _task_handler
    result = task.result()
             ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/solax/discovery.py", line 69, in _discovery_task
    await i.get_data()
  File "/usr/local/lib/python3.11/site-packages/solax/inverter.py", line 61, in get_data
    data = await self.make_request()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/solax/inverter.py", line 75, in make_request
    raw_response = await self.http_client.request()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/solax/inverter_http_client.py", line 55, in request
    return await self.post()
           ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/solax/inverter_http_client.py", line 70, in post
    async with session.post(url, headers=self.headers, data=data) as req:
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 1141, in __aenter__
    self._resp = await self._coro
                 ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 560, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 894, in start
    with self._timer:
  File "/usr/local/lib/python3.11/site-packages/aiohttp/helpers.py", line 721, in __exit__
    raise asyncio.TimeoutError from None
TimeoutError
2023-08-31 21:07:52.841 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback DiscoveryState._task_handler(<Task finishe...imeoutError()>)
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/local/lib/python3.11/site-packages/solax/discovery.py", line 57, in _task_handler
    result = task.result()
             ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/solax/discovery.py", line 69, in _discovery_task
    await i.get_data()
  File "/usr/local/lib/python3.11/site-packages/solax/inverter.py", line 61, in get_data
    data = await self.make_request()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/solax/inverter.py", line 75, in make_request
    raw_response = await self.http_client.request()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/solax/inverter_http_client.py", line 55, in request
    return await self.post()
           ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/solax/inverter_http_client.py", line 70, in post
    async with session.post(url, headers=self.headers, data=data) as req:
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 1141, in __aenter__
    self._resp = await self._coro
                 ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 560, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 894, in start
    with self._timer:
  File "/usr/local/lib/python3.11/site-packages/aiohttp/helpers.py", line 721, in __exit__
    raise asyncio.TimeoutError from None
TimeoutError

Additional information

No response

@home-assistant
Copy link

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

Code owner commands

Code owners of solax can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign solax Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


solax documentation
solax source
(message by IssueLinks)

@greengumbyaus
Copy link

I've been getting this bug for a few months as well. Once it has timed out and failed at start up, going into devices and running a reload typically brings it up for me.

@DeltaFox0018
Copy link
Author

Hi @greengumbyaus , I tried it too but it didn't work, the only way I found working is just deactivate the component, reboot and then when finished reactivate it

@issue-triage-workflows
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@ha-bnst
Copy link

ha-bnst commented Dec 11, 2023

The issue still exists.

@github-actions github-actions bot removed the stale label Dec 11, 2023
@greengumbyaus
Copy link

Can also confirm this still exists, upgrade from 2023.12.0 to 2023.12.1 and had to manually reload the solax integration after the initial timeout.

@brew-your-own
Copy link

The discovery code in the upstream library is most likely at fault.
see squishykid/solax#107

For some reason, some inverters fail / crash when getting hit by multiple query attempts, which is what the discovery code does: it tries all the variants in turn. If your inverter is far down the list (like the X1HybridGen4) it will get hit multiple times with invalid requests and may start timing out.

The hack to make this go away is to modify the integration code to try your particular inverter first. You need to modify solax/discovery.py in HA's site-packages directory and change the order of the REGISTRY array.
A better fix would be to modify the home assistant integration to make it possible to bypass the discovery code and configure directly the inverter model.

@brew-your-own
Copy link

See more details here as well #66617
Many of the issues that are currently open against this integration can be traced back to the discovery approach.

brew-your-own added a commit to brew-your-own/solax that referenced this issue Jan 21, 2024
in the case where the Inverter type is already known.

Some inverters at the end of the REGISTRY (e.g. X1HybridGen4) randomly
crash because the discovery code issues too many incorrect requests
before sending the correct one.
This patch adds a variant of the entry point in which one can specify
the name of the inverter type.

This addresses home-assistant/core#66617
and home-assistant/core#99421
@github-actions github-actions bot locked and limited conversation to collaborators Feb 10, 2024
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

4 participants