Bump config version to 2 for AVM Fritz Tools (#51176)

This commit is contained in:
Michael 2021-05-28 11:12:46 +02:00 committed by GitHub
parent 538a03ee0c
commit d200f1e504
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View File

@ -3,6 +3,10 @@ import logging
from fritzconnection.core.exceptions import FritzConnectionException, FritzSecurityError
from homeassistant.components.device_tracker.const import (
CONF_CONSIDER_HOME,
DEFAULT_CONSIDER_HOME,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
CONF_HOST,
@ -63,6 +67,22 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
return True
async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
"""Migrate config entry."""
_LOGGER.debug("Migrating from version %s", config_entry.version)
if config_entry.version == 1:
config_entry.version = 2
hass.config_entries.async_update_entry(
config_entry,
options={CONF_CONSIDER_HOME: DEFAULT_CONSIDER_HOME.total_seconds()},
)
_LOGGER.info("Migration to version %s successful", config_entry.version)
return True
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload FRITZ!Box Tools config entry."""
fritzbox: FritzBoxTools = hass.data[DOMAIN][entry.entry_id]

View File

@ -38,7 +38,7 @@ _LOGGER = logging.getLogger(__name__)
class FritzBoxToolsFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a FRITZ!Box Tools config flow."""
VERSION = 1
VERSION = 2
@staticmethod
@callback