Control of Victron Battery Discharge and Grid Power Management via MODBUS

I want to control Victron so that I can decide when Victron is allowed to discharge the batteries at night or instead draw energy from the grid.

As I found out, I can achieve this via MODBUS registers 2704 and 2705.

As soon as I set register 2704 to 0, the system starts drawing from the grid. Additionally, I need to set register 2705 to 0 so that the battery is not charged from the grid.

This works quite well. Unfortunately, the “return” to the original state doesn’t work as smoothly. For that, I would first reset register 2704 to “-1”, and then set register 2705 to “-1”.

In practice, however, this doesn’t work. Register 2705 can be set to -1 via the value 65535 without any issues, but not register 2704. It seems I can only set 2704 to 0, but not to -1.

What am I doing wrong, or which register do I need to address to disable “limit inverter power”?

Please don’t get me wrong, I want to program this cleanly, so no “tricks” like setting register 2704 to 10,000 watts or something like that.