Skip to content

Commit

Permalink
Fix config migration
Browse files Browse the repository at this point in the history
  • Loading branch information
FL550 committed Oct 9, 2024
1 parent 9e1fa64 commit 86c93e0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
17 changes: 16 additions & 1 deletion custom_components/dwd_weather/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
CONF_ENTITY_TYPE_STATION,
CONF_HOURLY_UPDATE,
CONF_INTERPOLATE,
CONF_MAP_HOMEMARKER_COLOR,
CONF_MAP_HOMEMARKER_SHAPE,
CONF_MAP_HOMEMARKER_SHAPE_CIRCLE,
CONF_MAP_HOMEMARKER_SIZE,
CONF_MAP_LOOP_COUNT,
CONF_MAP_LOOP_SPEED,
CONF_MAP_CENTERMARKER,
Expand Down Expand Up @@ -167,7 +171,18 @@ def update_unique_id(entity_entry):
elif config_entry.version == 7:
new = {**config_entry.data}
new[CONF_MAP_HOMEMARKER] = False
hass.config_entries.async_update_entry(config_entry, data=new, version=8)
new[CONF_MAP_HOMEMARKER_SHAPE] = CONF_MAP_HOMEMARKER_SHAPE_CIRCLE
new[CONF_MAP_HOMEMARKER_SIZE] = 15
new[CONF_MAP_HOMEMARKER_COLOR] = [255, 0, 0]
# Skip version 8 as some already have this config with an error. Version 9 is correct
hass.config_entries.async_update_entry(config_entry, data=new, version=9)
elif config_entry.version == 8:
new = {**config_entry.data}
# If someone is on version 8, add the missing config items.
new[CONF_MAP_HOMEMARKER_SHAPE] = CONF_MAP_HOMEMARKER_SHAPE_CIRCLE
new[CONF_MAP_HOMEMARKER_SIZE] = 15
new[CONF_MAP_HOMEMARKER_COLOR] = [255, 0, 0]
hass.config_entries.async_update_entry(config_entry, data=new, version=9)

_LOGGER.info("Migration to version %s successful", config_entry.version)
return True
Expand Down
2 changes: 1 addition & 1 deletion custom_components/dwd_weather/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Base component constants
NAME = "DWD Weather"
DOMAIN = "dwd_weather"
CONF_VERSION = 8
CONF_VERSION = 9
ATTRIBUTION = "Data provided by Deutscher Wetterdienst (DWD)"
# Platforms
PLATFORMS = [
Expand Down
2 changes: 1 addition & 1 deletion custom_components/dwd_weather/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"domain": "dwd_weather",
"version": "2.1.14",
"version": "2.1.15",
"name": "Deutscher Wetterdienst (DWD)",
"documentation": "https://github.com/FL550/dwd_weather",
"issue_tracker": "https://github.com/FL550/dwd_weather/issues",
Expand Down

0 comments on commit 86c93e0

Please sign in to comment.