Add Blink config migration (#46671)

This commit is contained in:
Kevin Fronczak 2021-03-23 04:24:42 -04:00 committed by GitHub
parent fb03d79daf
commit 8900b38c7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View File

@ -67,11 +67,15 @@ async def async_setup(hass, config):
async def async_migrate_entry(hass, entry):
"""Handle migration of a previous version config entry."""
_LOGGER.debug("Migrating from version %s", entry.version)
data = {**entry.data}
if entry.version == 1:
data.pop("login_response", None)
await hass.async_add_executor_job(_reauth_flow_wrapper, hass, data)
return False
if entry.version == 2:
await hass.async_add_executor_job(_reauth_flow_wrapper, hass, data)
return False
return True
@ -148,7 +152,7 @@ async def async_unload_entry(hass, entry):
return True
hass.services.async_remove(DOMAIN, SERVICE_REFRESH)
hass.services.async_remove(DOMAIN, SERVICE_SAVE_VIDEO_SCHEMA)
hass.services.async_remove(DOMAIN, SERVICE_SAVE_VIDEO)
hass.services.async_remove(DOMAIN, SERVICE_SEND_PIN)
return True

View File

@ -44,7 +44,7 @@ def _send_blink_2fa_pin(auth, pin):
class BlinkConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
"""Handle a Blink config flow."""
VERSION = 2
VERSION = 3
CONNECTION_CLASS = config_entries.CONN_CLASS_CLOUD_POLL
def __init__(self):

View File

@ -273,7 +273,7 @@ async def test_options_flow(hass):
data={"username": "blink@example.com", "password": "example"},
options={},
entry_id=1,
version=2,
version=3,
)
config_entry.add_to_hass(hass)