Marstek Battery plugin Topic is solved

Python and python framework

Moderator: leecollings

RNEE
Posts: 30
Joined: Sunday 05 August 2018 10:13
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Eindhoven area
Contact:

Marstek Battery plugin

Post by RNEE »

Last week i installed a new Marstek Venus E 5,12 Kwh homebattery.
It seems they are flooding the market with these :lol:

Runs like " hell" and i love it, but currently it is not incorporated in Domoticz.

It has a modbus RS 485 connection and so i orderd https://nl.aliexpress.com/item/10050068 ... pt=glo2nld this Puser USR-DR132/134 modbus to ethernet convertor at Aliexpress.

I'am going to try to incorporate it in Domoticz.

There are already python tools available and the Homewizard Battery Plugin.

Any thoughts ?
Domoticz on Docker on Raspberry PI 5 with 500 Gb NvME|Milight|RFXCOM|Goodwe|Smartstuff P1 meter|Buienradar|Afval kalender|Tuya|deCONZ Conbee II|Marstek Homebattery 5,12Kwh via Modbus |MQTTMapper|
User avatar
gizmocuz
Posts: 2549
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Marstek Battery plugin

Post by gizmocuz »

It indeed supports modbus. So you could create a python Domoticz plugin for this.
Or a python application that runs in the background of your system and uses the Domoticz JSON API to publish it's values to Domoticz

Advertisement is a bit tricky... No it does not support 100A, as it is just plugged into your wall

The real max. output is 10.9A = ~2500 Watt (Default 800Watt)

(Which still is nice!)

Maybe this could help you get started:

https://github.com/gizmocuz/SDM630-Modbus

