question

ralfz avatar image
ralfz asked

Multiplus-II with Raspberry Pi and ESS Mode 3, python script for control loop

Situation

I have a Multiplus-II 48/5000/70 connected to a Raspberry Pi 3B+ running Venus OS with a MK3-USB. For test purposes, I have a 48V 70Ah LeadAcid AGM battery connected.

I am following the documentation ESS mode 2 and 3 - 3.3 Running software on the CCGX and using DBus paths.

The goal is to use my own script for doing the control loop, so I need Mode 3, where the MP2 inverter is fully under the scripts control.

I wrote a script in Python, based on the code from dummy_vebus.py. It claims the dbus service "com.victronenergy.vebus.ttyO1" as described in the docs. Here is the simple code in order to get me started:


#!/usr/bin/env python

## @package conversions
# Based on code from https://github.com/victronenergy/dbus_vebus_to_pvinverter/blob/master/test/dummy_vebus.py
# This script is a simple test for controlling the MultiPlus-II via ESS Mode 3
# publishing values on dbus for the MultiPlus-II to charge or discharge the battery

from dbus.mainloop.glib import DBusGMainLoop
import gobject
import dbus
import dbus.service
import platform
import logging
import sys
import os

# our own packages
sys.path.insert(1, os.path.join(os.path.dirname(__file__), '../ext/velib_python'))
from vedbus import VeDbusService

dbusservice = None

def update():
  dbusservice['/Hub4/L1/AcPowerSetpoint'] = -150  # discharge battery a little
  logging.info("/Hub4/L1/AcPowerSetpoint: -150W")
  gobject.timeout_add(500, update)  # update every 500ms

# Init logging
logging.basicConfig(level=(logging.INFO))
logging.info(__file__ + " is starting up")
logLevel = {0: 'NOTSET', 10: 'DEBUG', 20: 'INFO', 30: 'WARNING', 40: 'ERROR'}
logging.info('Loglevel set to ' + logLevel[logging.getLogger().getEffectiveLevel()])

# Have a mainloop, so we can send/receive asynchronous calls to and from dbus
DBusGMainLoop(set_as_default=True)

dbusservice = VeDbusService('com.victronenergy.vebus.ttyO1')

# Create the management objects, as specified in the ccgx dbus-api document
dbusservice.add_path('/Management/ProcessName', __file__)
dbusservice.add_path('/Management/ProcessVersion', 'Unkown version, and running on Python ' + platform.python_version())
dbusservice.add_path('/Management/Connection', 'Mode3 battery regulator service')

# Create the mandatory objects
dbusservice.add_path('/DeviceInstance', 0)
dbusservice.add_path('/ProductId', 'NoID')
dbusservice.add_path('/ProductName', 'Mode3 battery regulator')
dbusservice.add_path('/FirmwareVersion', 0)
dbusservice.add_path('/HardwareVersion', 0)
dbusservice.add_path('/Connected', 1)

# Create all the objects that we want to export to the dbus
dbusservice.add_path('/Hub4/L1/AcPowerSetpoint', -123) # discharge battery a little
dbusservice.add_path('/Hub4/DisableCharge', 0)
dbusservice.add_path('/Hub4/DisableFeedIn', 0)
dbusservice.add_path('/Dc/V', 48.8)
dbusservice.add_path('/Dc/Battery/Voltage', 48.9)

dbusservice.add_path('/Devices/0/Version', 'test')

gobject.timeout_add(100, update)	# update in 100ms

print 'Connected to dbus, and switching over to gobject.MainLoop() (= event based)'
mainloop = gobject.MainLoop()
mainloop.run()

Problem

I see no reaction of the MultiPlus-II on the signals being published on dbus. The inverter stays idle.

I do see all paths and values when I am using dbus-spy, so the script does what I told it to do.

Question

What am I missing here? There is probably only a little thing that I am doing wrong.

Does anyone have sample code that gets me going?

Any help is welcome!

Multiplus-IIESS
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

0 Answers