thomluther / ha-anker-solix

Home Assistant integration for Anker Solix Power devices
MIT License
198 stars 5 forks source link

Ability to change the used account for present integrations #110

Closed nlincke closed 4 weeks ago

nlincke commented 1 month ago

Checklist

Is your feature request related to a problem? Please describe.

Not that i know of.

Describe the solution you'd like

In case a integration is already present, it would be great if i could replace the used account via the Integration settings ....

Describe alternatives you've considered

Deleting the integration and create a new one with the new account. I guess this could mean that the used entity IDs will be new one (at least if i create a new connection before i delete the present one).

Additional context

Nothing to add. Perhaps it could be an option within Configuration (Konfiguration): image

thomluther commented 1 month ago

Hi, there is no special way in HA to handle that. You cannot add a new account that shares devices with the existing one, this is checked and will cause an error.

In the backend, changing an existing account would be the same as deleting the existing configuration and create a new one with the new account because all entities have to be removed from registry and re-loaded from the new connection. When systems and devices are shared, the old entities will be re-used since the unique ID is composed out of the device SNs and Site ID, which will not change when switching accounts.

So you can safely delete the account, and create a new one. You old entities will be re-activated if data provided via the new account.

thomluther commented 1 month ago

Actually HA 2024.04 implemented a reconfiguration step for integrations: https://developers.home-assistant.io/blog/2024/03/21/config-entry-reconfigure-step/

Need to evaluate if that may be an option to change the account for a configuration entry. While it would simplify the user experience, it would have to do the same in the backend (unload the actual configuration and associated devices and entities and reload it with the new account if that is possible)

thomluther commented 4 weeks ago

Account reconfiguration capability added with release 2.1.0