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:


  1. #!/usr/bin/env python
  2.  
  3. ## @package conversions
  4. # Based on code from https://github.com/victronenergy/dbus_vebus_to_pvinverter/blob/master/test/dummy_vebus.py
  5. # This script is a simple test for controlling the MultiPlus-II via ESS Mode 3
  6. # publishing values on dbus for the MultiPlus-II to charge or discharge the battery
  7.  
  8. from dbus.mainloop.glib import DBusGMainLoop
  9. import gobject
  10. import dbus
  11. import dbus.service
  12. import platform
  13. import logging
  14. import sys
  15. import os
  16.  
  17. # our own packages
  18. sys.path.insert(1, os.path.join(os.path.dirname(__file__), '../ext/velib_python'))
  19. from vedbus import VeDbusService
  20.  
  21. dbusservice = None
  22.  
  23. def update():
  24. dbusservice['/Hub4/L1/AcPowerSetpoint'] = -150 # discharge battery a little
  25. logging.info("/Hub4/L1/AcPowerSetpoint: -150W")
  26. gobject.timeout_add(500, update) # update every 500ms
  27.  
  28. # Init logging
  29. logging.basicConfig(level=(logging.INFO))
  30. logging.info(__file__ + " is starting up")
  31. logLevel = {0: 'NOTSET', 10: 'DEBUG', 20: 'INFO', 30: 'WARNING', 40: 'ERROR'}
  32. logging.info('Loglevel set to ' + logLevel[logging.getLogger().getEffectiveLevel()])
  33.  
  34. # Have a mainloop, so we can send/receive asynchronous calls to and from dbus
  35. DBusGMainLoop(set_as_default=True)
  36.  
  37. dbusservice = VeDbusService('com.victronenergy.vebus.ttyO1')
  38.  
  39. # Create the management objects, as specified in the ccgx dbus-api document
  40. dbusservice.add_path('/Management/ProcessName', __file__)
  41. dbusservice.add_path('/Management/ProcessVersion', 'Unkown version, and running on Python ' + platform.python_version())
  42. dbusservice.add_path('/Management/Connection', 'Mode3 battery regulator service')
  43.  
  44. # Create the mandatory objects
  45. dbusservice.add_path('/DeviceInstance', 0)
  46. dbusservice.add_path('/ProductId', 'NoID')
  47. dbusservice.add_path('/ProductName', 'Mode3 battery regulator')
  48. dbusservice.add_path('/FirmwareVersion', 0)
  49. dbusservice.add_path('/HardwareVersion', 0)
  50. dbusservice.add_path('/Connected', 1)
  51.  
  52. # Create all the objects that we want to export to the dbus
  53. dbusservice.add_path('/Hub4/L1/AcPowerSetpoint', -123) # discharge battery a little
  54. dbusservice.add_path('/Hub4/DisableCharge', 0)
  55. dbusservice.add_path('/Hub4/DisableFeedIn', 0)
  56. dbusservice.add_path('/Dc/V', 48.8)
  57. dbusservice.add_path('/Dc/Battery/Voltage', 48.9)
  58.  
  59. dbusservice.add_path('/Devices/0/Version', 'test')
  60.  
  61. gobject.timeout_add(100, update) # update in 100ms
  62.  
  63. print 'Connected to dbus, and switching over to gobject.MainLoop() (= event based)'
  64. mainloop = gobject.MainLoop()
  65. 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