Skip to content

Commit

Permalink
config_flow.py version up.
Browse files Browse the repository at this point in the history
__init__.py update migration.

Signed-off-by: [email protected] <[email protected]>
  • Loading branch information
sca075 committed Apr 19, 2024
1 parent fbb68fb commit 45a1c41
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 24 additions & 0 deletions custom_components/valetudo_vacuum_camera/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ async def async_migrate_entry(hass, config_entry: config_entries.ConfigEntry):
hass.config_entries.async_update_entry(
config_entry, data=new_data, options=new_options
)

if config_entry.version == 2.4:
_LOGGER.debug(
"Starting migration data from .storage to valetudo_camera folder."
Expand All @@ -217,6 +218,29 @@ async def async_migrate_entry(hass, config_entry: config_entries.ConfigEntry):
hass.config_entries.async_update_entry(
config_entry, data=new_data, options=old_options
)

if config_entry.version == 3.0:
if not os.path.exists(
os.path.join(hass.config.path(STORAGE_DIR), "valetudo_camera")
):
await move_data_to_valetudo_camera(hass.config.path(STORAGE_DIR))
old_data = {**config_entry.data}
new_data = {"vacuum_config_entry": old_data["vacuum_config_entry"]}
_LOGGER.debug(dict(new_data))
old_options = {**config_entry.options}
if len(old_options) != 0:
tmp_option = {
"offset_top": 0,
"offset_bottom": 0,
"offset_left": 0,
"offset_right": 0,
}
new_options = await update_options(old_options, tmp_option)
_LOGGER.debug(f"migration data:{dict(new_options)}")
config_entry.version = 3.1
hass.config_entries.async_update_entry(
config_entry, data=new_data, options=new_options
)
else:
_LOGGER.error(
"Please REMOVE and SETUP the Camera again. Error in migration process!!"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/valetudo_vacuum_camera/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@


class ValetudoCameraFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
VERSION = 3.0
VERSION = 3.1

def __init__(self):
self.data = {}
Expand Down

0 comments on commit 45a1c41

Please sign in to comment.