It is a Chinese Battery (Aren't they all), but they do ping-back to China.

Here is a Dutch review

https://www.youtube.com/watch?v=2HDamrcr1q8
Quality outlives Quantity!
RNEE
Posts: 30
Joined: Sunday 05 August 2018 10:13
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Eindhoven area
Contact:

Re: Marstek Battery plugin

Post by RNEE »

Thank you !

I run it on a seperate group at 2500 watts.

Although i can programm (a little) , have some knowledge of I2C and SPI and C, python is not in my toolbox (!).

I will come back to this as soon as i receive the adapter.

Edit : found this
https://www.photovoltaikforum.com/threa ... /?pageNo=1

https://github.com/scruysberghs/ha-marstek-venus
Domoticz on Docker on Raspberry PI 5 with 500 Gb NvME|Milight|RFXCOM|Goodwe|Smartstuff P1 meter|Buienradar|Afval kalender|Tuya|deCONZ Conbee II|Marstek Homebattery 5,12Kwh via Modbus |MQTTMapper|
RNEE
Posts: 30
Joined: Sunday 05 August 2018 10:13
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Eindhoven area
Contact:

Re: Marstek Battery plugin

Post by RNEE »

I have the Pusr DR134 (RS485 to LAN) running and posting values from the home battery to Mosquito.
(for the hardware setup thanks to " @superdupper1969" at Tweakers in the topic for connecting modbus to HA)

Although i have no experience in MQTT it was easy to set up the Marstek and DR134 and after some hours it have the device posting to Mosquito.

I now get the following message in MQTT Explorer :

Code: Select all

{"params":{"dir":"up","id":"xxxxxxxxxx","r_data":[{"name":"batteryvoltage","value":"5426","err":"0"},{"name":"batterycurrent","value":"4373","err":"0"},{"name":"batterypower","value":"2374","err":"0"},{"name":"batterySOC","value":"54","err":"0"},{"name":"batterytotalenergy","value":"5120","err":"0"},{"name":"ACvoltage","value":"2341","err":"0"},{"name":"ACcurrent","value":"1045","err":"0"},{"name":"ACpower","value":"-2344","err":"0"},{"name":"ACfrequency","value":"4999","err":"0"},{"name":"internaltemp","value":"417","err":"0"}]}}
I have installed MQTTMapper (of witch i understand it should be usable to create devices) but now i do NOT get it how to create a device description for the homebattery in Domoticz.

There are no Homebattery device types on https://wiki.domoticz.com/Developing_a_ ... vice_Types.

I could use some help on the JSON file for device description in MQTTMapper.
Domoticz on Docker on Raspberry PI 5 with 500 Gb NvME|Milight|RFXCOM|Goodwe|Smartstuff P1 meter|Buienradar|Afval kalender|Tuya|deCONZ Conbee II|Marstek Homebattery 5,12Kwh via Modbus |MQTTMapper|
FlyingDomotic
Posts: 388
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: Marstek Battery plugin

Post by FlyingDomotic »

A possible idea is to use some plug-in like MqttMapper.

I tried to make a configuration giving data posted here, but format is too complicated as the selector item is within a list (supported), but as value after "name" item. As of now, it's not supported, and there's no chance to support it soon, as the way definition is done is very uncommon (and not in JSON spirit).
User avatar
waltervl
Posts: 5886
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Marstek Battery plugin

Post by waltervl »

If the order in the list is always is the same, so eg batteryvoltage is always the first value in the r_data list you can use the order eg
params.r_data[0].value for batteryvoltage
params.r_data[9].value for internaltemp

Not sure how this could be used in the MQTT mapper JSON configuration file.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
FlyingDomotic
Posts: 388
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: Marstek Battery plugin

Post by FlyingDomotic »

waltervl wrote: Wednesday 09 July 2025 10:08 Not sure how this could be used in the MQTT mapper JSON configuration file.
You're right, this is not supported.

As of now, only "*" is supported to scan a list of values, but idea is to be able to select an item, not an item's value.
"select" or "reject" are also supported, but to select or reject a message giving an item presence/absence, not to select an item in a list.

However, for this kind of complex syntax, yo can still copy the full message into a Domoticz text device, and do a manual parsing with either LUA or dzVents.

For example:

Code: Select all

{
	"My full topic message": {
		"topic": "my/full/topic",
		"type": "243", "subtype": "19", "switchtype": "0",
		"mapping": {"item": ""}
	}
}
Replace "my/full/topic" by topic of MQTT message you want to intercept and you'll get the original message into "My full topic message" Domoticz device (probably prefixed by "MQTT Mapper - " or equivalent).

You now can write a LUA or dzVents small script looking for this device changes, and analyze content of device (which is the full message indeed).

You may event extract only par of message specifying something into "mapping":"item". Here, instead of "", you may want to indicate "params/r_data" to only get the list of data.

Manually create corresponding (virtual) dummy devices, and load them within script.
RNEE
Posts: 30
Joined: Sunday 05 August 2018 10:13
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Eindhoven area
Contact:

Re: Marstek Battery plugin

Post by RNEE »

Thank you for your input, realy usefull.

Message is always the same, with changing values. Definition of the content of message is by me.

The DR134 asks the Modbus connected device and creats the message. It is very easy to setup, but one needs the registeradres.

I can limit the message to what i need :
batterySOC = percentage of battery filled
ACpower = watts going in or out.

i try dzVentz.
Domoticz on Docker on Raspberry PI 5 with 500 Gb NvME|Milight|RFXCOM|Goodwe|Smartstuff P1 meter|Buienradar|Afval kalender|Tuya|deCONZ Conbee II|Marstek Homebattery 5,12Kwh via Modbus |MQTTMapper|
User avatar
waltervl
Posts: 5886
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Marstek Battery plugin

Post by waltervl »

RNEE wrote: Wednesday 09 July 2025 13:14 Thank you for your input, realy usefull.

Message is always the same, with changing values. Definition of the content of message is by me.
Can you also steer the structure of the content to make it more useable?

It ideally should look something like:

Code: Select all

{
    "params": {
        "dir": "up",
        "id": "xxxxxxxxxx",
        "r_data":  {
                "batteryvoltage": 5426,
                "batteryvoltage_err": false,
                "batterycurrent": 4373,
                "batterycurrent_err": false,
                etc
            }
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
RNEE
Posts: 30
Joined: Sunday 05 August 2018 10:13
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Eindhoven area
Contact:

Re: Marstek Battery plugin

Post by RNEE »

I tried several settings, but couldn’t change the layout.
Some conversion has to be made to get this layout.

The other setting is Modbus TCP so i probably can use another plugin.
Domoticz on Docker on Raspberry PI 5 with 500 Gb NvME|Milight|RFXCOM|Goodwe|Smartstuff P1 meter|Buienradar|Afval kalender|Tuya|deCONZ Conbee II|Marstek Homebattery 5,12Kwh via Modbus |MQTTMapper|
FlyingDomotic
Posts: 388
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: Marstek Battery plugin

Post by FlyingDomotic »

Do you have any pointer to the doc explaining how to change layout?
RNEE
Posts: 30
Joined: Sunday 05 August 2018 10:13
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Eindhoven area
Contact:

Re: Marstek Battery plugin

Post by RNEE »

The manuals are over here :
https://www.pusr.com/products/Lipstick- ... erver.html

Because i only need 2 values maybe it is possible to change Mqttmapper to read just 2 fixed values.

The other option is :
https://github.com/DomoticX/domoticz-mo ... me-ov-file

I looked into several different plugins etc but nothing that could fit easily.

The device is nice and usefull, it was very hopefull to have an easy solution but “helaas pindakaas”
Domoticz on Docker on Raspberry PI 5 with 500 Gb NvME|Milight|RFXCOM|Goodwe|Smartstuff P1 meter|Buienradar|Afval kalender|Tuya|deCONZ Conbee II|Marstek Homebattery 5,12Kwh via Modbus |MQTTMapper|
FlyingDomotic
Posts: 388
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: Marstek Battery plugin

Post by FlyingDomotic »

What kind of MQTT publish transmission did you setup? Custom?
RNEE
Posts: 30
Joined: Sunday 05 August 2018 10:13
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Eindhoven area
Contact:

Re: Marstek Battery plugin

Post by RNEE »

I use " Transparent transmission" , then the expected message is received :
{"params":{"dir":"up","id":"02103225061700034587","r_data":[{"name":"batterySOC","value":"67","err":"0"},{"name":"ACpower","value":"2492","err":"0"}]}}

I can upload a template file like this :

Code: Select all

{
  "datas": [
    {
      "key": 4,
      "name": "batterySOC",
      "sadd": 1,
      "rtype": 3,
      "radd": 32104,
      "dtype": 1,
      "magn": "1",
      "report": 0,
      "ampl": "0"
    },
    {
      "key": 8,
      "name": "ACpower",
      "sadd": 1,
      "rtype": 3,
      "radd": 32202,
      "dtype": 3,
      "magn": "1",
      "report": 0,
      "ampl": "0"
    }
  ]
}
It is like the input screen :
Image

When set to " Custom" bytes are sent but i don't receive anything in MQTT Explorer.

But you mean a custom template can be made ?
Domoticz on Docker on Raspberry PI 5 with 500 Gb NvME|Milight|RFXCOM|Goodwe|Smartstuff P1 meter|Buienradar|Afval kalender|Tuya|deCONZ Conbee II|Marstek Homebattery 5,12Kwh via Modbus |MQTTMapper|
User avatar
waltervl
Posts: 5886
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Marstek Battery plugin

Post by waltervl »

From the manual
Transparent transmission: The data received by the serial port is
transparently transmitted to the associated topic.
Topic distribution: When configuring a topic, you can define an identifier
for the topic. After receiving serial port data, the device sends it to the
associated topic based on the identifier. The device allows different topics
to have the same identifier, so that data is pushed to all topics with the
same identifier. The identifier and the payload are separated by commas.
Custom mode: The custom mode is simple and quick to use, and users do
not need to configure the relevant parameters of data release on the web.
Only need to open the custom mode switch, click Save and restart
the device to achieve MQTT data transparent transmission.
So please try Topic distribution and the Custom to check the mqtt messages.
You have to restart the device after each change.....
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
RNEE
Posts: 30
Joined: Sunday 05 August 2018 10:13
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Eindhoven area
Contact:

Re: Marstek Battery plugin

Post by RNEE »

Yes , yes i did.
I tried everything now. (also restarts etc).
No usefull output then.

I ask the company in china.
Domoticz on Docker on Raspberry PI 5 with 500 Gb NvME|Milight|RFXCOM|Goodwe|Smartstuff P1 meter|Buienradar|Afval kalender|Tuya|deCONZ Conbee II|Marstek Homebattery 5,12Kwh via Modbus |MQTTMapper|
RNEE
Posts: 30
Joined: Sunday 05 August 2018 10:13
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Eindhoven area
Contact:

Re: Marstek Battery plugin

Post by RNEE »

Found this using NodeRed to convert to a Domoticz usable message.

viewtopic.php?t=36213
Domoticz on Docker on Raspberry PI 5 with 500 Gb NvME|Milight|RFXCOM|Goodwe|Smartstuff P1 meter|Buienradar|Afval kalender|Tuya|deCONZ Conbee II|Marstek Homebattery 5,12Kwh via Modbus |MQTTMapper|
Toulon7559
Posts: 859
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Marstek Battery plugin

Post by Toulon7559 »

See several attempts to construct an interface between Marstek-battery and Domoticz and other applications.
But (whatever the application) a 'clean' setup starts with getting&reading the specification of the interface and it's data-protocol.
Therefore: which document is applicable for interface & data-protocol?
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
RNEE
Posts: 30
Joined: Sunday 05 August 2018 10:13
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Eindhoven area
Contact:

Re: Marstek Battery plugin

Post by RNEE »

I have converted the data delivered by the DR134 to Mosquito with JQ:

Code: Select all

$ mosquitto_sub -t /PubTopic1/# -h 192.168.2.32 -p 1883 -u rene -P rene |jq -r --unbuffered '.[].r_data[0].value'|mosquitto_pub -t BatterySOC -l -h 192.168.2.32 -p 1883 -u rene -P rene
This returns the actual soc % to the topic "BatterySOC" or " ACPower" as a value in mosquito.

Image

Now i have to figure out how to get it into Domoticz !
Domoticz on Docker on Raspberry PI 5 with 500 Gb NvME|Milight|RFXCOM|Goodwe|Smartstuff P1 meter|Buienradar|Afval kalender|Tuya|deCONZ Conbee II|Marstek Homebattery 5,12Kwh via Modbus |MQTTMapper|
RNEE
Posts: 30
Joined: Sunday 05 August 2018 10:13
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Eindhoven area
Contact:

Re: Marstek Battery plugin

Post by RNEE »

Toulon7559 wrote: Friday 11 July 2025 15:16 See several attempts to construct an interface between Marstek-battery and Domoticz and other applications.
But (whatever the application) a 'clean' setup starts with getting&reading the specification of the interface and it's data-protocol.
Therefore: which document is applicable for interface & data-protocol?
I posted the manuals before.

The interface device DR134 automaticly polls the RS485 device and creates a MQTT message with a fixed layout witch is posted to in my case Mosquito as a broker.
So i thought it should be easy to incorporate into Domoticz, but "helaas pindakaas"

But Jq can handle the output now.
Domoticz on Docker on Raspberry PI 5 with 500 Gb NvME|Milight|RFXCOM|Goodwe|Smartstuff P1 meter|Buienradar|Afval kalender|Tuya|deCONZ Conbee II|Marstek Homebattery 5,12Kwh via Modbus |MQTTMapper|
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest