mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-07-14 19:34:29 +02:00
Added config entry migration for SSL Verify option
This commit is contained in:
parent
8e68931e57
commit
6f888a5c08
2 changed files with 30 additions and 6 deletions
|
@ -3,23 +3,24 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
import logging
|
||||||
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers import device_registry
|
from homeassistant.helpers import device_registry
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
|
||||||
from .const import (
|
from homeassistant.const import CONF_VERIFY_SSL
|
||||||
PLATFORMS,
|
|
||||||
DOMAIN,
|
from .const import PLATFORMS, DOMAIN, RUN_SCRIPT_COMMAND, DEFAULT_VERIFY_SSL
|
||||||
RUN_SCRIPT_COMMAND,
|
|
||||||
)
|
|
||||||
from .coordinator import MikrotikData, MikrotikCoordinator, MikrotikTrackerCoordinator
|
from .coordinator import MikrotikData, MikrotikCoordinator, MikrotikTrackerCoordinator
|
||||||
|
|
||||||
SCRIPT_SCHEMA = vol.Schema(
|
SCRIPT_SCHEMA = vol.Schema(
|
||||||
{vol.Required("router"): cv.string, vol.Required("script"): cv.string}
|
{vol.Required("router"): cv.string, vol.Required("script"): cv.string}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# async_setup_entry
|
# async_setup_entry
|
||||||
|
@ -77,3 +78,26 @@ async def async_remove_config_entry_device(
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Remove a config entry from a device."""
|
"""Remove a config entry from a device."""
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------
|
||||||
|
# async_migrate_entry
|
||||||
|
# ---------------------------
|
||||||
|
async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry):
|
||||||
|
_LOGGER.debug(
|
||||||
|
"Migrating configuration from version %s.%s",
|
||||||
|
config_entry.version,
|
||||||
|
config_entry.minor_version,
|
||||||
|
)
|
||||||
|
|
||||||
|
if config_entry.version < 2:
|
||||||
|
new_data = {**config_entry.data}
|
||||||
|
new_data[CONF_VERIFY_SSL] = DEFAULT_VERIFY_SSL
|
||||||
|
hass.config_entries.async_update_entry(config_entry, data=new_data, version=2)
|
||||||
|
|
||||||
|
_LOGGER.debug(
|
||||||
|
"Migration to configuration version %s.%s successful",
|
||||||
|
config_entry.version,
|
||||||
|
config_entry.minor_version,
|
||||||
|
)
|
||||||
|
return True
|
||||||
|
|
|
@ -86,7 +86,7 @@ def configured_instances(hass):
|
||||||
class MikrotikControllerConfigFlow(ConfigFlow, domain=DOMAIN):
|
class MikrotikControllerConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""MikrotikControllerConfigFlow class"""
|
"""MikrotikControllerConfigFlow class"""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 2
|
||||||
CONNECTION_CLASS = CONN_CLASS_LOCAL_POLL
|
CONNECTION_CLASS = CONN_CLASS_LOCAL_POLL
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue