From acf3e946a604cc1d4357766f20707059d1573606 Mon Sep 17 00:00:00 2001 From: Trefor Southwell <48591903+springfall2008@users.noreply.github.com> Date: Mon, 15 Jan 2024 19:16:39 +0000 Subject: [PATCH 1/2] Fix issue where inverter skew is falsely reported --- apps/predbat/predbat.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/predbat/predbat.py b/apps/predbat/predbat.py index cfd1bd38a..916924431 100644 --- a/apps/predbat/predbat.py +++ b/apps/predbat/predbat.py @@ -18,7 +18,7 @@ import os import yaml -THIS_VERSION = "v7.14.43" +THIS_VERSION = "v7.14.44" TIME_FORMAT = "%Y-%m-%dT%H:%M:%S%z" TIME_FORMAT_SECONDS = "%Y-%m-%dT%H:%M:%S.%f%z" TIME_FORMAT_OCTOPUS = "%Y-%m-%d %H:%M:%S%z" @@ -837,19 +837,23 @@ def __init__(self, base, id=0, quiet=False): # Check inverter time and confirm skew if self.inverter_time: - tdiff = self.inverter_time - self.base.now_utc + # Fetch current time again as it may have changed since we run this inverter update + local_tz = pytz.timezone(self.base.get_arg("timezone", "Europe/London")) + now_utc = datetime.now(local_tz) + + tdiff = self.inverter_time - now_utc tdiff = self.base.dp2(tdiff.seconds / 60 + tdiff.days * 60 * 24) if not quiet: - self.base.log("Invertor time {} AppDaemon time {} difference {} minutes".format(self.inverter_time, self.base.now_utc, tdiff)) + self.base.log("Invertor time {} AppDaemon time {} difference {} minutes".format(self.inverter_time, now_utc, tdiff)) if abs(tdiff) >= 5: self.base.log( "WARN: Invertor time is {} AppDaemon time {} this is {} minutes skewed, Predbat may not function correctly, please fix this by updating your inverter or fixing AppDaemon time zone".format( - self.inverter_time, self.base.now_utc, tdiff + self.inverter_time, now_utc, tdiff ) ) self.base.record_status( "Invertor time is {} AppDaemon time {} this is {} minutes skewed, Predbat may not function correctly, please fix this by updating your inverter or fixing AppDaemon time zone".format( - self.inverter_time, self.base.now_utc, tdiff + self.inverter_time, now_utc, tdiff ), had_errors=True, ) @@ -10772,4 +10776,4 @@ def run_time_loop_balance(self, cb_args): except Exception as e: self.log("ERROR: Exception raised {}".format(e)) self.record_status("ERROR: Exception raised {}".format(e)) - raise + raise \ No newline at end of file From e993cdbac60d80d799c39bb484c947eec8136f60 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Mon, 15 Jan 2024 19:17:55 +0000 Subject: [PATCH 2/2] [pre-commit.ci lite] apply automatic fixes --- apps/predbat/predbat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/predbat/predbat.py b/apps/predbat/predbat.py index 916924431..fd585d102 100644 --- a/apps/predbat/predbat.py +++ b/apps/predbat/predbat.py @@ -10776,4 +10776,4 @@ def run_time_loop_balance(self, cb_args): except Exception as e: self.log("ERROR: Exception raised {}".format(e)) self.record_status("ERROR: Exception raised {}".format(e)) - raise \ No newline at end of file + raise