Skip to content

Commit f132c4b

Browse files
authored
Merge pull request #114 from explosivo22/dev
Config Flow Migration
2 parents 3d5bbae + 1d028ae commit f132c4b

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

custom_components/rinnaicontrolr-ha/__init__.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,21 @@ async def async_remove_config_entry_device(
8383
) -> bool:
8484
"""Remove a config entry from a device."""
8585
return True
86+
87+
async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry):
88+
"""Migrate old entry."""
89+
_LOGGER.debug("Migrating from version %s", config_entry.version)
90+
91+
if config_entry.version == 1:
92+
data = {**config_entry.data}
93+
94+
if not data.get(CONF_ACCESS_TOKEN):
95+
data[CONF_ACCESS_TOKEN] = config_entry.data[CONF_REFRESH_TOKEN]
96+
if not data.get(CONF_REFRESH_TOKEN):
97+
data[CONF_REFRESH_TOKEN] = config_entry.data[CONF_REFRESH_TOKEN]
98+
99+
hass.config_entries.async_update_entry(config_entry, data=data, version=2)
100+
101+
_LOGGER.info("Migration to version %s successful", config_entry.version)
102+
103+
return True

custom_components/rinnaicontrolr-ha/config_flow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
2424
"""Handle a config flow for Rinnai."""
2525

26-
VERSION = 1
26+
VERSION = 2
2727

2828
entry: config_entries.ConfigEntry | None
2929

custom_components/rinnaicontrolr-ha/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
"documentation": "https://github.com/explosivo22/rinnaicontrolr-ha/",
66
"codeowners": [ "@explosivo22" ],
77
"requirements": [ "aiorinnai==0.4.0a2" ],
8-
"version": "1.5.4",
8+
"version": "1.5.5",
99
"iot_class": "cloud_polling"
1010
}

0 commit comments

Comments
 (0)