From e8db97127d177ee50407fcf2b141cf7b455aed02 Mon Sep 17 00:00:00 2001 From: Trefor Southwell <48591903+springfall2008@users.noreply.github.com> Date: Sat, 8 Jun 2024 16:18:52 +0100 Subject: [PATCH] Fix for restart losing config entities (#1192) * Fix for restart losing config entities * [pre-commit.ci lite] apply automatic fixes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> --- apps/predbat/predbat.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/predbat/predbat.py b/apps/predbat/predbat.py index 0441e350..054dc06e 100644 --- a/apps/predbat/predbat.py +++ b/apps/predbat/predbat.py @@ -36,7 +36,7 @@ if not "PRED_GLOBAL" in globals(): PRED_GLOBAL = {} -THIS_VERSION = "v7.22.3" +THIS_VERSION = "v7.22.4" PREDBAT_FILES = ["predbat.py"] TIME_FORMAT = "%Y-%m-%dT%H:%M:%S%z" TIME_FORMAT_SECONDS = "%Y-%m-%dT%H:%M:%S.%f%z" @@ -15037,6 +15037,7 @@ def load_user_config(self, quiet=True, register=False): Load config from HA """ self.config_index = {} + self.log("Refreshing Predbat configuration") # New install, used to set default of expert mode new_install = True @@ -15112,7 +15113,7 @@ def load_user_config(self, quiet=True, register=False): if item.get("manual"): self.manual_times(name, new_value=ha_value) else: - self.expose_config(item["name"], ha_value, quiet=quiet) + self.expose_config(item["name"], ha_value, quiet=quiet, force=True) # Update the last time we refreshed the config self.set_state_wrapper(entity_id=self.prefix + ".config_refresh", state=self.now_utc.strftime(TIME_FORMAT)) @@ -15667,6 +15668,7 @@ def update_states(self): return res = self.api_call("/api/states") if res: + self.state_data = {} for item in res: self.update_state_item(item) else: