Marstek Battery plugin Topic is solved

Python and python framework

Moderator: leecollings

eddieb
Posts: 357
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 »

Sorry, what do you mean ?
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: 357
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 »

found it !

had /Marstek as topic, it seems to be working now
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: 46
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 »

you have to leave out the slashes !

happy to hear you got it working to!

you can easily add your own readings from registers.
Domoticz on Docker on Raspberry PI 5 with 500 Gb NVMe|Milight|KaKu + RFXCOM|Goodwe|Smartstuff P1 meter|Buienradar|Afval kalender|Tuya|Zigbee + deCONZ Conbee II|Marstek Homebattery 5,12Kwh via Modbus on Pusr-dr134|MQTTMapper|Quatt v2|
eddieb
Posts: 357
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 »

Hi @RNEE
it is indeed working. But, not all, for example :
MPWR is not returning any value thru mqttmapper...

Code: Select all

{"params":{"dir":"up","id":"02103225071800005978","r_data":[{"name":"batterySOC","value":"31","err":"0"},{"name":"ACpower","value":"289","err":"0"},{"name":"MTCE","value":"10185","err":"0"},{"name":"MTDE","value":"8243","err":"0"},{"name":"MIT","value":"385","err":"0"}]}}
Screenshot 2025-08-02 at 05.30.11.png
Screenshot 2025-08-02 at 05.30.11.png (28.05 KiB) Viewed 241 times
the MQTT message shows a value of 239, which is not displayed.
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: 46
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 that too.

But the power is displayed correctly in energy dashboard (and calculated with) and on my dashboard (when starred) and on the setup>devices tab.

Image

I dont know why the values can’t be seen in the forementioned device itself, there is also no logging.
I tried different device numbers but this one worked best.

(And yes i still use the default dasboard….)
Domoticz on Docker on Raspberry PI 5 with 500 Gb NVMe|Milight|KaKu + RFXCOM|Goodwe|Smartstuff P1 meter|Buienradar|Afval kalender|Tuya|Zigbee + deCONZ Conbee II|Marstek Homebattery 5,12Kwh via Modbus on Pusr-dr134|MQTTMapper|Quatt v2|
eddieb
Posts: 357
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 »

Ok,
the reason for not showing up is that an attribute is not filled for this device.
each device type has a certain amount of attributes that can be filled.
I still can not find a list of devices with there attributes and how to fill them ...
in the dzevents examples there is

Code: Select all

        -- kWh, Electricity (instant and counter)
        --      actualWatt: Number. Actual usage in Watt.
        --      counterToday: Number.
        --      updateElectricity(power, energy): Function. Supports command options.
        --      usage: Number.
        --      WhToday: Number. Total Wh usage of the day. Note the unit is Wh and not kWh!
        --      WhTotal: Number. Total Wh usage.
        --      WhActual: Number. Actual reading in Watt. Please use actualWatt
and

Code: Select all

        -- P1 Smart meter
        --    counterDeliveredToday: Number.
        --    counterToday: Number.
        --    usage1, usage2: Number.
        --    return1, return2: Number.
        --    updateP1(usage1, usage2, return1, return2, cons, prod): Function. Updates the device. Supports command options.
        --    usage: Number.
        --    usageDelivered: Number.
but I don't know if that is the way to go, perhaps one of the more experianced people around here ...
we need to map those values from mqttmapper ...
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
User avatar
waltervl
Posts: 5969
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Marstek Battery plugin

Post by waltervl »

Do not use dzvents as a reference here but the Domoticz API calls.
Your MPWR device is an General kwh (or electricity instant+counter) device.
It needs 2 inputs: https://wiki.domoticz.com/Domoticz_API/ ... d_counter)
POWER = current power (W)
ENERGY = Integer, total cumulative energy in Watt-hours (Wh)
(Energy Read type (use edit button to change): Default: From Device. If the device is not able to send the ENERGY counter values you choose "Energy read : Computed". This will ignore ENERGY counter values and Domoticz will calculate the Energy (kWh) internally based on the (previous/current) POWER (Watt) values. By design this is less accurate then using the ENERGY counter when using them "from Device".)

Domoticz will calculate the today values based on the delta's in the total cumulative energy of today.

For Counters the standard counter dividers apply (menu setup - settings - tab counters)

Note: This device will show in Domoticz as type "General, kWh"
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: 357
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 »

tnx @walthervl

Code: Select all

