|
10 | 10 | from enum import Enum |
11 | 11 |
|
12 | 12 | NUM_SCHEDULES = 12 |
13 | | -INTERVAL = 5 |
| 13 | +INTERVAL = 2 |
14 | 14 | SELLPOWER = -32000 |
15 | 15 | HUB4_SERVICE = 'com.victronenergy.hub4' |
16 | 16 |
|
@@ -60,7 +60,7 @@ def charge(self, flags, restrictions, rate, allow_feedin): |
60 | 60 | def discharge(self, flags, restrictions, rate, allow_feedin): |
61 | 61 | raise NotImplementedError("discharge") |
62 | 62 |
|
63 | | - def idle(self, allow_feedin): |
| 63 | + def idle(self, restrictions, allow_feedin): |
64 | 64 | raise NotImplementedError("idle") |
65 | 65 |
|
66 | 66 | def self_consume(self, restrictions, allow_feedin): |
@@ -177,21 +177,21 @@ def discharge(self, flags, restrictions, rate, allow_feedin): |
177 | 177 | self.monitor.set_value_async(HUB4_SERVICE, '/Overrides/MaxDischargePower', -1) |
178 | 178 | return rate |
179 | 179 |
|
180 | | - def idle(self, allow_feedin): |
| 180 | + def idle(self, restrictions, allow_feedin): |
181 | 181 | self._set_feedin(allow_feedin) |
182 | 182 | self._set_charge_power(None) |
183 | 183 | self.monitor.set_value_async(HUB4_SERVICE, '/Overrides/ForceCharge', 0) |
184 | 184 |
|
185 | | - if allow_feedin: |
| 185 | + # When idle only configure setpoint and maxDischarge overrides if consumption < pv. Otherwise, use standard ESS |
| 186 | + # (which is also quicker to react) to avoid importing when pv is lower, or consumption higher, than forecast. |
| 187 | + if allow_feedin and self.consumption < self.acpv + self.pvpower: |
186 | 188 | # This keeps battery idle by not allowing more power to be taken |
187 | 189 | # from the DC bus than what DC-coupled PV provides. |
188 | 190 | self.monitor.set_value_async(HUB4_SERVICE, '/Overrides/MaxDischargePower', |
189 | 191 | max(1.0, round(0.9*self.pvpower))) |
190 | 192 | self.monitor.set_value_async(HUB4_SERVICE, '/Overrides/Setpoint', self.maxfeedinpower) |
191 | 193 | else: |
192 | | - self.monitor.set_value_async(HUB4_SERVICE, '/Overrides/Setpoint', 0) # Normal ESS |
193 | | - self.monitor.set_value_async(HUB4_SERVICE, '/Overrides/MaxDischargePower', max(1.0, self.pvpower)) |
194 | | - |
| 194 | + self.self_consume(restrictions, allow_feedin) |
195 | 195 | return None |
196 | 196 |
|
197 | 197 | def self_consume(self, restrictions, allow_feedin): |
@@ -276,7 +276,7 @@ def discharge(self, flags, restrictions, rate, allow_feedin): |
276 | 276 |
|
277 | 277 | return rate |
278 | 278 |
|
279 | | - def idle(self, allow_feedin): |
| 279 | + def idle(self, restrictions, allow_feedin): |
280 | 280 | self.monitor.set_value_async(self.service, '/Ess/DisableFeedIn', int(not allow_feedin)) |
281 | 281 | self.monitor.set_value_async(self.service, '/Ess/UseInverterPowerSetpoint', 1) |
282 | 282 | self.monitor.set_value_async(self.service, '/Ess/InverterPowerSetpoint', -max(0, self.pvpower)) |
@@ -583,7 +583,7 @@ def bail(code): |
583 | 583 | # zone |
584 | 584 | self.discharge_hysteresis = 1 |
585 | 585 | self._dbusservice['/DynamicEss/ChargeRate'] = \ |
586 | | - self._device.idle(w.allow_feedin) |
| 586 | + self._device.idle(restrictions, w.allow_feedin) |
587 | 587 |
|
588 | 588 | break # out of for loop |
589 | 589 | else: |
|
0 commit comments