Skip to content

Commit bf252c0

Browse files
authored
Merge pull request #99 from plugwise/async_entry_update
Avoid BREAKING unique_id change
2 parents 1069d30 + 47f887e commit bf252c0

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

custom_components/plugwise-beta/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ async def async_update_data():
101101

102102
_LOGGER.debug("Async update interval %s", update_interval)
103103

104+
# Migrate to new unique_id's when needed
105+
if api.smile_version[0] == "2.5.9":
106+
if entry.unique_id is None:
107+
hass.config_entries.async_update_entry(
108+
entry, unique_id=entry.data[api.gateway_id]
109+
)
110+
elif entry.unique_id == api.gateway_id:
111+
hass.config_entries.async_update_entry(
112+
entry, unique_id=entry.data[api.hostname]
113+
)
114+
104115
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = {
105116
"api": api,
106117
"coordinator": coordinator,

0 commit comments

Comments
 (0)