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
74.19k stars 31.15k forks source link

Issue with SMA integration, [pysma] Could not start session: Max amount of sessions reached #125346

Open filip-heens opened 2 months ago

filip-heens commented 2 months ago

The problem

Hi, One of my 2 SMA converters won't connect after restart And the logs redirect me to the core to submit a report?

What could be the problem? The second Converter works fine. PS, it's been already a few months that I have this problem, but I didn't have time to open a case

What version of Home Assistant Core has the issue?

core-2024.9.0

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

SMA

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2024-09-05 17:09:38.773 ERROR (MainThread) [pysma] Could not start session: Max amount of sessions reached
2024-09-05 17:09:38.773 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry 192.168.x.x for sma
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 604, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sma/__init__.py", line 55, in async_setup_entry
    sma_device_info = await sma.device_info()
                      ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pysma/__init__.py", line 370, in device_info
    await self.read(self._device_info_sensors)
  File "/usr/local/lib/python3.12/site-packages/pysma/__init__.py", line 303, in read
    result_body = await self._read_body(URL_VALUES, payload)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pysma/__init__.py", line 211, in _read_body
    await self.new_session()
  File "/usr/local/lib/python3.12/site-packages/pysma/__init__.py", line 275, in new_session
    raise SmaAuthenticationException()
pysma.exceptions.SmaAuthenticationException
2024-09-05 17:10:10.996 WARNING (Recorder) [homeassistant.components.sensor.recorder] Entity sensor.xxxxxxx_total_consumption_current_hour from integration smappee has state class total_increasing, but its state is negative. Triggered by state -19 with last_updated set to 2024-09-05T15:08:53.332705+00:00. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+smappee%22
2024-09-05 17:10:10.997 WARNING (Recorder) [homeassistant.components.sensor.recorder] Entity sensor.xxxxxxx_total_consumption_last_5_minutes from integration smappee has state class total_increasing, but its state is negative. Triggered by state -19 with last_updated set to 2024-09-05T15:08:53.337505+00:00. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+smappee%22
2024-09-05 17:10:10.997 WARNING (Recorder) [homeassistant.components.sensor.recorder] Entity sensor.xxxxxxx_always_on_today from integration smappee has state class total_increasing, but its state is negative. Triggered by state -13064 with last_updated set to 2024-09-05T15:04:59.999999+00:00. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+smappee%22

Additional information

No response

home-assistant[bot] commented 2 months ago

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

Code owner commands Code owners of `sma` 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 sma` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


sma documentation sma source (message by IssueLinks)

laurentclaus commented 2 months ago

Hi Filip, I just experienced the same problem. I switched off and on again the 230V side of my SMA converter (via the fuse) and the HA integration started working again. I suspect that with each HA restart a new session to the SMA is opened (until max number of sessions reached) and that the power switch off kills all the cumulated open sessions. Hope this could work for you too.

dreamar99 commented 1 month ago

Hello. I have the same problem with the maximum number of connections. I have already restarted the inverter. Now it happens every day. I don't want to restart the inverter every day.

Thebivere commented 4 weeks ago

Hi, I've been experiencing the same issue for about a month. Is there a way to close the connection when restarting Home Assistant so that sessions don’t stay open? Restarting the inverter each time isn't an ideal solution.