Rename everything to goecontroller

This commit is contained in:
2024-09-20 17:34:22 +02:00
parent 89cc2ee3b8
commit a860c200c9
6 changed files with 38 additions and 46 deletions

View File

@ -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

View File

@ -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

View File

@ -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__":

View File

@ -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")

View File

@ -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)

View File

@ -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