Dbus-spy data extraction? We have ways of making you talk!

Hello people of Victron Community!
I’m going round in circles a wee bit and hope one of y’all can shed some light?

Using dbus-spy as root…
I see beautiful information before me.

BATTERY 1 and BATTERY 2 full info

These batteries are Lifepo4 batteries connected by CAN to the cerbo.
Cerbo GUI only sees one of these and gives one of them an instance ID of 225.
This is no worry as I can see the persistent data from both in dubus-spy

com.victronenergy.battery.socketcan_can0” (battery 2) and “com.victronenergy.battery.socketcan_can1” (battery 1) exists.

Heading to NODE_RED.
Using a the victron modbus node when I select the dropdown for attributes i can see

com.victronenergy.battery

but not “com.victronenergy.battery.socketcan_can0

Is there a way of my manually adding this?

Second approach!

I use a generic modbus node. Enter the cerbo ip us the start address 259 for battery info (as stated in Victron https://www.victronenergy.com/live/ccgx:modbustcp_faq)
and requesting a quantity of 60.

This will not process any data unless i state a UNIT-ID of which I have only one: 225 which is for only one battery. The debug node does as expected. Prints pay load for 1 battery.

So unless I have another UNIT-ID for the second battery. That node appears not to help.

As stated. The full data for both batteries appear in dbus-spy under:
“com.victronenergy.battery.socketcan_can0” and com.victronenergy.battery.socketcan_can1 (battery 1)

Does anyone know how I can extract this into payload in Node-Red?

I’ve tried battery aggregation and this hasnt helped btw.
I simply (or not so simply) want to extract the data from
socketcan_can0 and socketcan_can1

I’m new to modbus if you hadn’t noticed!

All the Best!

Do you have two different types of batteries?

Same. Both Fogstar pro 280ah in parallel.

Then do you have them connected individually to the Venus OS on different CAN ports?

Because, generally speaking, the batteries’ BMSes should talk to each other and present themself to the Venus OS just like one big battery…

I am asking these because it’s strange that in the dbus you have two different batteries like that, just like you have them on different CAN ports…
For example I have six batteries in parallel, but in the dbus I have only one battery (com.victronenergy.battery.socketcan_can1) with six times one’s capacity.

Na. The fogstar BMS which is a JBD BMS doesn’t link on CAN. One battery is in BMS CAN into Cerbo and one is in VE.CAN (with BMS parameters).

You’d have thought, as the data that’s needed exists in Dbus-spy (made my victron? GitHub - victronenergy/dbus-spy). It must be able to be extracted by modbus? Think their NODE-RED node could be modified to fix this.

We’ve also got a cerbo V2 also as there are more fogstar batteries to monitor, and the outcome is the same regarding data extraction.

I’m sure I will figure it out over time!

Yep, unusual usage.
But…
If you know your way around a linux system, you can ssh on Cerbo and then add whatever dbus paths (variables) and your chosen ids on the modbus driver and then get them the usual way.
Just modify the /opt/victronenergy/dbus-modbustcp/attributes.csv file for that and restart the modbus service.
The same as the one here: GitHub - victronenergy/dbus_modbustcp: Modbustcp server, that allows for example PLCs to get data from the D-Bus.

1 Like

Had a bit of a tinker and am making progress with that info. Thank you!

So i’ve edited that file

with

com.victronenergy.battery.socketcan_can0,/Dc/0/Current,d,A DC,261,int16,10,R
com.victronenergy.battery.socketcan_can1,/Dc/0/Current,d,A DC,261,int16,10,R
com.victronenergy.battery.socketcan_can0,/Dc/0/Voltage,d,V DC,260,uint16,100,R
com.victronenergy.battery.socketcan_can1,/Dc/0/Voltage,d,V DC,260,uint16,100,R

and the dbus path is now showing on dropdown for the Victron Modbus node in Node-Red.

But the node still requires a Unit-ID of which only 225 works (225 is for main battery which displays in the Cerbo GUI).

So moving on. I select socketcan_can* attributes and close the edited Victron Modbus node which is connected to a debug.
Open the modbus node again to check the attribute saved. And no luck.
The dropdown just links to the main battery options ie:
com.victronenergy.battery:/Dc/0/Voltage
not
com.victronenergy.battery.socketcan_can1:/Dc/0/Voltage

Now I’ve linked the CAN paths in the CSV file you pointed me to.
Is there another way of extracting each data line in node red or via script in command line which I could print to file then send on to whatever application?

Don’t use existing addresses. Use unique, unused values.

Alternative, use dbus or dbus-send utility.

Examples:

1 Like

Got the option to now save in the Victron Modbus Node.
It was the unique ID issue causing the node not saving!

Now looks like:

com.victronenergy.battery.socketcan_can1,/Dc/0/Power,i,W,6001,int16,1,R
com.victronenergy.battery.socketcan_can1,/Dc/0/Voltage,d,V DC,6002,uint16,100,R
com.victronenergy.battery.socketcan_can1,/Dc/1/Voltage,d,V DC,6003,uint16,100,R
com.victronenergy.battery.socketcan_can1,/Dc/0/Current,d,A DC,6004,int16,10,R
com.victronenergy.battery.socketcan_can1,/Dc/0/Temperature,d,Degrees celsius,6005,int16,10,R
com.victronenergy.battery.socketcan_can1,/Dc/0/MidVoltage,d,V DC,6006,uint16,100,R
com.victronenergy.battery.socketcan_can1,/Dc/0/MidVoltageDeviation,d,%,6007,uint16,100,R
com.victronenergy.battery.socketcan_can1,/ConsumedAmphours,d,Ah,6008,uint16,-10,R
com.victronenergy.battery.socketcan_can1,/Soc,y,%,6009,uint16,10,R
com.victronenergy.battery.socketcan_can1,/Soh,y,%,6010,uint16,10,R

com.victronenergy.battery.socketcan_can0,/Dc/0/Power,i,W,7001,int16,1,R
com.victronenergy.battery.socketcan_can0,/Dc/0/Voltage,d,V DC,7002,uint16,100,R
com.victronenergy.battery.socketcan_can0,/Dc/1/Voltage,d,V DC,7003,uint16,100,R
com.victronenergy.battery.socketcan_can0,/Dc/0/Current,d,A DC,7004,int16,10,R
com.victronenergy.battery.socketcan_can0,/Dc/0/Temperature,d,Degrees celsius,7005,int16,10,R
com.victronenergy.battery.socketcan_can0,/Dc/0/MidVoltage,d,V DC,263,uint16,7006,R
com.victronenergy.battery.socketcan_can0,/Dc/0/MidVoltageDeviation,d,%,7007,uint16,100,R
com.victronenergy.battery.socketcan_can0,/ConsumedAmphours,d,Ah,7008,uint16,-10,R
com.victronenergy.battery.socketcan_can0,/Soc,y,%,7009,uint16,10,R
com.victronenergy.battery.socketcan_can0,/Soh,y,%,7010,uint16,10,R

So now I’ve setup two Victron Modbus nodes to read the SOC topics of
com.victronenergy.battery.socketcan_can1,/Soc,y,%,6009,uint16,10,R
and
com.victronenergy.battery.socketcan_can0,/Soc,y,%,7009,uint16,10,R

Sadly their output is the exactly same in debug.Tho the actual SOC of two batteries are different.

Looks like:

Is next, but will be a steep learning curve. Hopefully someone else may be able to chime in on the Node issue above while I go study lol

Have learned quite a bit so far. So thank you @alexpescaru

OK. Via command line in cerbo as root I can extract the data (as you advised!):

root@CerboGX:~# dbus -y com.victronenergy.battery.socketcan_can1 /Soc GetValue

value = 85.0

root@CerboGX:~# dbus -y com.victronenergy.battery.socketcan_can0 /Soc GetValue

value = 91.0

I’m sure I can write a script to run as root to publish these queries to MQTT.
Will just need to check this script persists after firmware upgrade.

Would prefer the Victron Modbus node working. But this can be a stopgap!

** EDIT
First draft of the script:

#!/bin/bash

# MQTT Broker details
MQTT_BROKER="THE BROKER IP"
MQTT_PORT=1883
MQTT_TOPIC="/fogstar/battery/soc"

# DBUs Commands
CAN1_REPLY=$(dbus -y com.victronenergy.battery.socketcan_can1 /Soc GetValue)
CAN0_REPLY=$(dbus -y com.victronenergy.battery.socketcan_can0 /Soc GetValue)

# Extract SOC values using awk
CAN1_SOC=$(echo "$CAN1_REPLY" | awk -F' = ' '{print $2}' | awk '{print $1}')
CAN0_SOC=$(echo "$CAN0_REPLY" | awk -F' = ' '{print $2}' | awk '{print $1}')

# Debugging output
echo "CAN1_REPLY: $CAN1_REPLY"
echo "CAN0_REPLY: $CAN0_REPLY"
echo "CAN1_SOC: $CAN1_SOC"
echo "CAN0_SOC: $CAN0_SOC"

# Publish to MQTT
mosquitto_pub -h $MQTT_BROKER -p $MQTT_PORT -t "$MQTT_TOPIC/can1" -m "$CAN1_SOC"
mosquitto_pub -h $MQTT_BROKER -p $MQTT_PORT -t "$MQTT_TOPIC/can0" -m "$CAN0_SOC"

echo "Published CAN1 SOC: $CAN1_SOC to $MQTT_TOPIC/can1"
echo "Published CAN0 SOC: $CAN0_SOC to $MQTT_TOPIC/can0"

Output:

can1 = 85.0

can0 = 90.0

Get cron to run this and job’s a gooden. Just need to add all of the topics!
This may take a while.

If anyone can help make the Victron Modbus Node work. This would be a better solution for those using 2 CAN bus to monitor their batteries in Cerbo GX.