Skip to content

Commit

Permalink
added pvcontrol to pvstatus.json
Browse files Browse the repository at this point in the history
  • Loading branch information
StefaE committed Jan 6, 2022
1 parent 3a26db3 commit 36908a6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 20 deletions.
55 changes: 36 additions & 19 deletions PVControl/pvcontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,37 +137,38 @@ def runControl(self, _pvstatus = None, _pvforecast = None, _carstatus = None):
minsoc : float, range 0 .. 1
lowest value for SOC sliders
"""
self.pvforecast = _pvforecast
wallbox = WallBoxFactory()
if _pvstatus is None: # ----------------------------------------------------- we need get life PV status data
pvmonitor = PVMonitorFactory()
self.inverter = pvmonitor.getPVMonitor(self.monitorProvider, self.config)
self.pvstatus = self.inverter.getStatus()
self.wallbox = wallbox.getWallBox(self.wallboxProvider, self.config)
self.pvforecast = _pvforecast
wallbox = WallBoxFactory()
if _pvstatus is None: # --------------------------------------------------- we need get life PV status data
pvmonitor = PVMonitorFactory()
self.inverter = pvmonitor.getPVMonitor(self.monitorProvider, self.config)
self.pvstatus = self.inverter.getStatus()
self.wallbox = wallbox.getWallBox(self.wallboxProvider, self.config)
self.wallbox.readWB(self.persist['charge_completed'])
if self.wallbox.status is not None:
ctrl_power = self._I_to_P(self.wallbox.status['ctrl_current'])
ctrl_power = self._I_to_P(self.wallbox.status['ctrl_current'])
if self.I_min is None or self.I_min < self.wallbox.status['I_min']: self.I_min = self.wallbox.status['I_min']
if self.I_max is None or self.I_max > self.wallbox.status['I_max']: self.I_max = self.wallbox.status['I_max']
else:
ctrl_power = self.persist['ctrl_power'] # fall-back
self.currTime = self.pvstatus.name
ctrl_power = self.persist['ctrl_power'] # fall-back
self.currTime = self.pvstatus.name
if self.pvforecast is None:
forecastObj = PVForecast(self.config)
self.pvforecast = forecastObj.getForecast(self.pvstatus.name)
active = True # we are in active mode, actually controlling wallbox
forecastObj = PVForecast(self.config)
self.pvforecast = forecastObj.getForecast(self.pvstatus.name)
active = True # we are in active mode, actually controlling wallbox

else: # ----------------------------------------------------- running in simulation mode
self.pvstatus = _pvstatus
self.wallbox = wallbox.getWallBox('dummy', self.config)
self.pvstatus = _pvstatus
self.wallbox = wallbox.getWallBox('dummy', self.config)
self.wallbox.status.update(_carstatus)
self.currTime = self.pvstatus.name # time of last PV status
ctrl_power = self.persist['ctrl_power']
self.currTime = self.pvstatus.name # time of last PV status
ctrl_power = self.persist['ctrl_power']
if self.I_min is None: self.I_min = self.wallbox.status['I_min'] # fall-back values
if self.I_max is None: self.I_max = self.wallbox.status['I_max']
active = False
active = False

self.I_min = self.wallbox.round_current(self.I_min)
self.I_min = self.wallbox.round_current(self.I_min)
self.sysstatus['pvcontrol'] = self._getPVControl()
if self.persist['saved'].year > 1970:
delta_t = (self.currTime - self.persist['saved']).total_seconds()/60
if delta_t > 10: self._initPersist() # file is older than 10 minutes, re-inialize
Expand Down Expand Up @@ -451,3 +452,19 @@ def _logInflux(self):
pass
except Exception as e:
print('pvcontrol._logInflux: ' + str(e))

def _getPVControl(self):
"""
get PVControl settings for sysstatus (as later used by GUI)
"""

pvcontrol = { "I_min" : self.I_min,
"I_max" : self.I_max,
"I_gridMax" : self.I_gridMax,

"minSOC" : self.minSOC,
"minSOCCharge" : self.minSOCCharge,
"maxSOCCharge" : self.maxSOCCharge,
"maxSOC" : self.maxSOC
}
return pvcontrol
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ In the [above example](#ev-excess-charging-example), we have seen how, on a sunn
| minSOCCharge | Home battery is charged to at least this level prior to EV charging to start. This has two reasons: (a) one may want to give priority to home battery charging with `minSOCCarge` = 100%. Then, EV charging starts once this SOC level is reached. (b) during EV excess charging, home battery can support short shadow periods. However, support is programmed to be dependent on SOC level to avoid too heavy battery cycling. Hence, one may choose to have battery at least 50% full before EV charging starts. (For the same reason, the home battery is charged at maximum rate if an EV is plugged in, but power is insufficient to start charging) |
| maxSOCCharge | prior to EV charging being completed, home battery will not be charged above this level. Purpose to keep some battery capacity available in case EV charging finishes early and PV power would otherwise run into grid feed-in limits. |
| I_gridMax | maximum grid power to be used for EV charging. If set to 0A, only PV excess charging is possible. If set to `I_max`, potentially all energy could come from grid. If `0A < I_gridMax < I_max` it defines the maximum current which can be drawn from grid for EV charging (after having accounted for home consumption). In this case, EV charging will *not* be supported from home battery |
| I_max | maximum current provided for EV charging. Reason to set this lower to maximum current supported by wallbox are days where some PV power is available and we want extent of duration of EV charging, to make use of 'all the sun we get' |
| I_max | maximum current provided for EV charging. This level can only be reached if sufficient PV power is available to support the difference `I_max - I_gridMax`. Reason to set this lower to maximum current supported by wallbox are days where some PV power is available and we want extent of duration of EV charging, to make use of 'all the sun we get' |
| I_min | minimum current required to start EV charging |

The special value `I_max = 0` disables control of the wallbox, so that native wallbox control can be used again, without interference from `PVOptimize`.
Expand Down

0 comments on commit 36908a6

Please sign in to comment.