Skip to content

Commit

Permalink
Improve version handling on config entry migration
Browse files Browse the repository at this point in the history
  • Loading branch information
dext0r committed Apr 27, 2024
1 parent 227dedd commit 00792a4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions custom_components/yandex_smart_home/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import logging

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import EVENT_HOMEASSISTANT_STOP, SERVICE_RELOAD
from homeassistant.const import EVENT_HOMEASSISTANT_STOP, MAJOR_VERSION, MINOR_VERSION, SERVICE_RELOAD
from homeassistant.core import Event, HomeAssistant, callback
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.aiohttp_client import async_get_clientsession
Expand Down Expand Up @@ -251,8 +251,13 @@ async def async_remove_entry(hass: HomeAssistant, entry: ConfigEntry):
await delete_cloud_instance(hass, entry)


async def async_migrate_entry(_: HomeAssistant, entry: ConfigEntry) -> bool:
entry.version = 1
async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
if int(MAJOR_VERSION) < 2024 or (int(MAJOR_VERSION) == 2024 and int(MINOR_VERSION) < 4):
entry.version = 1
hass.config_entries.async_update_entry(entry)
else:
hass.config_entries.async_update_entry(entry, version=1)

return True


Expand Down

0 comments on commit 00792a4

Please sign in to comment.