Marstek Battery plugin Topic is solved

Python and python framework

Moderator: leecollings

RNEE
Posts: 37
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 »

It Works !!!!

:shock: :shock: :shock: :shock:

But not exactly how i want it :
Image

Image

I tried to create an entry in MqttmMapper.Json for the Battery_SOC but it results in a duplicate key ??

Code: Select all

{
	"MPWR": {
		"topic": "Marstek",
		"type": "243", "subtype": "29", "switchtype": "0",
		"mapping": {"item": "params/r_data/2/value", "multiplier": 0.001, "digits": 3}
	},
	"MSOC": {
		"topic": "Marstek",
		"type": "243", "subtype": "6", "switchtype": "0",
		"mapping": {"item": "params/r_data/1/value", "multiplier": 1, "digits": 1}
	}
}
These devices :
Image
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|Quatt v2|
FlyingDomotic
Posts: 396
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: Marstek Battery plugin

Post by FlyingDomotic »

MqttMapper uses topic as key for each created device, which is a constant (while device name can easily be changed).

Drawback is that when you create two (or more) devices with the same topic, you get duplicate values.

There's a way to fix this: using the "key" item. For example:

Code: Select all

{
	"MPWR": {
		"topic": "Marstek",
		"key": "Marstek/2",
		"type": "243", "subtype": "29", "switchtype": "0",
		"mapping": {"item": "params/r_data/2/value", "multiplier": 0.001, "digits": 3}
	},
	"MSOC": {
		"topic": "Marstek",
		"key": "Marstek/6",
		"type": "243", "subtype": "6", "switchtype": "0",
		"mapping": {"item": "params/r_data/1/value", "multiplier": 1, "digits": 1}
	}
}
Key can be absolutely anything, it must just be unique in the configuration file, and is linked to the device (if you change it, a new device will be created). Here, I choose to name them after topic and r_data index.
RNEE
Posts: 37
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 »

Oke this works and the data are flowing in.

Problem is the way the enery flow to/from the battery :

Code: Select all

{
	"MPWR": {
		"topic": "Marstek",
                "key":"MPWR",
		"type": "248", "subtype": "1", "switchtype": "0",
		"mapping": {"item": "params/r_data/2/value", "multiplier": 1, "digits": 1}
	},
	"MSOC": {
		"topic": "Marstek",
		"key":"MSOC",
		"type": "243", "subtype": "6", "switchtype": "0",
		"mapping": {"item": "params/r_data/1/value", "multiplier": 1, "digits": 1}
	}
}
In this case the battery is loading ( - minus sign)!

Image

SOC works great , but flow is the problem 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|Quatt v2|
User avatar
waltervl
Posts: 5953
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Marstek Battery plugin

Post by waltervl »

What is the Watt value in MQTT in this case? Also minus? Perhaps you have to change the Domoticz kWh device to generating?
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: 37
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 value in Mqtt message is -negative (minus)
This can't be changed.

I used device type : 248/1/0
i cant change any device setting

When changing to type : 243/29/0 i get 2 values , both negative.
I can change the setting to usage/return and from device /calculated.
But changing these values has no effect.

Edit :
Maybe we need a battery device in Domoticz ?
Editje :
There isn't even a Battery icon..

Edit 2 : SOLVED
I set the mapping / multiplier to -1
now it works !
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|Quatt v2|
RNEE
Posts: 37
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 »

Wrapping up
Many thankx to Waltervl and the author of the MQTTMapper plugin : FlyingDomotic

I used the PUSR-DR134 , a € 15,-- device witch polls on a RS485 connection the Modbusdevice (in this case the Marstek Venus E battery) and sends (over Lan) the requested registerdata to a MQTT Broker, in my case Mosquito.

It is easy and fast to setup. You need a suitable cable (this is easy but tricky) and the modbus registeradresses of the device!

The Domoticz plugin MQTTMapper reads the message on the broker (Mosquito) and creates , feeds the Domoticz devices from a json device description file.

I had NO knowlegde of Modbus, MQTT messaging, Mosquito etc before.
My knowledge of Domoticz is very basic and i use my knowledge once a year...

Had i know things before i should have been able to setup this up in less than an hour.

Some things still have to be done (like the Wifi device , sending commands, using more registers etc ).