http://IP/json.htm?type=command&param=getdevices&rid=225
that is the battery device, gives (not complete)

Code: Select all

{
			"AddjMulti" : 1.0,
			"AddjMulti2" : 1.0,
			"AddjValue" : 0.0,
			"AddjValue2" : 0.0,
			"BatteryLevel" : 255,
			"Counter" : "102.150",
			"CounterDeliv" : "83.230",
			"CounterDelivToday" : "2.430 kWh",
			"CounterToday" : "0.300 kWh",
			"CustomImage" : 0,
			"Data" : "102150.0;0;83230.0;0;0;0",
			"Description" : "",
			"Favorite" : 0,
			"HardwareDisabled" : false,
			"HardwareID" : 14,
			"HardwareName" : "Marstek",
			"HardwareType" : "MQTT mapper with network interface",
			"HardwareTypeVal" : 94,
			"HaveTimeout" : false,
			"ID" : "Battery",
			"LastUpdate" : "2025-08-02 10:23:34",
			"Name" : "Marstek - Battery",
			"Notifications" : "false",
			"PlanID" : "18",
			"PlanIDs" : 
			[
				18
			],
			"Protected" : false,
			"ShowNotifications" : true,
			"SignalLevel" : "-",
			"SubType" : "Energy",
			"SwitchTypeVal" : 0,
			"Timers" : "false",
			"Type" : "P1 Smart Meter",
			"TypeImg" : "counter",
			"Unit" : 6,
			"Usage" : "0 Watt",
			"UsageDeliv" : "0 Watt",
			"Used" : 1,
			"XOffset" : "0",
			"YOffset" : "0",
			"idx" : "225",
			"price" : "-0.5190"
		}
	
in the Data attribute, not all is filled ...

same for the MPWR ...

Code: Select all

{
			"AddjMulti" : 1.0,
			"AddjMulti2" : 1.0,
			"AddjValue" : 0.0,
			"AddjValue2" : 0.0,
			"BatteryLevel" : 255,
			"CustomImage" : 0,
			"Data" : "-91, -91.0",
			"Description" : "",
			"EnergyMeterMode" : "",
			"Favorite" : 0,
			"HardwareDisabled" : false,
			"HardwareID" : 14,
			"HardwareName" : "Marstek",
			"HardwareType" : "MQTT mapper with network interface",
			"HardwareTypeVal" : 94,
			"HaveTimeout" : false,
			"ID" : "MPWR",
			"LastUpdate" : "2025-08-02 10:24:52",
			"Name" : "Marstek - MPWR",
			"Notifications" : "false",
			"PlanID" : "18",
			"PlanIDs" : 
			[
				18
			],
			"Protected" : false,
			"ShowNotifications" : true,
			"SignalLevel" : "-",
			"SubType" : "kWh",
			"SwitchTypeVal" : 0,
			"Timers" : "false",
			"Type" : "General",
			"TypeImg" : "current",
			"Unit" : 1,
			"Used" : 1,
			"XOffset" : "0",
			"YOffset" : "0",
			"idx" : "220"
		}
Both fields in the Data attribute contain a value, not sure why it is not displaying them
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: 46
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 »

@eddib : ive gone through al that, but the final result was not usable for the task.
i can accept that something doen't work in one way , but works great for my needs.


@waltervl , there is only one value. any other counter that is useable? (also in the power dashboard)
Domoticz on Docker on Raspberry PI 5 with 500 Gb NVMe|Milight|KaKu + RFXCOM|Goodwe|Smartstuff P1 meter|Buienradar|Afval kalender|Tuya|Zigbee + deCONZ Conbee II|Marstek Homebattery 5,12Kwh via Modbus on Pusr-dr134|MQTTMapper|Quatt v2|
User avatar
waltervl
Posts: 5969
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 value is available from Marstek, the power (in Watt) or the total counter of energy (in Wh)?

if the power is missing then use a normal counter device.
If the energy is missing you could send energy as hardcoded 0 and put the device on computer so it will calculate the energy from the given powers over time.
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: 46
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 actual power in watt is avaiable , in my opinion wh does not work here. These are different values and are read in the P1 device.

For me the current results are fine they show me exactly what i want , per second.

We should not forget this is basicly a work around.

But i like it that much, and trust its outcome, that my next project will be my Goodwe convertor. I already orderd a dr134.
There is a very nice programm by Janjaap for reading the Goodwe Api but data in the Goodwe cloud are old, and sometime not avaiable.

