Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion custom_components/diveracontrol/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,26 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->
"Failed to remove old entity registry entries during migration"
)

# v1.2.1: no migration needed
# v1.2.1: add new base_url parameter to config entry
if VERSION == 1 and MINOR_VERSION == 2 and PATCH_VERSION == 1:
_LOGGER.info(
"Migrating config entry to version %s.%s.%s",
VERSION,
MINOR_VERSION,
PATCH_VERSION,
)

if D_BASE_API_URL not in config_entry.data:
_LOGGER.info("Adding base_url to existing config entry")

hass.config_entries.async_update_entry(
config_entry,
data={
**config_entry.data,
D_BASE_API_URL: "https://api.divera247.com",
},
version=VERSION,
minor_version=MINOR_VERSION,
)

return True
7 changes: 3 additions & 4 deletions tests/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ async def test_reconfigure(
from custom_components.diveracontrol.const import (
D_UPDATE_INTERVAL_ALARM,
D_UPDATE_INTERVAL_DATA,
D_BASE_API_URL,
)

# Add the existing config entry to hass
Expand Down Expand Up @@ -270,10 +271,8 @@ async def test_reconfigure(
assert updated_entry.data[D_API_KEY] == new_api_key
assert updated_entry.data[D_UPDATE_INTERVAL_DATA] == new_interval_data
assert updated_entry.data[D_UPDATE_INTERVAL_ALARM] == new_interval_alarm

# Properly unload the entry to clean up timers
await hass.config_entries.async_unload(mock_config_entry.entry_id)
await hass.async_block_till_done()
# Verify base_url is present from migration
assert D_BASE_API_URL in updated_entry.data


async def test_reconfigure_entry_not_found(hass: HomeAssistant) -> None:
Expand Down
Loading