Step-by-step instructions for exemplary SMA example
Configuring Maximum AC Power Limit on the TP25000 in FHEM
This article explains how to configure a FHEM device using the ModbusAttr module to:
Read the current AC power (GridMs.TotW) from a TP25000 inverter. Set (write) the maximum AC power limit (Pmax) into the inverter.
In our example, the device is renamed to AB_PV17_STP25000_MaxAC and the target maximum power is set to 2000 W.
Step 1: Define the Device as a Modbus Master
The device is defined as a Modbus master that polls every 60 seconds via TCP:
define AB_PV17_STP25000_MaxAC ModbusAttr 3 60 192.168.29.182:502 TCP
attr AB_PV17_STP25000_MaxAC dev-h-defPoll 1
AB_PV17_STP25000_MaxAC: Name of the FHEM device.
ModbusAttr 3 60 192.168.9.182:502 TCP: Sets the device as a Modbus master with ID 3, polling every 60 seconds using Modbus TCP to the IP address 192.168.9.182 on port 502.
dev-h-defPoll 1: Ensures the device is polled regularly.
Step 2: Configure the Read Object for the Current AC Power
The current power value is read from the holding register at address 30775 (GridMs.TotW):
attr AB_PV17_STP25000_MaxAC obj-h30775-reading actAC
attr AB_PV17_STP25000_MaxAC obj-h30775-len 2
attr AB_PV17_STP25000_MaxAC obj-h30775-unpack N
obj-h30775-reading actAC: Reads the current power value from register 30775 and stores it in the reading named actAC.
obj-h30775-len 2: Indicates that 2 registers (32 bits) are read.
obj-h30775-unpack N: Decodes the 32‑bit value as an unsigned integer in Big‑Endian format.
Step 3: Configure the Write Object for the Maximum AC Power Limit
The maximum AC power (Pmax) is written into the holding register at address 40915 (Inverter.WMax):
attr AB_PV17_STP25000_MaxAC obj-h40915-reading maxAC
attr AB_PV17_STP25000_MaxAC obj-h40915-len 2
attr AB_PV17_STP25000_MaxAC obj-h40915-unpack N
attr AB_PV17_STP25000_MaxAC obj-h40915-set 1
attr AB_PV17_STP25000_MaxAC obj-h40915-setexpr $val
attr AB_PV17_STP25000_MaxAC obj-h40915-showGet 1
obj-h40915-reading maxAC: Reads/writes the target maximum power value from register 40915 and stores it in the reading maxAC.
obj-h40915-len 2: Specifies that 2 registers (32 bits) are used.
obj-h40915-unpack N: Decodes the 32‑bit value as unsigned in Big‑Endian format.
obj-h40915-set 1: Enables writing to this object.
obj-h40915-setexpr $val: Passes the entered value directly to the register.
obj-h40915-showGet 1: Causes an input field for the set command to appear in the web interface.
Step 4: Set the Maximum AC Power
To limit the maximum AC power to 2000 W, execute:
set AB_PV17_STP25000_MaxAC maxAC 2000
This command writes the value 2000 into register 40915, thereby setting the maximum AC power limit to 2000 W.
Summary
The device AB_PV17_STP25000_MaxAC is configured using the ModbusAttr module to:
Read the current AC power from registers starting at 30775 (2 registers, 32 bits) and store it as actAC.
Write the maximum AC power limit into registers starting at 40915 (2 registers, 32 bits).
With obj-h40915-showGet 1, an input field appears in the web interface so that you can directly enter a new value.
To monitor the current power, use:
get AB_PV17_STP25000_MaxAC actAC
To set the maximum power to 2000 W, use:
set AB_PV17_STP25000_MaxAC maxAC 2000