Page 3 of 5

Re: Marstek Battery plugin

Posted: Saturday 12 July 2025 21:50
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

Re: Marstek Battery plugin

Posted: Saturday 12 July 2025 23:21
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.

Re: Marstek Battery plugin

Posted: Sunday 13 July 2025 10:43
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

Re: Marstek Battery plugin

Posted: Sunday 13 July 2025 10:53
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?

Re: Marstek Battery plugin

Posted: Sunday 13 July 2025 11:23
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 !

Re: Marstek Battery plugin

Posted: Sunday 13 July 2025 12:05
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

Re: Marstek Battery plugin

Posted: Wednesday 23 July 2025 13:36
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 ?

Re: Marstek Battery plugin

Posted: Wednesday 23 July 2025 13:42
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.

Re: Marstek Battery plugin

Posted: Wednesday 23 July 2025 13:56
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-)

Re: Marstek Battery plugin

Posted: Wednesday 23 July 2025 14:00
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.

Re: Marstek Battery plugin

Posted: Wednesday 23 July 2025 14:03
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:

Re: Marstek Battery plugin

Posted: Wednesday 23 July 2025 14:08
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

Re: Marstek Battery plugin

Posted: Wednesday 23 July 2025 21:57
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 ?

Re: Marstek Battery plugin

Posted: Thursday 24 July 2025 8:53
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.

Re: Marstek Battery plugin

Posted: Saturday 26 July 2025 15:43
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 ?

Re: Marstek Battery plugin

Posted: Saturday 26 July 2025 20:11
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)

Re: Marstek Battery plugin

Posted: Saturday 26 July 2025 22:48
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

Re: Marstek Battery plugin

Posted: Sunday 27 July 2025 23:35
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).

Re: Marstek Battery plugin

Posted: Friday 01 August 2025 19:33
by eddieb
So today I received my PUSR-DR134

setting up needed a windows laptop here because the PUSR-DR134 default does NOT use dhcp but starts on 192.168.0.7 ...
after using the setuptool from the PUSR website on windows it is working on DHCP

following the instructions on https://github.com/RneeJ/Domoticz-Marstek worked until the mqttmapper part ...

below is the capture in mqttexplorer, refreshes every second as intended...

Code: Select all

{"params":{"dir":"up","id":"02103225071800005978","r_data":[{"name":"batterySOC","value":"100","err":"0"},{"name":"ACpower","value":"0","err":"0"},{"name":"MTCE","value":"10183","err":"0"},{"name":"MTDE","value":"7888","err":"0"},{"name":"MIT","value":"383","err":"0"}]}}
devices are created, and not updated ...
Screenshot 2025-08-01 at 19.37.38.png
Screenshot 2025-08-01 at 19.37.38.png (140.85 KiB) Viewed 2449 times

Marstek.json (exactly as on the github page)

Code: Select all

{
        "MPWR": {
                "topic": "Marstek",
                "key":"MPWR",
                "type": "243", "subtype": "29", "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}
        },
        "MTCE": {
                "topic": "Marstek",
                "key":"MTCE",
                "type": "113", "subtype": "0", "switchtype": "3",
                "mapping": {"item": "params/r_data/3/value", "multiplier": 0.01, "digits": 2}
        },
        "MTDE": {
                "topic": "Marstek",
                "key":"MTDE",
                "type": "113", "subtype": "0", "switchtype": "3",
                "mapping": {"item": "params/r_data/4/value", "multiplier": 0.01, "digits": 2}
        },
        "MIT": {
                "topic": "Marstek",
                "key":"MIT",
                "type": "80", "subtype": "5", "switchtype": "0",
                "mapping": {"item": "params/r_data/5/value", "multiplier": 0.1, "digits": 1}
        },
        "Battery": {
                "topic": "Marstek",
                "key":"Battery",
                "type": "250", "subtype": "1", "switchtype": "0",
                "mapping": {"item" : "params/r_data/3/value;~0;params/r_data/4/value;~0;~0;~0", "multiplier": 10, "digits": 2}
        }
}
suggestions ???

Re: Marstek Battery plugin

Posted: Friday 01 August 2025 20:43
by FlyingDomotic
What does contain the MQTT "marstek" topic?