From a860c200c99e6f221534996b9c37ffdf1ef89a1c Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Fri, 20 Sep 2024 17:34:22 +0200 Subject: [PATCH] Rename everything to goecontroller --- README.md | 20 ++++---- config.ini | 6 +-- dbus-goecharger.py => dbus-goecontroller.py | 52 +++++++++------------ restart.sh | 2 +- service/run | 2 +- uninstall.sh | 2 +- 6 files changed, 38 insertions(+), 46 deletions(-) rename dbus-goecharger.py => dbus-goecontroller.py (86%) diff --git a/README.md b/README.md index f1aeb14..b1c830d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# dbus-goecharger +# dbus-goecontroller Integrate go-eCharger into Victron Energies Venus OS ## Purpose @@ -44,22 +44,22 @@ Control of go-eCharger by the victron system in "Mode" "Auto" is not supported f ## Install & Configuration ### Get the code -Just grap a copy of the main branche and copy them to a folder under `/data/` e.g. `/data/dbus-goecharger`. +Just grap a copy of the goecontroller branche and copy them to a folder under `/data/` e.g. `/data/dbus-goecontroller`. After that call the install.sh script. The following script should do everything for you: ``` -wget https://github.com/vikt0rm/dbus-goecharger/archive/refs/heads/main.zip -unzip main.zip "dbus-goecharger-main/*" -d /data -mv /data/dbus-goecharger-main /data/dbus-goecharger -chmod a+x /data/dbus-goecharger/install.sh -/data/dbus-goecharger/install.sh -rm main.zip +wget https://github.com/0xFEEDC0DE64/dbus-goecontroller/archive/refs/heads/goecontroller.zip +unzip goecontroller.zip "dbus-goecontroller-goecontroller/*" -d /data +mv /data/dbus-goecontroller-goecontroller /data/dbus-goecontroller +chmod a+x /data/dbus-goecontroller/install.sh +/data/dbus-goecontroller/install.sh +rm goecontroller.zip ``` ⚠️ Check configuration after that - because service is already installed an running and with wrong connection data (host) you will spam the log-file ### Change config.ini -Within the project there is a file `/data/dbus-goecharger/config.ini` - just change the values - most important is the deviceinstance under "DEFAULT" and host in section "ONPREMISE". More details below: +Within the project there is a file `/data/dbus-goecontroller/config.ini` - just change the values - most important is the deviceinstance under "DEFAULT" and host in section "ONPREMISE". More details below: | Section | Config vlaue | Explanation | | ------------- | ------------- | ------------- | @@ -70,7 +70,7 @@ Within the project there is a file `/data/dbus-goecharger/config.ini` - just cha ## Usefull links -- https://github.com/goecharger/go-eCharger-API-v1 +- https://github.com/goecharger/go-eController-API - https://github.com/victronenergy/dbus_modbustcp/blob/master/CCGX-Modbus-TCP-register-list.xlsx - https://github.com/trixing/venus.dbus-twc3 diff --git a/config.ini b/config.ini index 87fde29..f4c812c 100644 --- a/config.ini +++ b/config.ini @@ -1,9 +1,7 @@ [DEFAULT] AccessType = OnPremise SignOfLifeLog = 1 -Deviceinstance = 43 -# Go-e charger hardware version: 1 = v1, 2 = v2, 3 = v3 -HardwareVersion = 3 +Deviceinstance = 44 [ONPREMISE] -Host=192.168.178.97 +Host=192.168.0.130 diff --git a/dbus-goecharger.py b/dbus-goecontroller.py similarity index 86% rename from dbus-goecharger.py rename to dbus-goecontroller.py index 8aa9ff5..4431a33 100755 --- a/dbus-goecharger.py +++ b/dbus-goecontroller.py @@ -20,11 +20,10 @@ sys.path.insert(1, os.path.join(os.path.dirname(__file__), '/opt/victronenergy/d from vedbus import VeDbusService -class DbusGoeChargerService: - def __init__(self, servicename, paths, productname='go-eCharger', connection='go-eCharger HTTP JSON service'): +class DbusGoeControllerService: + def __init__(self, servicename, paths, productname='go-eController', connection='go-eController HTTP JSON service'): config = self._getConfig() deviceinstance = int(config['DEFAULT']['Deviceinstance']) - hardwareVersion = int(config['DEFAULT']['HardwareVersion']) self._dbusservice = VeDbusService("{}.http_{:02d}".format(servicename, deviceinstance)) self._paths = paths @@ -36,8 +35,8 @@ class DbusGoeChargerService: '/Mode' ] - #get data from go-eCharger - data = self._getGoeChargerData() + #get data from go-eController + data = self._getGoeControllerData() # Create the management objects, as specified in the ccgx dbus-api document self._dbusservice.add_path('/Mgmt/ProcessName', __file__) @@ -57,7 +56,6 @@ class DbusGoeChargerService: pass self._dbusservice.add_path('/FirmwareVersion', fwv) self._dbusservice.add_path('/Serial', data['sse']) - self._dbusservice.add_path('/HardwareVersion', hardwareVersion) self._dbusservice.add_path('/Connected', 1) self._dbusservice.add_path('/UpdateIndex', 0) @@ -98,35 +96,35 @@ class DbusGoeChargerService: return int(value) - def _getGoeChargerStatusUrl(self): + def _getGoeControllerStatusUrl(self): config = self._getConfig() accessType = config['DEFAULT']['AccessType'] if accessType == 'OnPremise': - URL = "http://%s/status" % (config['ONPREMISE']['Host']) + URL = "http://%s/api/status" % (config['ONPREMISE']['Host']) else: raise ValueError("AccessType %s is not supported" % (config['DEFAULT']['AccessType'])) return URL - def _getGoeChargerMqttPayloadUrl(self, parameter, value): + def _getGoeControllerSetUrl(self, parameter, value): config = self._getConfig() accessType = config['DEFAULT']['AccessType'] if accessType == 'OnPremise': - URL = "http://%s/mqtt?payload=%s=%s" % (config['ONPREMISE']['Host'], parameter, value) + URL = "http://%s/api/set?%s=%s" % (config['ONPREMISE']['Host'], parameter, value) else: raise ValueError("AccessType %s is not supported" % (config['DEFAULT']['AccessType'])) return URL - def _setGoeChargerValue(self, parameter, value): - URL = self._getGoeChargerMqttPayloadUrl(parameter, str(value)) + def _setGoeControllerValue(self, parameter, value): + URL = self._getGoeControllerSetUrl(parameter, str(value)) request_data = requests.get(url = URL) # check for response if not request_data: - raise ConnectionError("No response from go-eCharger - %s" % (URL)) + raise ConnectionError("No response from go-eController - %s" % (URL)) json_data = request_data.json() @@ -137,12 +135,12 @@ class DbusGoeChargerService: if json_data[parameter] == str(value): return True else: - logging.warning("go-eCharger parameter %s not set to %s" % (parameter, str(value))) + logging.warning("go-eController parameter %s not set to %s" % (parameter, str(value))) return False - def _getGoeChargerData(self): - URL = self._getGoeChargerStatusUrl() + def _getGoeControllerData(self): + URL = self._getGoeControllerStatusUrl() try: request_data = requests.get(url = URL, timeout=5) except Exception: @@ -150,7 +148,7 @@ class DbusGoeChargerService: # check for response if not request_data: - raise ConnectionError("No response from go-eCharger - %s" % (URL)) + raise ConnectionError("No response from go-eController - %s" % (URL)) json_data = request_data.json() @@ -171,8 +169,8 @@ class DbusGoeChargerService: def _update(self): try: - #get data from go-eCharger - data = self._getGoeChargerData() + #get data from go-eController + data = self._getGoeControllerData() if data is not None: #send data to DBus @@ -199,11 +197,7 @@ class DbusGoeChargerService: self._dbusservice['/Mode'] = 0 # Manual, no control config = self._getConfig() - hardwareVersion = int(config['DEFAULT']['HardwareVersion']) - if hardwareVersion == 3: - self._dbusservice['/MCU/Temperature'] = int(data['tma'][0]) - else: - self._dbusservice['/MCU/Temperature'] = int(data['tmp']) + self._dbusservice['/MCU/Temperature'] = int(data['tma'][0]) # value 'car' 1: charging station ready, no vehicle 2: vehicle loads 3: Waiting for vehicle 4: Charge finished, vehicle still connected status = 0 @@ -243,11 +237,11 @@ class DbusGoeChargerService: logging.info("someone else updated %s to %s" % (path, value)) if path == '/SetCurrent': - return self._setGoeChargerValue('amp', value) + return self._setGoeControllerValue('amp', value) elif path == '/StartStop': - return self._setGoeChargerValue('alw', value) + return self._setGoeControllerValue('alw', value) elif path == '/MaxCurrent': - return self._setGoeChargerValue('ama', value) + return self._setGoeControllerValue('ama', value) else: logging.info("mapping for evcharger path %s does not exist" % (path)) return False @@ -279,7 +273,7 @@ def main(): _s = lambda p, v: (str(v) + 's') #start our main-service - pvac_output = DbusGoeChargerService( + pvac_output = DbusGoeControllerService( servicename='com.victronenergy.evcharger', paths={ '/Ac/Power': {'initial': 0, 'textformat': _w}, @@ -300,7 +294,7 @@ def main(): logging.info('Connected to dbus, and switching over to gobject.MainLoop() (= event based)') mainloop = gobject.MainLoop() - mainloop.run() + mainloop.run() except Exception as e: logging.critical('Error at %s', 'main', exc_info=e) if __name__ == "__main__": diff --git a/restart.sh b/restart.sh index 4ae4dd9..38b96fb 100644 --- a/restart.sh +++ b/restart.sh @@ -1,4 +1,4 @@ #!/bin/bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -kill $(pgrep -f "python $SCRIPT_DIR/dbus-goecharger.py") +kill $(pgrep -f "python $SCRIPT_DIR/dbus-goecontroller.py") diff --git a/service/run b/service/run index 7e80bd2..d2600c7 100644 --- a/service/run +++ b/service/run @@ -2,4 +2,4 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) exec 2>&1 -python $(realpath $SCRIPT_DIR/../dbus-goecharger.py) +python $(realpath $SCRIPT_DIR/../dbus-goecontroller.py) diff --git a/uninstall.sh b/uninstall.sh index 962352a..c620eb7 100644 --- a/uninstall.sh +++ b/uninstall.sh @@ -3,6 +3,6 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) SERVICE_NAME=$(basename $SCRIPT_DIR) rm /service/$SERVICE_NAME -kill $(pgrep -f 'supervise dbus-goecharger') +kill $(pgrep -f 'supervise dbus-goecontroller') chmod a-x $SCRIPT_DIR/service/run ./restart.sh