Skip to content

Commit

Permalink
Added new option to config flow
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsK1 committed Dec 1, 2024
1 parent 3db328e commit 279bb1f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
7 changes: 7 additions & 0 deletions custom_components/solvis_control/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
CONF_OPTION_2,
CONF_OPTION_3,
CONF_OPTION_4,
CONF_OPTION_5,
POLL_RATE_SLOW,
POLL_RATE_DEFAULT,
CONF_OPTION_5,
)
from .coordinator import SolvisModbusCoordinator

Expand Down Expand Up @@ -139,6 +141,11 @@ async def async_migrate_entry(hass, config_entry: ConfigEntry):
if POLL_RATE_SLOW not in new_data:
new_data[POLL_RATE_SLOW] = 300
current_minor_version = 4
if config_entry.minor_version < 5:
_LOGGER.info(f"Migrating from version {config_entry.version}_{config_entry.minor_version}")
if CONF_OPTION_5 not in new_data:
new_data[CONF_OPTION_5] = False
current_minor_version = 5
hass.config_entries.async_update_entry(
config_entry,
data=new_data,
Expand Down
7 changes: 5 additions & 2 deletions custom_components/solvis_control/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
CONF_OPTION_2,
CONF_OPTION_3,
CONF_OPTION_4,
CONF_OPTION_5,
DEVICE_VERSION,
POLL_RATE_DEFAULT,
POLL_RATE_SLOW,
Expand Down Expand Up @@ -68,6 +69,7 @@ def get_solvis_modules(data: ConfigType) -> Schema:
vol.Required(CONF_OPTION_2, default=False): bool, # HKR 3
vol.Required(CONF_OPTION_3, default=False): bool, # solar collectors
vol.Required(CONF_OPTION_4, default=False): bool, # heat pump
vol.Required(CONF_OPTION_5, default=False): bool, # room temperature
}
)

Expand All @@ -90,6 +92,7 @@ def get_solvis_modules_options(data: ConfigType) -> Schema:
vol.Required(CONF_OPTION_2, default=data.get(CONF_OPTION_2, False)): bool, # HKR 3
vol.Required(CONF_OPTION_3, default=data.get(CONF_OPTION_3, False)): bool, # solar collectors
vol.Required(CONF_OPTION_4, default=data.get(CONF_OPTION_4, False)): bool, # heat pump
vol.Required(CONF_OPTION_5, default=data.get(CONF_OPTION_5, False)): bool, # room temperature
}
)

Expand All @@ -116,7 +119,7 @@ def get_host_schema_options(data: ConfigType) -> Schema:

class SolvisConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
VERSION = 1
MINOR_VERSION = 4
MINOR_VERSION = 5

def __init__(self) -> None:
"""Init the ConfigFlow."""
Expand Down Expand Up @@ -169,7 +172,7 @@ def async_get_options_flow(

class SolvisOptionsFlow(config_entries.OptionsFlow):
VERSION = 1
MINOR_VERSION = 4
MINOR_VERSION = 5

def __init__(self, config) -> None:
"""Init the ConfigFlow."""
Expand Down
1 change: 1 addition & 0 deletions custom_components/solvis_control/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
CONF_OPTION_2 = "HKR3" # HKR 3
CONF_OPTION_3 = "solar collector" # Solar collector
CONF_OPTION_4 = "heat pump" # heat pump
CONF_OPTION_5 = "room temperature" # room temperature

DATA_COORDINATOR = "coordinator"
MANUFACTURER = "Solvis"
Expand Down
6 changes: 4 additions & 2 deletions custom_components/solvis_control/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"hkr2":"HKR 2",
"hkr3":"HKR 3",
"solar collector":"Solar Kollektoren",
"heat pump":"Wärmepumpe"
"heat pump":"Wärmepumpe",
"room temperature": "Schreiben der Raumtemperatursensoren"
}
}
},
Expand Down Expand Up @@ -64,7 +65,8 @@
"hkr2":"HKR 2",
"hkr3":"HKR 3",
"solar collector":"Solar Kollektoren",
"heat pump":"Wärmepumpe"
"heat pump":"Wärmepumpe",
"room temperature": "Schreiben der Raumtemperatursensoren"
}
}
},
Expand Down
6 changes: 4 additions & 2 deletions custom_components/solvis_control/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"hkr2":"HKR 2",
"hkr3":"HKR 3",
"solar collector":"Solar Kollektoren",
"heat pump":"Wärmepumpe"
"heat pump":"Wärmepumpe",
"room temperature": "Schreiben der Raumtemperatursensoren"
}
}
},
Expand Down Expand Up @@ -64,7 +65,8 @@
"hkr2":"HKR 2",
"hkr3":"HKR 3",
"solar collector":"Solar Kollektoren",
"heat pump":"Wärmepumpe"
"heat pump":"Wärmepumpe",
"room temperature": "Schreiben der Raumtemperatursensoren"
}
}
},
Expand Down

0 comments on commit 279bb1f

Please sign in to comment.