Skip to content

Commit

Permalink
Huawei (#738)
Browse files Browse the repository at this point in the history
* Huawei inverter updates to check service settings
* Update predbat.py - add power to service call

---------

Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
  • Loading branch information
springfall2008 and pre-commit-ci-lite[bot] authored Feb 7, 2024
1 parent 53d9f47 commit e22cab9
Showing 1 changed file with 31 additions and 9 deletions.
40 changes: 31 additions & 9 deletions apps/predbat/predbat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2493,23 +2493,46 @@ def adjust_charge_immediate(self, target_soc):
"""
if self.inv_has_service_api:
if target_soc > 0:
self.log("Inverter {} Starting charge to {} % via Service".format(self.id, target_soc))
self.base.call_service(self.base.get_arg("charge_start_service"), device_id=self.base.get_arg("device_id", index=self.id), target_soc=target_soc)
service = self.base.get_arg("charge_start_service", "")
if service:
self.base.log("Inverter {} Starting charge to {} % via Service {}".format(self.id, target_soc, service))
self.base.call_service(
service, device_id=self.base.get_arg("device_id", index=self.id, default=""), target_soc=target_soc, power=int(self.battery_rate_max_charge * MINUTE_WATT)
)
else:
self.log("WARN: Inverter {} unable to start charge as charge_start_service not set in apps.yaml".format(self.id))
else:
self.log("Inverter {} Stop charge via Service".format(self.id))
self.base.call_service(self.base.get_arg("charge_stop_service"), device_id=self.base.get_arg("device_id", index=self.id))
service = self.base.get_arg("charge_stop_service", "")
if service:
self.base.log("Inverter {} Stop charge via Service {}".format(self.id, service))
self.base.call_service(service, device_id=self.base.get_arg("device_id", index=self.id, default=""))
else:
self.log("WARN: Inverter {} unable to stop charge as charge_stop_service not set in apps.yaml".format(self.id))

def adjust_discharge_immediate(self, target_soc):
"""
Adjust from discharging or not discharging based on passed target soc
"""
if self.inv_has_service_api:
if target_soc > 0:
self.log("Inverter {} Starting discharge to {} % via Service".format(self.id, target_soc))
self.base.call_service(self.base.get_arg("discharge_start_service"), device_id=self.base.get_arg("device_id", index=self.id), target_soc=target_soc)
service = self.base.get_arg("discharge_start_service", "")
if service:
self.log("Inverter {} Starting discharge to {} % via Service {}".format(self.id, target_soc, service))
self.base.call_service(
service,
device_id=self.base.get_arg("device_id", index=self.id, default=""),
target_soc=target_soc,
power=int(self.battery_rate_max_discharge * MINUTE_WATT),
)
else:
self.log("WARN: Inverter {} unable to start discharge as discharge_start_service not set in apps.yaml".format(self.id))
else:
self.log("Inverter {} Stop discharge via Service".format(self.id))
self.base.call_service(self.base.get_arg("charge_stop_service", device_id=self.base.get_arg("device_id", index=self.id)))
service = self.base.get_arg("charge_stop_service", "")
if service:
self.base.log("Inverter {} Stop charge via Service {}".format(self.id, service))
self.base.call_service(service, device_id=self.base.get_arg("device_id", index=self.id, default=""))
else:
self.log("WARN: Inverter {} unable to stop charge as charge_stop_service not set in apps.yaml".format(self.id))

def adjust_charge_window(self, charge_start_time, charge_end_time, minutes_now):
"""
Expand Down Expand Up @@ -9968,7 +9991,6 @@ def execute_plan(self):
if self.set_discharge_freeze:
# In discharge freeze mode we disable charging during discharge slots
inverter.adjust_charge_rate(0)

# Immediate discharge mode
inverter.adjust_discharge_immediate(self.discharge_limits_best[0])
else:
Expand Down

0 comments on commit e22cab9

Please sign in to comment.