Skip to content

Commit

Permalink
Update status logic
Browse files Browse the repository at this point in the history
  • Loading branch information
fboundy committed Apr 3, 2024
1 parent 06eac09 commit 8a90d91
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions apps/pv_opt/solax.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,15 @@ def status(self):
status = self._solax_mode()

status["charge"] = self._solax_charge_periods()
status["charge"]["active"] = (
time_now >= status["charge"]["start"]
and time_now < status["charge"]["end"]
and status["charge"]["current"] > 0
and status["use_mode"]["Timed"] == "Force Time Use"
)
try:
status["charge"]["active"] = (
time_now >= status["charge"]["start"]
and time_now < status["charge"]["end"]
and status["charge"]["current"] > 0
and status["use_mode"]["Timed"] == "Force Time Use"
)
except:
status["charge"]["active"] = False

status["discharge"] = {
"start": midnight,
Expand All @@ -209,7 +212,7 @@ def _monitor_target_soc(self, target_soc, mode="charge"):
def _solax_mode(self, **kwargs):
if self.type == "SOLAX_X1":
return {
x: self.host.get_state(entity_id=self.host.config[f"id_{x}"])
x: self.host.get_state_retry(entity_id=self.host.config[f"id_{x}"])
for x in INVERTER_DEFS[self.type]["MODE_ITEMS"]
}

Expand All @@ -220,10 +223,10 @@ def _solax_charge_periods(self, **kwargs):
if self.type == "SOLAX_X1":
return {
limit: pd.Timestamp(
self.host.get_state(entity_id=self.host.config[f"id_charge_{limit}_time_1"]), tz=self.tz
self.host.get_state_retry(entity_id=self.host.config[f"id_charge_{limit}_time_1"]), tz=self.tz
)
for limit in LIMITS
} | {"current": self.host.get_state(entity_id=self.host.config[f"id_max_charge_current"])}
} | {"current": self.host.get_state_retry(entity_id=self.host.config[f"id_max_charge_current"])}

else:
self._unknown_inverter()

0 comments on commit 8a90d91

Please sign in to comment.