ele-dev / Huawei-PSU-Regulator

An automatic power regulator for linux systems
GNU General Public License v3.0
2 stars 0 forks source link

[Feature] Extend energy meter interface and add Modbus/TCP as alternative to UDP #12

Open ele-dev opened 1 month ago

ele-dev commented 1 month ago

The non blocking UDP listener works very well but is very specialized to my personal setup with the Berry script running the tasmota energy meter. A more generic interfaces class for energy meters would allow implementation of additional protocols such as HTTP or Modbus/TCP for other energymeters (e.g. Shelly Pro 3em)

ele-dev commented 1 month ago

POC for a Modbus/TCP client in C++ with libmodbus-dev was successfully tested on WSL2 with a Shelly Pro 3em.

ele-dev commented 1 month ago

First local build of the energy manager with modbus powermeter support is finished and will undergo testing

ele-dev commented 1 month ago

Basic tests passed. After some hours sometimes it suddenly receives invalid modbus data and does not auto recover from it yet. Taken measures:

ele-dev commented 1 month ago

Modbus polling issues remain a consistent problem. After a few hours of stable operation the Invalid Data error reappears without a logical explanation. One more idea would be to set a higher request-response-timeout and hope it will become more durable. It's concerning because I can't even be sure wether it's actually something wrong in my code or if the shelly modbus firmware might need patches. An auto reconnect is planned to at least temporarily have a working system again.

ele-dev commented 3 weeks ago

a python modbusclient has proven that is is a connection or firmware problem of the shelly. auto connection recovery and optional TCP keepalive has been implemented for Modbus/TCP