jonasbkarlsson / ev_smart_charging

Electric vehicle smart charging for Home Assistant.
MIT License
162 stars 25 forks source link

Home assistant crash when try to reconfigure the integration #297

Closed Perimec closed 1 month ago

Perimec commented 1 month ago

Version of the custom_component

Version V1.11.0

Configuration

Basic configuration with VW id connect car and Easee charger

Describe the bug

I initially set up the main integration parameter. However, I after decided to change the charging controller from the EV to the charger. I tried twice and every time after the change, when I tried to save the modification, the entire HA system crashed.

Debug log

Add your logs here.

tobiasnorbo commented 1 month ago

The same hoppens to me. Trying to change the SoC configuration and then HA crashes. Wanted to upload the debug log, but my HA instance is still down.

corvy commented 1 month ago

Same happens to me. Crash HA core when clicking on reconfigure. To fix I need to ssh into HA and restart core

ha core restart

I am on supervised HA running on Proxmox, HA version 2024.7.3.

Here are some logs:


2024-07-26 10:10:47.264 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry EV SC Eneren for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 130, in async_setup_entry
    return await component.async_setup_entry(entry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 184, in async_setup_entry
    raise ValueError(
ValueError: Config entry EV SC Eneren (01J3Q0X65V5ZQZ17QEQVMGAQ3F) for ev_smart_charging.sensor has already been setup!
2024-07-26 10:10:47.265 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry EV SC Eneren for switch
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/switch/__init__.py", line 92, in async_setup_entry
    return await component.async_setup_entry(entry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 184, in async_setup_entry
    raise ValueError(
ValueError: Config entry EV SC Eneren (01J3Q0X65V5ZQZ17QEQVMGAQ3F) for ev_smart_charging.switch has already been setup!
2024-07-26 10:10:47.265 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry EV SC Eneren for button
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/button/__init__.py", line 67, in async_setup_entry
    return await component.async_setup_entry(entry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 184, in async_setup_entry
    raise ValueError(
ValueError: Config entry EV SC Eneren (01J3Q0X65V5ZQZ17QEQVMGAQ3F) for ev_smart_charging.button has already been setup!
2024-07-26 10:10:47.266 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry EV SC Eneren for number
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/number/__init__.py", line 128, in async_setup_entry
    return await component.async_setup_entry(entry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 184, in async_setup_entry
    raise ValueError(
ValueError: Config entry EV SC Eneren (01J3Q0X65V5ZQZ17QEQVMGAQ3F) for ev_smart_charging.number has already been setup!
2024-07-26 10:10:47.267 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry EV SC Eneren for select
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/select/__init__.py", line 103, in async_setup_entry
    return await component.async_setup_entry(entry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 184, in async_setup_entry
    raise ValueError(
ValueError: Config entry EV SC Eneren (01J3Q0X65V5ZQZ17QEQVMGAQ3F) for ev_smart_charging.select has already been setup!
2024-07-26 10:10:47.268 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry EV SC Eneren for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 130, in async_setup_entry
    return await component.async_setup_entry(entry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 184, in async_setup_entry
    raise ValueError(
ValueError: Config entry EV SC Eneren (01J3Q0X65V5ZQZ17QEQVMGAQ3F) for ev_smart_charging.sensor has already been setup!
2024-07-26 10:10:47.269 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry EV SC Eneren for switch
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/switch/__init__.py", line 92, in async_setup_entry
    return await component.async_setup_entry(entry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 184, in async_setup_entry
    raise ValueError(
ValueError: Config entry EV SC Eneren (01J3Q0X65V5ZQZ17QEQVMGAQ3F) for ev_smart_charging.switch has already been setup!
2024-07-26 10:10:47.270 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry EV SC Eneren for button
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/button/__init__.py", line 67, in async_setup_entry
    return await component.async_setup_entry(entry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 184, in async_setup_entry
    raise ValueError(
ValueError: Config entry EV SC Eneren (01J3Q0X65V5ZQZ17QEQVMGAQ3F) for ev_smart_charging.button has already been setup!
2024-07-26 10:10:47.271 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry EV SC Eneren for number
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/number/__init__.py", line 128, in async_setup_entry
    return await component.async_setup_entry(entry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 184, in async_setup_entry
    raise ValueError(
ValueError: Config entry EV SC Eneren (01J3Q0X65V5ZQZ17QEQVMGAQ3F) for ev_smart_charging.number has already been setup!
2024-07-26 10:10:47.272 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry EV SC Eneren for select
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/select/__init__.py", line 103, in async_setup_entry
    return await component.async_setup_entry(entry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 184, in async_setup_entry
    raise ValueError(
ValueError: Config entry EV SC Eneren (01J3Q0X65V5ZQZ17QEQVMGAQ3F) for ev_smart_charging.select has already been setup!
2024-07-26 10:10:47.273 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry EV SC Eneren for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
jonasbkarlsson commented 1 month ago

That doesn't sound good... There seems to be some changes in HA 2024.7 that affects things. If anyone of you have the possibility to roll-back to HA 2024.6, and check if things work, that would be great.

Also strange that an integration can crash the whole HA...

corvy commented 1 month ago

I have a demo install, and I just upgraded that to 2024.6.3 and installed both nordpool and EV Smart Charge. Set up two dummy helpers for SOC and SOC Target. Worked just fine. Upgraded to 2024.7.3 and still it works... very strange. Not able to reproduce the bug.

Do you think this could be related to the DB upgrades done in 2024.7.x series? It was implemented from 2024.7.1 and 2024.7.2. See here: https://github.com/home-assistant/core/pull/120779

I believe this was mostly relevant for old installs that got issues, due to a very old database schema. My install is quite old and has been upgraded for at least the last 3 or 4 years. @Perimec and @tobiasnorbo, how old are your installs?

corvy commented 1 month ago

Just managed to provoke it on my test setup. Seems it happens when I try to change the name of the integration. Will downgrade and test again.

corvy commented 1 month ago

Ok, I have now downgraded to 2024.6.3 and here it works fine, in 2024.7.0 it fails (and all versions thereafter). To trigger the error just try to rename the integration. Logs from my demo install (version 2024.7.0):

2024-07-29 12:07:02.654 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Charger Smart for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 130, in async_setup_entry
    return await component.async_setup_entry(entry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 184, in async_setup_entry
    raise ValueError(
ValueError: Config entry Charger Smart (57008a1e234ac9205306bbb22c3ced1f) for ev_smart_charging.sensor has already been setup!
2024-07-29 12:07:02.655 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Charger Smart for switch
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/switch/__init__.py", line 92, in async_setup_entry
    return await component.async_setup_entry(entry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 184, in async_setup_entry
    raise ValueError(
ValueError: Config entry Charger Smart (57008a1e234ac9205306bbb22c3ced1f) for ev_smart_charging.switch has already been setup!
2024-07-29 12:07:02.656 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Charger Smart for button
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/button/__init__.py", line 67, in async_setup_entry
    return await component.async_setup_entry(entry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 184, in async_setup_entry
    raise ValueError(
ValueError: Config entry Charger Smart (57008a1e234ac9205306bbb22c3ced1f) for ev_smart_charging.button has already been setup!
2024-07-29 12:07:02.657 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Charger Smart for number
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/number/__init__.py", line 128, in async_setup_entry
    return await component.async_setup_entry(entry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 184, in async_setup_entry
    raise ValueError(
ValueError: Config entry Charger Smart (57008a1e234ac9205306bbb22c3ced1f) for ev_smart_charging.number has already been setup!
2024-07-29 12:07:02.658 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Charger Smart for select
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I know the bug linked above was introduced in 2024.7.0 and a fix was implemented in 2024.7.2, but that seems to not help for this integration. Please see also here: https://github.com/home-assistant/core/issues/117263#issuecomment-2197311144. For me it sounds likely that this is related.

jonasbkarlsson commented 1 month ago

I have tested a bit, and can recreate the issue by either changing the configuration or by changing the name of the device. Either of those will trigger a re-creation of the device. And that doesn't seem to work for HA 2024.7

jonasbkarlsson commented 1 month ago

I know the bug linked above was introduced in 2024.7.0 and a fix was implemented in 2024.7.2, but that seems to not help for this integration. Please see also here: home-assistant/core#117263 (comment). For me it sounds likely that this is related.

@corvy, I don't see the relation between the two issues? How does the recreatation of a device relate to the recorder?

corvy commented 1 month ago

Because several other integrations had recorder issues on 2024.7.

More info here: https://community.home-assistant.io/t/psa-2024-7-recorder-problems/746428

jonasbkarlsson commented 1 month ago

I think this is different.

Anyhow, I will make v1.11.1 release soon, that will remove the possibility to reconfigure a device for HA 2024.7. And then I need to find a soluton for reconfiguration. I might have implemented it in a way (using Options Flow) that is not according to the way one should do...

Anyone who knows about an integration that supports reconfiguration and works with HA 2024.7?

I guess this is what one should do: https://developers.home-assistant.io/docs/config_entries_config_flow_handler/#reconfigure

jonasbkarlsson commented 1 month ago

Now made a v1.11.1 that will disable reconfiguration for HA 2024.7.

jonasbkarlsson commented 1 month ago

In release v1.11.2, reconfiguration for HA 2024.7 has been fixed. So now everything should be ok, I hope.

Perimec commented 1 month ago

That is perfect. I will try it asap and let u know. Thanks again for the support and for this super integration!On 2 Aug 2024, at 11:20, Jonas Karlsson @.***> wrote: In release v1.11.2, reconfiguration for HA 2024.7 has been fixed. So now everything should be ok, I hope.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

corvy commented 1 month ago

Confirm it is fixed. :) Thanks!