Skip to content

Commit

Permalink
Change order of force discharge to try to avoid grid spike (#1274)
Browse files Browse the repository at this point in the history
* Change order of force discharge to try to avoid grid spike

* Bump version
  • Loading branch information
springfall2008 authored Jun 30, 2024
1 parent b552905 commit a9ed7f8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
22 changes: 12 additions & 10 deletions apps/predbat/inverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1609,6 +1609,12 @@ def adjust_force_discharge(self, force_discharge, new_start_time=None, new_end_t
if not force_discharge:
self.adjust_inverter_mode(force_discharge)

# Turn off scheduled discharge
if not force_discharge and old_discharge_enable:
if not SIMULATE:
self.write_and_poll_switch("scheduled_discharge_enable", self.base.get_arg("scheduled_discharge_enable", indirect=False, index=self.id), False)
self.log("Inverter {} Turning off scheduled discharge".format(self.id))

self.base.log("Inverter {} Adjust force discharge to {}, change times from {} - {} to {} - {}".format(self.id, force_discharge, old_start, old_end, new_start, new_end))
changed_start_end = False

Expand Down Expand Up @@ -1671,22 +1677,18 @@ def adjust_force_discharge(self, force_discharge, new_start_time=None, new_end_t
entity_id = self.base.get_arg("charge_discharge_update_button", indirect=False, index=self.id)
self.press_and_poll_button(entity_id)

# Change scheduled discharge enable
if force_discharge and not old_discharge_enable:
if not SIMULATE:
self.write_and_poll_switch("scheduled_discharge_enable", self.base.get_arg("scheduled_discharge_enable", indirect=False, index=self.id), True)
self.log("Inverter {} Turning on scheduled discharge".format(self.id))
elif not force_discharge and old_discharge_enable:
if not SIMULATE:
self.write_and_poll_switch("scheduled_discharge_enable", self.base.get_arg("scheduled_discharge_enable", indirect=False, index=self.id), False)
self.log("Inverter {} Turning off scheduled discharge".format(self.id))

# REST version of writing slot
if self.rest_data and new_start and new_end and ((new_start != old_start) or (new_end != old_end)):
changed_start_end = True
if not SIMULATE:
self.rest_setDischargeSlot1(new_start, new_end)

# Change scheduled discharge enable
if force_discharge and not old_discharge_enable:
if not SIMULATE:
self.write_and_poll_switch("scheduled_discharge_enable", self.base.get_arg("scheduled_discharge_enable", indirect=False, index=self.id), True)
self.log("Inverter {} Turning on scheduled discharge".format(self.id))

# Force discharge, turn it on after we change the window
if force_discharge:
self.adjust_inverter_mode(force_discharge, changed_start_end=changed_start_end)
Expand Down
2 changes: 1 addition & 1 deletion apps/predbat/predbat.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import asyncio
import json

THIS_VERSION = "v8.2.1"
THIS_VERSION = "v8.2.2"
PREDBAT_FILES = ["predbat.py", "config.py", "prediction.py", "utils.py", "inverter.py", "ha.py", "download.py", "unit_test.py"]
from download import predbat_update_move, predbat_update_download, check_install

Expand Down

0 comments on commit a9ed7f8

Please sign in to comment.