Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions dbus_systemcalc.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ def __init__(self):
'/Ac/L3/Current': dummy,
'/StarterVoltage': dummy},
'com.victronenergy.settings' : {
'/Settings/SystemSetup/Ac/Out/L1/Power' : dummy,
'/Settings/SystemSetup/Ac/Out/L2/Power' : dummy,
'/Settings/SystemSetup/Ac/Out/L3/Power' : dummy,
'/Settings/SystemSetup/AcInput1' : dummy,
'/Settings/SystemSetup/AcInput2' : dummy,
'/Settings/CGwacs/RunWithoutGridMeter' : dummy,
Expand Down Expand Up @@ -250,6 +253,10 @@ def __init__(self):
supported_settings = {
'batteryservice': ['/Settings/SystemSetup/BatteryService', self.BATSERVICE_DEFAULT, 0, 0],
'hasdcsystem': ['/Settings/SystemSetup/HasDcSystem', 0, 0, 1],
'hasuserconsumptioncalc': ['/Settings/SystemSetup/HasUserConsumptionCalc', 0, 0, 1],
'userAcOutL1consumption': ['/Settings/SystemSetup/Ac/Out/L1/Power', float("inf"), -float("inf"), float("inf")],
'userAcOutL2consumption': ['/Settings/SystemSetup/Ac/Out/L2/Power', float("inf"), -float("inf"), float("inf")],
'userAcOutL3consumption': ['/Settings/SystemSetup/Ac/Out/L3/Power', float("inf"), -float("inf"), float("inf")],
'useacout': ['/Settings/SystemSetup/HasAcOutSystem', 1, 0, 1],
'hasacinloads': ['/Settings/SystemSetup/HasAcInLoads', 1, 0, 1],
'gaugeautomax': ['/Settings/Gui/Gauges/AutoMax', 1, 0, 1],
Expand Down Expand Up @@ -983,6 +990,9 @@ def _updatevalues(self):
# everything must be on AC-out then.
has_ac_in_system = self._settings['hasacinloads'] == 1

# If a system has user consumption calculation enabled.
has_user_consumption_calc = self._settings['hasuserconsumptioncalc']

# If we have an ESS system and RunWithoutGridMeter is set, there cannot be load on the AC-In, so it
# must be on AC-Out. Hence we do calculate AC-Out consumption even if 'useacout' is disabled.
# Similarly all load are by definition on the output if this is not an ESS system.
Expand All @@ -994,6 +1004,7 @@ def _updatevalues(self):
for phase in consumption:
c = None
a = None
user_consumption = None
if use_ac_out:
c = newvalues.get('/Ac/PvOnOutput/%s/Power' % phase)
a = newvalues.get('/Ac/PvOnOutput/%s/Current' % phase)
Expand All @@ -1019,6 +1030,7 @@ def _updatevalues(self):
a = _safeadd(a, i_out)
c = _safemax(0, c)
a = _safemax(0, a)

newvalues['/Ac/ConsumptionOnOutput/%s/Power' % phase] = c
newvalues['/Ac/ConsumptionOnOutput/%s/Current' % phase] = a
newvalues['/Ac/Consumption/%s/Power' % phase] = _safeadd(consumption[phase], c)
Expand All @@ -1027,6 +1039,15 @@ def _updatevalues(self):
newvalues['/Ac/ConsumptionOnInput/%s/Power' % phase] = consumption[phase]
newvalues['/Ac/ConsumptionOnInput/%s/Current' % phase] = currentconsumption[phase]

if has_user_consumption_calc:

user_consumption = self._dbusmonitor.get_value('com.victronenergy.settings', '/Settings/SystemSetup/Ac/Out/%s/Power' % phase)
user_consumption = _safemax(0, user_consumption)

#if user_consumption is not None:
newvalues['/Ac/ConsumptionOnOutput/%s/Power' % phase] = user_consumption
newvalues['/Ac/Consumption/%s/Power' % phase] = user_consumption

self._compute_number_of_phases('/Ac/Consumption', newvalues)
self._compute_number_of_phases('/Ac/ConsumptionOnOutput', newvalues)
self._compute_number_of_phases('/Ac/ConsumptionOnInput', newvalues)
Expand Down