From 3c890024a3d2d2b7e0bd509b5704af2cc33ba84c Mon Sep 17 00:00:00 2001 From: stevepbyrne <77573484+stevepbyrne@users.noreply.github.com> Date: Tue, 9 Feb 2021 15:56:54 +0000 Subject: [PATCH] Update dbus_systemcalc.py --- dbus_systemcalc.py | 54 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 7 deletions(-) diff --git a/dbus_systemcalc.py b/dbus_systemcalc.py index d5f45c5..dbbab90 100755 --- a/dbus_systemcalc.py +++ b/dbus_systemcalc.py @@ -20,7 +20,7 @@ import delegates from sc_utils import safeadd as _safeadd, safemax as _safemax -softwareVersion = '2.63' +softwareVersion = '2.58' class SystemCalc: STATE_IDLE = 0 @@ -130,7 +130,16 @@ def __init__(self): '/Ac/Out/L1/V': dummy, '/Ac/Out/L1/I': dummy, '/Yield/Power': dummy, - '/Soc': dummy, + '/Soc': dummy}, + 'com.victronenergy.windcharger': { + '/Connected': dummy, + '/ProductName': dummy, + '/ProductId' : dummy, + '/Mgmt/Connection': dummy, + '/Dc/0/Voltage': dummy, + '/Dc/0/Current': dummy, + '/Dc/0/Power': dummy, + } } @@ -195,8 +204,6 @@ def __init__(self): '/AutoSelectedBatteryMeasurement', value=None, gettextcallback=self._gettext) self._dbusservice.add_path( '/ActiveBatteryService', value=None, gettextcallback=self._gettext) - self._dbusservice.add_path( - '/Dc/Battery/BatteryService', value=None) self._dbusservice.add_path( '/PvInvertersProductIds', value=None) self._summeditems = { @@ -253,7 +260,8 @@ def __init__(self): '/Dc/Vebus/Power': {'gettext': '%.0F W'}, '/Dc/System/Power': {'gettext': '%.0F W'}, '/Ac/ActiveIn/Source': {'gettext': '%s'}, - '/VebusService': {'gettext': '%s'} + '/VebusService': {'gettext': '%s'}, + '/Dc/Wind/Power' :{'gettext': '%.0F W'} } for m in self._modules: @@ -358,7 +366,7 @@ def _determinebatteryservice(self): # Battery service has changed. Notify delegates. for m in self._modules: m.battery_service_changed(self._batteryservice, newbatteryservice) - self._dbusservice['/Dc/Battery/BatteryService'] = self._batteryservice = newbatteryservice + self._batteryservice = newbatteryservice def _autoselect_battery_service(self): # Default setting business logic: @@ -456,6 +464,31 @@ def _updatevalues(self): for path in pos.values(): self._compute_number_of_phases(path, newvalues) + # ==== WINDCHARGERS ==== + windchargers = self._dbusmonitor.get_service_list('com.victronenergy.windcharger') + windcharger_batteryvoltage = None + windcharger_batteryvoltage_service = None + windchargers_charge_power = 0 + + for windcharger in windchargers: + v = self._dbusmonitor.get_value(windcharger, '/Dc/0/Voltage') + if v is None: + continue + i = self._dbusmonitor.get_value(windcharger, '/Dc/0/Current') + if i is None: + continue + P = self._dbusmonitor.get_value(windcharger, '/Dc/0/Power') + + windchargers_charge_power += P + + if '/Dc/Wind/Power' not in newvalues: + newvalues['/Dc/Wind/Power'] = P + else: + newvalues['/Dc/Wind/Power'] += P + windcharger_batteryvoltage = v + windcharger_batteryvoltage_service = windcharger + + # ==== SOLARCHARGERS ==== solarchargers = self._dbusmonitor.get_service_list('com.victronenergy.solarcharger') solarcharger_batteryvoltage = None @@ -597,9 +630,15 @@ def _updatevalues(self): if solarcharger_batteryvoltage is not None: newvalues['/Dc/Battery/Voltage'] = solarcharger_batteryvoltage newvalues['/Dc/Battery/VoltageService'] = solarcharger_batteryvoltage_service + + elif windcharger_batteryvoltage is not None: + newvalues['/Dc/Battery/Voltage'] = windcharger_batteryvoltage + newvalues['/Dc/Battery/VoltageService'] = windcharger_batteryvoltage_service + elif charger_batteryvoltage is not None: newvalues['/Dc/Battery/Voltage'] = charger_batteryvoltage newvalues['/Dc/Battery/VoltageService'] = charger_batteryvoltage_service + elif vedirect_inverter is not None: v = self._dbusmonitor.get_value(vedirect_inverter, '/Dc/0/Voltage') if v is not None: @@ -611,7 +650,8 @@ def _updatevalues(self): # and amps from vebus, solarchargers and chargers. assert '/Dc/Battery/Power' not in newvalues assert '/Dc/Battery/Current' not in newvalues - p = solarchargers_charge_power + newvalues.get('/Dc/Charger/Power', 0) + vebuspower + p = solarchargers_charge_power + newvalues.get('/Dc/Charger/Power', 0) + vebuspower + windchargers_charge_power + voltage = newvalues['/Dc/Battery/Voltage'] newvalues['/Dc/Battery/Current'] = p / voltage if voltage > 0 else None newvalues['/Dc/Battery/Power'] = p