Skip to content

Commit

Permalink
Add migration
Browse files Browse the repository at this point in the history
  • Loading branch information
SukramJ committed Aug 31, 2024
1 parent 3ad0737 commit bcf80ed
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions custom_components/homematicip_local/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,5 +200,11 @@ def del_param(name: str) -> None:
instance_name=entry.data["instance_name"], storage_folder=get_storage_folder(hass=hass)
)
hass.config_entries.async_update_entry(entry, version=5, data=data)
if entry.version == 5:
data = dict(entry.data)
cleanup_cache_dirs(
instance_name=entry.data["instance_name"], storage_folder=get_storage_folder(hass=hass)
)
hass.config_entries.async_update_entry(entry, version=6, data=data)
_LOGGER.info("Migration to version %s successful", entry.version)
return True
2 changes: 1 addition & 1 deletion custom_components/homematicip_local/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ async def _async_validate_config_and_get_system_information(
class DomainConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle the instance flow for Homematic(IP) Local."""

VERSION = 5
VERSION = 6
CONNECTION_CLASS = CONN_CLASS_LOCAL_PUSH

def __init__(self) -> None:
Expand Down
6 changes: 3 additions & 3 deletions custom_components/homematicip_local/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
BASE_SCHEMA_DEVICE.extend(
{
vol.Optional(CONF_CHANNEL): vol.Coerce(int),
vol.Required(CONF_PARAMSET_KEY): vol.In(["MASTER", "VALUES"]),
vol.Required(CONF_PARAMSET_KEY): vol.All(cv.string, vol.Upper),
}
),
)
Expand Down Expand Up @@ -161,7 +161,7 @@
BASE_SCHEMA_DEVICE.extend(
{
vol.Optional(CONF_CHANNEL): vol.Coerce(int),
vol.Required(CONF_PARAMSET_KEY): vol.In(["MASTER", "VALUES"]),
vol.Required(CONF_PARAMSET_KEY): vol.All(cv.string, vol.Upper),
vol.Required(CONF_PARAMSET): dict,
vol.Optional(CONF_WAIT_FOR_CALLBACK): cv.positive_int,
vol.Optional(CONF_RX_MODE): vol.All(cv.string, vol.Upper),
Expand Down Expand Up @@ -453,7 +453,7 @@ async def _async_service_fetch_system_variables(hass: HomeAssistant, service: Se
async def _async_service_put_paramset(hass: HomeAssistant, service: ServiceCall) -> None:
"""Service to call the putParamset method on a Homematic(IP) Local connection."""
channel_no = service.data.get(CONF_CHANNEL)
paramset_key = ParamsetKey(service.data[CONF_PARAMSET_KEY])
paramset_key = service.data[CONF_PARAMSET_KEY]
# When passing in the paramset from a YAML file we get an OrderedDict
# here instead of a dict, so add this explicit cast.
# The service schema makes sure that this cast works.
Expand Down

0 comments on commit bcf80ed

Please sign in to comment.