Data for grid and battery are on a near real time basis, for my solarpanels are minuts behind.
That makes the energy dashboard useless.
Domoticz on Docker on Raspberry PI 5 with 500 Gb NVMe|Milight|KaKu + RFXCOM|Goodwe|Smartstuff P1 meter|Buienradar|Afval kalender|Tuya|Zigbee + deCONZ Conbee II|Marstek Homebattery 5,12Kwh via Modbus on Pusr-dr134|MQTTMapper|Quatt v2|
User avatar
waltervl
Posts: 5969
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Marstek Battery plugin

Post by waltervl »

To get a proper display of the Watt you can still use this type of Domoticz device but you have to send 2 values to the device to get proper display. The energy value can always be 0.
Or use the electricity usage device that only uses the Watt value, but that has no history logging....
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: 46
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 that did it :
Changed MPWR to : "mapping": {"item": "params/r_data/2/value;~0", "multiplier": -1, "digits": 1}

Now the actual power value is displayed in the device mentioned before : T: 0.000 kWh, A: -467 Watt.

Since the power is positive and negative Total will be the balance (loss went to heat)

I prefer the data from the P1 Battery device witch splits positive and negative and show really nice graphs.

Edit :
have it running now for some time, but results (total and graph, settings>device tab) are confusing, i personally will not use the new representation.
Domoticz on Docker on Raspberry PI 5 with 500 Gb NVMe|Milight|KaKu + RFXCOM|Goodwe|Smartstuff P1 meter|Buienradar|Afval kalender|Tuya|Zigbee + deCONZ Conbee II|Marstek Homebattery 5,12Kwh via Modbus on Pusr-dr134|MQTTMapper|Quatt v2|
Haaibaai
Posts: 1
Joined: Sunday 03 August 2025 14:22
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Marstek Battery plugin

Post by Haaibaai »

Do I really need the Ethernet version of PUser for this to work, can it also work with the WIFI version? My batteries are in my garage and I don't really want to connect Ethernet to the garage as it would involve drilling a hole in the ground.
eddieb
Posts: 357
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 also have a wifi version of the adapter, I will power it on and compare
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: 357
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 just tried the PUSR-DR164 and at least the menu's are totally different.
I doubt if that one is going to work, perhaps some other device ????

there is some mqtt but no "point" menu where the modbus registers can be configured
no edge menu either ...
Screenshot 2025-08-03 at 15.21.18.png
Screenshot 2025-08-03 at 15.21.18.png (227.98 KiB) Viewed 105 times
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: 46
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 dr164 too and it hasn’t edgecomputing.

Only the latest dr134 has it.

I asked Puser and they confirmed that. I told them there could be a hugh demand for an edgecomputing wifi device.
Maybe in the future.

You can use a ethernet powerline adapter. TP-link has several sets.
I tested one set already for mij solarpanels and that worked well.
Domoticz on Docker on Raspberry PI 5 with 500 Gb NVMe|Milight|KaKu + RFXCOM|Goodwe|Smartstuff P1 meter|Buienradar|Afval kalender|Tuya|Zigbee + deCONZ Conbee II|Marstek Homebattery 5,12Kwh via Modbus on Pusr-dr134|MQTTMapper|Quatt v2|
eddieb
Posts: 357
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 also use a powerline adapter to get to my garage where my Marstek is ...
the wifi part of that powerline adapter makes the Marstel connection to my wifi way more stable too !!!
So it is just waiting for PUSR to release firmware for the DR164 that supports the same as the DR134
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: 46
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 am drilling holes everywhere in my , before ethernet, house to get cat5e everywhere.

But for the Marstek in the garage it was quite easy as my meterkast is directly connected to the garage. Just 2 holes, one for ethernet and one for connecting to a free 16amp group, where needed.

i am looking into a solution for the dr164. But i have to many projects and to little time.

Edit : i’am not using the Marstek app anymore…
Domoticz on Docker on Raspberry PI 5 with 500 Gb NVMe|Milight|KaKu + RFXCOM|Goodwe|Smartstuff P1 meter|Buienradar|Afval kalender|Tuya|Zigbee + deCONZ Conbee II|Marstek Homebattery 5,12Kwh via Modbus on Pusr-dr134|MQTTMapper|Quatt v2|
eddieb
Posts: 357
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 »

it would be nice if USR woulld combine the DR134 software with wifi and release an update for the DR164 that includes the functions needed ...
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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest