Skip to content

Commit

Permalink
Add migration handler
Browse files Browse the repository at this point in the history
If migrating the configuration from version 1, then prompt the user to
reconfigure using API keys as username/password are no longer supported.
  • Loading branch information
danelphick authored and nathanmarlor committed Feb 28, 2024
1 parent 84bab16 commit b8b8dbf
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions custom_components/foxess_em/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,17 @@ async def async_reload_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
async def options_update_listener(hass: HomeAssistant, config_entry: ConfigEntry):
"""Handle options update."""
await hass.config_entries.async_reload(config_entry.entry_id)


async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
"""Handle migration from earlier configuration options."""
version = config_entry.version

if version == 1:
# Migrate from username/password to API keys.
_LOGGER.warning(
"FoxESS Energy Management can no longer access foxesscloud.com using a username and password.\r\nPlease reconfigure using API keys."
)
return False

return True

0 comments on commit b8b8dbf

Please sign in to comment.