Skip to content
Closed
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rsync.sh
*.json
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions config.ini
Original file line number Diff line number Diff line change
@@ -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
35 changes: 22 additions & 13 deletions dbus-evcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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__)
Expand All @@ -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)
Expand Down Expand Up @@ -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'])


Expand Down Expand Up @@ -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']))
Expand Down
6 changes: 6 additions & 0 deletions example-calls.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#@baseUrl=http://evcc.local:7070
@baseUrl=http://192.168.40.227:7070


### get evcc state
GET {{baseUrl}}/api/state