Skip to content

Commit 930519d

Browse files
committed
Release 1.0.8
1 parent 8050d4a commit 930519d

4 files changed

Lines changed: 23 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## [1.0.8] (2022-11-21)
4+
### Fixed
5+
- "Failed to setup" error after upgrading to v1.0.7 (#37)
6+
37
## [1.0.7] (2022-11-20)
48
### Added
59
- Spanish and italian translations (#21)

custom_components/imou_life/__init__.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,28 @@ async def async_reload_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
129129
async def async_migrate_entry(hass, config_entry: ConfigEntry) -> bool:
130130
"""Migrate old entry."""
131131
_LOGGER.debug("Migrating from version %s", config_entry.version)
132+
data = {**config_entry.data}
133+
options = {**config_entry.options}
134+
unique_id = data[CONF_DEVICE_ID]
135+
132136
if config_entry.version == 1:
133-
data = {**config_entry.data}
134137
# add the api url. If in option, use it, otherwise use the default one
135138
option_api_url = config_entry.options.get(OPTION_API_URL, None)
136139
api_url = DEFAULT_API_URL if option_api_url is None else option_api_url
137140
data[CONF_API_URL] = api_url
138-
# set unique_id
139-
unique_id = data[CONF_DEVICE_ID]
140-
# update the config entry
141141
config_entry.version = 2
142-
hass.config_entries.async_update_entry(
143-
config_entry, data=data, unique_id=unique_id
144-
)
142+
143+
if config_entry.version == 2:
144+
# if api_url is empty, copy over the one in options
145+
if data[CONF_API_URL] == "":
146+
data[CONF_API_URL] = DEFAULT_API_URL
147+
if OPTION_API_URL in options:
148+
del options[OPTION_API_URL]
149+
config_entry.version = 3
150+
151+
# update the config entry
152+
hass.config_entries.async_update_entry(
153+
config_entry, data=data, options=options, unique_id=unique_id
154+
)
145155
_LOGGER.info("Migration to version %s successful", config_entry.version)
146156
return True

custom_components/imou_life/config_flow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
class ImouFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
3232
"""Config flow for imou."""
3333

34-
VERSION = 2
34+
VERSION = 3
3535
CONNECTION_CLASS = config_entries.CONN_CLASS_CLOUD_POLL
3636

3737
def __init__(self):

custom_components/imou_life/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
"config_flow": true,
88
"codeowners": ["@user2684"],
99
"requirements": ["imouapi==1.0.7"],
10-
"version": "1.0.7",
10+
"version": "1.0.8",
1111
"iot_class": "cloud_polling"
1212
}

0 commit comments

Comments
 (0)