You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 47e9376
Browse filesBrowse the repository at this point in the historyBrowse files
fix(inverter): hard-raise when no charge window source is configured at all
Splits what update_status() previously collapsed into one "safe defaults,
retry next update" path, per maintainer review on #4288:
- REST configured (givtcp_rest) but rest_data hasn't returned anything yet
this cycle - genuinely transient (fetch hiccup, or before the first poll
on a fresh start), so still falls through to the graceful retry path.
- Neither a REST API nor charge_start_time configured at all - a permanent
setup gap, not something that resolves on its own. Retrying forever would
misrepresent a plan Predbat can't actually deliver, so this now raises a
ValueError with a proper message (unlike the original bare `raise
ValueError`) and records the error status before doing so.
Split into two tests: the existing no-source-configured test now expects
the raise, and a new test covers the REST-pending case staying graceful.
# Neither a data source nor a fallback config value is available - log the specific
1472
-
# reason here, but let the shared handling below (which also covers a source that
1473
-
# returned an unusable value) set the status entity and safe defaults, so this
1474
-
# doesn't hard-crash the whole plan for what may just be a temporarily empty feed.
1475
-
self.log("Error: Inverter {} unable to read charge window time as neither REST, charge_start_time or charge_start_hour are set".format(self.id))
1470
+
elifself.rest_api:
1471
+
# A REST data source (givtcp_rest) is configured but hasn't returned anything this
1472
+
# cycle - genuinely transient (a fetch hiccup, or before the first poll on a fresh
1473
+
# start, e.g. GivEnergy cloud "no devices"), so fall through to the same safe-defaults/
1474
+
# retry-next-update handling below as a configured-but-currently-unusable value,
1475
+
# rather than crashing the whole plan for something that should resolve itself.
1476
1476
charge_start_time=None
1477
1477
charge_end_time=None
1478
+
else:
1479
+
# Neither a REST API nor a charge_start_time config value is configured at all - a
1480
+
# permanent setup gap, not something that will resolve on its own. Retrying every
1481
+
# cycle forever would be misleading, so don't pretend to make a plan Predbat can't
1482
+
# actually deliver (maintainer call on #4288/#4179 - see PR review discussion).
1483
+
message="Error: Inverter {} unable to read charge window time as neither REST, charge_start_time or charge_start_hour are set".format(self.id)
1484
+
self.log(message)
1485
+
self.base.record_status(message, had_errors=True)
1486
+
raiseValueError(message)
1478
1487
1479
1488
ifcharge_start_timeisNoneorcharge_end_timeisNone:
1480
1489
self.log("Warn: Inverter {} unable to read charge window time as charge_start_time or charge_end_time is None, will retry next update".format(self.id))
0 commit comments