Add Reset learned model to Configure
Configure now opens a menu: Settings (the previous form) or Reset learned model. After an explicit confirmation the entry is unloaded, the learned parts of the stored model (zone, extended and ventilation coefficients, models kept for removed zones, Model Error and Forecast Error statistics, fingerprints) are removed under the storage lock, and the entry is set up again. Configuration, heat-source baselines and the window event log are kept, and model_changes records the reset. Unloading first means no update still running can write the old model back. English and Romanian strings; the gust hint now refers to Model Error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
28ff953ddd
commit
49565d610a
8 files changed
+174
-12
No files matched your search
@@ -23,6 +23,7 @@ from .heat_sources import (
|
||||
SOURCE_KEY, SOURCE_NAME, SOURCE_RESPONSE, SOURCE_SENSOR, SOURCE_ZONE, SUBENTRY_HEAT_SOURCE,
|
||||
HeatSource, build_sources, validate_source,
|
||||
)
|
||||
from .coordinator import async_reset_learned_model
|
||||
from .weather_sources import sources_for
|
||||
from .windows import (
|
||||
DEFAULT_AZIMUTH, OPENING_RANGE, SUBENTRY_WINDOW, WINDOW_AZIMUTH, WINDOW_ENABLED, WINDOW_INVERTED,
|
||||
@@ -205,6 +206,9 @@ class HeatingMPCConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
SUBENTRY_WINDOW: WindowSubentryFlow}
|
||||
|
||||
|
||||
CONFIRM_RESET = "confirm_reset"
|
||||
|
||||
|
||||
class HeatingMPCOptionsFlow(config_entries.OptionsFlow):
|
||||
"""Edit sensors, ranked alternative weather providers and MPC parameters."""
|
||||
|
||||
@@ -215,13 +219,26 @@ class HeatingMPCOptionsFlow(config_entries.OptionsFlow):
|
||||
return [sensor for zone in entry_zones(self.config_entry) for sensor in zone.sensors]
|
||||
|
||||
async def async_step_init(self, user_input: dict[str, Any] | None = None):
|
||||
return self.async_show_menu(step_id="init", menu_options=["settings", "reset_model"])
|
||||
|
||||
async def async_step_settings(self, user_input: dict[str, Any] | None = None):
|
||||
config = {**self.config_entry.data, **self.config_entry.options}
|
||||
if user_input is not None:
|
||||
self._draft = user_input
|
||||
return await self.async_step_weather()
|
||||
return self.async_show_form(step_id="init", data_schema=_main_schema(
|
||||
return self.async_show_form(step_id="settings", data_schema=_main_schema(
|
||||
config, detailed=True))
|
||||
|
||||
async def async_step_reset_model(self, user_input: dict[str, Any] | None = None):
|
||||
"""Forget the learned model after an explicit confirmation; settings stay."""
|
||||
if user_input is not None:
|
||||
if user_input.get(CONFIRM_RESET) is not True:
|
||||
return self.async_abort(reason="model_not_reset")
|
||||
await async_reset_learned_model(self.hass, self.config_entry)
|
||||
return self.async_abort(reason="model_reset")
|
||||
return self.async_show_form(step_id="reset_model", data_schema=vol.Schema(
|
||||
{vol.Required(CONFIRM_RESET, default=False): selector.BooleanSelector()}))
|
||||
|
||||
async def async_step_weather(self, user_input: dict[str, Any] | None = None):
|
||||
config = {**self.config_entry.data, **self.config_entry.options, **self._draft}
|
||||
if user_input is not None:
|
||||
|
||||
Reference in new issue
Block a user