I think the combination of the PUSR-DR134 and MQTTMapper are a great enhancement for the simple use of Modbus devices in Domoticz (Solarconvertors , Battery and other machinery)

With this combination you can have live data from your own device and don't need an API from a vendors website or a dedicated plugin for your device anymore!


Edit 21.07.2025 : You can find a detailed description here : https://github.com/RneeJ/Domoticz-Marstek
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|Quatt v2|
RNEE
Posts: 37
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 »

Well, had some troubles (works like hell, ahum) with the Marstek Venus (battery) to keep it connected to the CT3 (P1 reader).

Now it has its own (very old) wifi router very very near by. Wifi - Signal strength is 96 tot 100 %. Seems to work, i hope.

My previous mentioned Github published solution works great.
If the mods think this can be an addition to the Wiki it can be used there.

---your expertise is needed please-------------

I have troubles getting the data correctly displayed and stored in Domoticz, what device should i use ?
There is no battery device available.

I have these values now :
Image
Image

MTCE “total charging energy“
MTDE “total discharging energy“
MDCE “daily charging energy“
MDDE “daily discharging energy“
MMCE “monthly charging energy“
MMDE “monthly discharging energy“

Because i read the registers via the DR134 it starts on a daily basis with 0.
I had several resets on the battery so the monthly and total values are not correct but from now on it should work.
The data in the Marstek app, are not available anymore when the modbus connection is used.
Thats oke for me when i can get them into Domoticz.

As you can see i get very strange data in the energy device (RFX) in integers.

I would like to see the same data as from the P1 meter : actual, per hour,day, month year; in and out.

How can i get these with existing devices or should that be made with a dzVents script ?
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|Quatt v2|
User avatar
waltervl
Posts: 5953
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 you have a working solution with MQTTMapper then you better make a topic about it in the "Show your Projects" forum viewforum.php?f=38

Then everybody who googles it will find it and you can maintain that topic (and the first post) yourself for updates or changes.
Alternative is to make a github repository if there is a lot to change and maintain.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
eddieb
Posts: 347
Joined: Wednesday 04 July 2018 7:48
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Marstek Battery plugin

Post by eddieb »

I had the same issue with the Battery, it had a too weak wifi signal. Putting an old accesspoint close to it made it work much better ...
I also swapped the CT003 for a HomeWizzard P1 ...
Looks it is stable for a couple of days now. The original app is sluggish ...
My modbus-wifi adapter arrived, waiting for the connector
a step-by-step setup instruction would be nice 8-)
RPI4 Beta / Tasmota / ZigBee2MQTT / P1meter / Haier AC with Node-Red and MQTT / SolarEdge SE3500H modbus_tcp / Opentherm gateway / Plugwise Anna/Smile / ObserverIP weatherstation thru WuDirect
Feeding ADSB https://adsb.im/home
RNEE
Posts: 37
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 »

Oke, in time, when everything works the right way. The Github is already there : https://github.com/RneeJ/Domoticz-Marstek

Next step beyond reading values is to control the device easily from within Domoticz.
I even are going to try to use the DR134 on my Goodwe convertor.
Both should be (quit easily) possible too

But can somebody help me with the meter devices ?

I tried several things but reading the wiki doesn't help much.
Last edited by RNEE on Wednesday 23 July 2025 14:05, edited 1 time in total.
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|Quatt v2|
RNEE
Posts: 37
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 »

eddieb wrote: Wednesday 23 July 2025 13:56 I had the same issue with the Battery, it had a too weak wifi signal. Putting an old accesspoint close to it made it work much better ...
I also swapped the CT003 for a HomeWizzard P1 ...
Looks it is stable for a couple of days now. The original app is sluggish ...
My modbus-wifi adapter arrived, waiting for the connector
a step-by-step setup instruction would be nice 8-)
This solution is for the PUSER-DR134 with a fixed lan cable.
So no wifi.

The DR134 has light-edge capabilities with automated polling and publishing over MQTT.
It is very easy to setup and use!
The problem here is Domoticz :oops:
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|Quatt v2|
eddieb
Posts: 347
Joined: Wednesday 04 July 2018 7:48
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Marstek Battery plugin

Post by eddieb »

