Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions apps/predbat/predbat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
)
Expand Down