diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4547dd9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +rsync.sh +*.json diff --git a/README.md b/README.md index 0bc3d87..9e86232 100644 --- a/README.md +++ b/README.md @@ -43,10 +43,9 @@ Within the project there is a file `/data/dbus-evcc/config.ini` - just change th (Count up `dbus-evcc-1` for each loadpoint) 2. Update the `dbus-evcc-1/config.ini`: - The `deviceinstance` should be different for each loadpoint: Use `43` for the first. Use `44` for the second loadpoint... -3. Update the `dbus-evcc.py`: - Search for `["loadpoints"][0]` and replace it with `["loadpoints"][1]`. + - The `loadpointInstance` should be different for each loadpoint: Use `0` for the first. Use `1` for the second loadpoint... -If you have more than two loadpoints, the procedure is the same, but the index should be counted up. +If you have more than two loadpoints, the procedure is the same, but the indexes should be counted up. ## Useful links Many thanks. @vikt0rm, @fabian-lauer, @trixing and @JuWorkshop project: diff --git a/config.ini b/config.ini index e001f8d..d928a3a 100644 --- a/config.ini +++ b/config.ini @@ -1,7 +1,10 @@ [DEFAULT] AccessType = OnPremise SignOfLifeLog = 1 +# Default = 43. Count up for every additional loadpoint Deviceinstance = 43 +# Read readme.md first! Default = 0. Count up for every additional loadpoint +LoadpointInstance = 0 [ONPREMISE] Host=192.168.1.2:7070 diff --git a/dbus-evcc.py b/dbus-evcc.py index c4acbea..1042769 100644 --- a/dbus-evcc.py +++ b/dbus-evcc.py @@ -24,6 +24,8 @@ class DbusEvccChargerService: def __init__(self, servicename, paths, productname='EVCC-Charger', connection='EVCC REST API'): config = self._getConfig() deviceinstance = int(config['DEFAULT']['Deviceinstance']) + global lpInstance + lpInstance = int(config['DEFAULT']['LoadpointInstance']) self._dbusservice = VeDbusService("{}.http_{:02d}".format(servicename, deviceinstance)) self._paths = paths @@ -36,7 +38,11 @@ def __init__(self, servicename, paths, productname='EVCC-Charger', connection='E ] # get data from go-eCharger - data = self._getEvccChargerData() + result = self._getEvccChargerData() + loadpoint = result["loadpoints"][lpInstance] + + # Set custom name from loadpoint title + customname = str(loadpoint['title']) # Create the management objects, as specified in the ccgx dbus-api document self._dbusservice.add_path('/Mgmt/ProcessName', __file__) @@ -48,8 +54,8 @@ def __init__(self, servicename, paths, productname='EVCC-Charger', connection='E self._dbusservice.add_path('/DeviceInstance', deviceinstance) self._dbusservice.add_path('/ProductId', 0xFFFF) # self._dbusservice.add_path('/ProductName', productname) - self._dbusservice.add_path('/CustomName', productname) - #self._dbusservice.add_path('/FirmwareVersion', int(data['divert_update'])) + self._dbusservice.add_path('/CustomName', customname) + self._dbusservice.add_path('/FirmwareVersion', result["version"]) self._dbusservice.add_path('/HardwareVersion', 2) #self._dbusservice.add_path('/Serial', data['comm_success']) self._dbusservice.add_path('/Connected', 1) @@ -129,23 +135,26 @@ def _signOfLife(self): def _update(self): try: # get data from go-eCharger - data = self._getEvccChargerData() - result = data["result"] - loadpoint = result["loadpoints"][0] + result = self._getEvccChargerData() + loadpoint = result["loadpoints"][lpInstance] # send data to DBus # not really needed, but can be enabled - voltage = 230 # adjust to your voltage - self._dbusservice['/Ac/L1/Power'] = float(loadpoint['chargeCurrents'][0]) * voltage # watt - self._dbusservice['/Ac/L2/Power'] = float(loadpoint['chargeCurrents'][1]) * voltage # watt - self._dbusservice['/Ac/L3/Power'] = float(loadpoint['chargeCurrents'][2]) * voltage # watt + voltage1 = float(loadpoint['chargeVoltages'][0]) # volt + voltage2 = float(loadpoint['chargeVoltages'][1]) # volt + voltage3 = float(loadpoint['chargeVoltages'][2]) # volt + voltage = (voltage1 + voltage2 + voltage3) / 3 # 230 # adjust to your voltage + + self._dbusservice['/Ac/L1/Power'] = float(loadpoint['chargeCurrents'][0]) * voltage1 # watt + self._dbusservice['/Ac/L2/Power'] = float(loadpoint['chargeCurrents'][1]) * voltage2 # watt + self._dbusservice['/Ac/L3/Power'] = float(loadpoint['chargeCurrents'][2]) * voltage3 # watt self._dbusservice['/Ac/Voltage'] = voltage self._dbusservice['/Ac/Power'] = float(loadpoint['chargePower']) # w - self._dbusservice['/Current'] = float(loadpoint['chargeCurrent']) + self._dbusservice['/Current'] = float(loadpoint['chargePower']) / voltage - self._dbusservice['/SetCurrent'] = float(loadpoint['chargeCurrent']) + self._dbusservice['/SetCurrent'] = float(loadpoint['chargePower']) / voltage self._dbusservice['/MaxCurrent'] = int(loadpoint['maxCurrent']) # int(data['ama']) @@ -180,7 +189,7 @@ def _update(self): if status == 0: self._dbusservice['/ChargingTime'] = 0 else: - self._dbusservice['/ChargingTime'] = int(loadpoint["chargeDuration"])/1000000000 # s + self._dbusservice['/ChargingTime'] = int(loadpoint["chargeDuration"]) # /1000000000 # s # logging logging.debug("Wallbox Consumption (/Ac/Power): %s" % (self._dbusservice['/Ac/Power'])) diff --git a/example-calls.http b/example-calls.http new file mode 100644 index 0000000..10cd36c --- /dev/null +++ b/example-calls.http @@ -0,0 +1,6 @@ +#@baseUrl=http://evcc.local:7070 +@baseUrl=http://192.168.40.227:7070 + + +### get evcc state +GET {{baseUrl}}/api/state