I recently started playing with mqttmapper and I found it really nice.
transformed the nodered implementation for my HaierAC into mqttmapper and that works realy well
RPI4 Beta / Tasmota / ZigBee2MQTT / P1meter / Haier AC with Node-Red and MQTT / SolarEdge SE3500H modbus_tcp / Opentherm gateway / Plugwise Anna/Smile / ObserverIP weatherstation thru WuDirect
Feeding ADSB https://adsb.im/home
eddieb
Posts: 347
Joined: Wednesday 04 July 2018 7:48
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Marstek Battery plugin

Post by eddieb »

RNEE wrote: Wednesday 23 July 2025 13:36 The data in the Marstek app, are not available anymore when the modbus connection is used.
Thats oke for me when i can get them into Domoticz.
Is it only the "sluggish" presentation in the app ?
The app is needed to connect to wifi and to a p1, or are those fields availiable in mqtt ?
RPI4 Beta / Tasmota / ZigBee2MQTT / P1meter / Haier AC with Node-Red and MQTT / SolarEdge SE3500H modbus_tcp / Opentherm gateway / Plugwise Anna/Smile / ObserverIP weatherstation thru WuDirect
Feeding ADSB https://adsb.im/home
RNEE
Posts: 37
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 set the sending time to Mqtt to 10 seconds. data is now stored at Marstek, and visible in the app.

After modbusconnection the app still works, but a bit more sluggish.

From the register information it seems the battery can also be controlled over the modbus connection.

But my only goal is to incorpotate data in 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|Quatt v2|
RNEE
Posts: 37
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 »

RNEE wrote: Wednesday 23 July 2025 13:36 I have these values now :
Image
Image

MTCE “total charging energy“
MTDE “total discharging energy“
MDCE “daily charging energy“
MDDE “daily discharging energy“
MMCE “monthly charging energy“
MMDE “monthly discharging energy“
I need your help please with a dzVents script, i have been trying for 4 or 5 hours now.

My idea is to put the individual RFX counter values in a P1 meter device (newly created).
This works well for my P1 meter in a script where data is read from the .json file delivered by a P1 dongle.

Code: Select all

Energy_Delivered1 = domoticz.devices("MQTTmapper DR134 - MTCE").value 
This (and many many variants) result in errors like "attempt to call a nil value (field 'devices') " no value is returned.

How do i get the value from the counter ?
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|Quatt v2|
User avatar
waltervl
Posts: 5953
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Marstek Battery plugin

Post by waltervl »

See wiki https://wiki.domoticz.com/DzVents:_next ... ncremental

Probably .counter so

Code: Select all

Energy_Delivered1 = domoticz.devices("MQTTmapper DR134 - MTCE").counter
And when you do the MQTTmapping right you possibly could merge the values from marstek directly into a Domoticz P1 device (and not need a dzvents script)
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: 37
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 »

.counter didn't work.

But i had unforeseen success with getting value's directly into the P1 device from Mqttmapper !!
(tried a lot of things before but didn't work out)

Current working:

Code: Select all

"Battery": {
		"topic": "Marstek",
		"key":"Battery",
		"type": "250", "subtype": "1", "switchtype": "0",
		"mapping": {"item" : "params/r_data/3/value;params/r_data/4/value;params/r_data/5/value;params/r_data/6/value;params/r_data/7/value;params/r_data/2/value", "multiplier": 0.01, "digits": 2}
	}
Values are not at the right place but there are values !.
I hope this means i can use the P1 device for a Battery device and get the database and graphs like the P1 meter!.

Edit 27.07.2025 Works now ! ; Update on https://github.com/RneeJ/Domoticz-Marstek
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|Quatt v2|
FlyingDomotic
Posts: 396
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: Marstek Battery plugin

Post by FlyingDomotic »

P1 device accept 6 values, cumulated energy produced for 2 tariffs (usually day and night, but not only), cumulated energy consumed for 2 tariffs, instant energy produced and instant energy consumed. You may set some to zero if not used (for example if you have only one tariff, or don't generate (or consume) energy.

The issue you may have is that your battery probably has no tariff (in this case use only T1, and set T2 to 0), and may also have only information of global energy with a signed value (like positive value is energy delivered and negative consumed, in this case, you should either write a small script, or use a different kind of device, P1 being designed with these 6 values in mind).
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest