Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Cant access com.victronenergy.battery.socketcan_* from VICTRON MODBUS NODE #205

Open
happycodinguk opened this issue Dec 11, 2024 · 2 comments

Comments

@happycodinguk
Copy link

happycodinguk commented Dec 11, 2024

Describe the bug
Not sure if its a bug or missing feature...

BATTERY 1 and BATTERY 2 are attached to Cerbo GX BMS CAN and VE.CAN respectively as the Fogstar Lifepo4 BMS (JBD BMS) dont link.
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 batteries attached to CAN ports in dbus-spy

1
2

com.victronenergy.battery.socketcan_can0” (battery 2) and “com.victronenergy.battery.socketcan_can1” (battery 1) exists and all of the beautiful data within!

Heading to NODE-RED.
Using 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 com.victronenergy.battery.socketcan_* dropdown to your modbus node in node red??

@happycodinguk
Copy link
Author

Got the option of new attributes in the Victron Modbus Node.
I added data into: /opt/victronenergy/dbus-modbustcp/attributes.csv

With these mods:

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

You can now see the added lines as options inside Victron Modbus Node.

can screen

When setting up two Victron Modbus nodes to read the SOC topics of can0 and can1.

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

I'm hoping as the developers you may have a bit more knowledge on how to extract the dbus-spy data into node red!

@happycodinguk
Copy link
Author

Made a work around.
Data can be extracted and printed to MQTT with the basis of this script.
It's a first draft.

#!/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"

MQTT Broker Output:
can1 = 85.0
can0 = 90.0

Get cron to run this and job’s a gooden.
If you guys can help me work out whats going wrong for me using Victron Modbus Node.
That may be a better solution with firmware upgrades on the horizon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant