Skip to content

Commit

Permalink
Update deprecated version update on migrate rospogrigio#224
Browse files Browse the repository at this point in the history
  • Loading branch information
xZetsubou committed May 5, 2024
1 parent ec11471 commit 9a06d88
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions custom_components/localtuya/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry):
if config_entry.version == 1:
# This an old version of original integration no nned to put it here.
pass
# Update to version 3
if config_entry.version == 2:
# Switch config flow to selectors convert DP IDs from int to str require HA 2022.4.
_LOGGER.debug("Migrating config entry from version %s", config_entry.version)
Expand All @@ -206,8 +207,8 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry):
ent_items[k] = str(v) if type(v) is int else v
new_data[CONF_DEVICES][device][CONF_ENTITIES][i].update(ent_items)
i = i + 1
config_entry.version = 3
hass.config_entries.async_update_entry(config_entry, data=new_data)
hass.config_entries.async_update_entry(config_entry, data=new_data, version=3)
# Update to version 4
if config_entry.version <= 3:
# Convert values and friendly name values to dict.
from .const import (
Expand Down Expand Up @@ -284,8 +285,7 @@ def convert_str_to_dict(list1: str, list2: str = ""):
new_entity_data
)
current_entity += 1
config_entry.version = 4
hass.config_entries.async_update_entry(config_entry, data=new_data)
hass.config_entries.async_update_entry(config_entry, data=new_data, version=4)

_LOGGER.info(
"Entry %s successfully migrated to version %s.",
Expand Down

0 comments on commit 9a06d88

Please sign in to comment.