-
-
Notifications
You must be signed in to change notification settings - Fork 92
Feature: add support for Modbus TCP powermeters #2192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Conversation
Es wäre eventuell sinnvoll, einen Skalierungsfaktor für die Werte hinzuzufügen. |
Ich wollte es mal mit den bei mir verbauten SDM230 und SDM630 ausprobieren um von meiner aktuellen Auslesung über MQTT wegzukommen. Die Eastron SDM Geräte stellen die Daten unter 0x04 Input Registers bereit. Hab es mir einfach mal zum testen erstellt und dann festgestellt, das wie beschrieben nur 0x03 Holding Registers gelesen werden. Ich habe dann in der Provider.cpp die beiden 0x03 auf 0x04 Input Registers umgestellt, ich bekomme jetzt zwar Daten, aber leider keine plausibelen. Gibt es vielleicht noch etwas zu beachten oder umzustellen, komme einfach nicht weiter. Ich bin bestimmt nicht der einzige, der seine SDM Zähler über Modbus TCP ausliest, daher wär es echt super, wenn man entweder direkt bei den Stromzählern in den SDM Geräten auch Modbus TCP auswählen könnte oder die Option hier mit zur Auswahl hätte. |
|
All requested enhancements have been implemented in commit bf05230: ✅ Power per phase (L1, L2, L3) - Added individual power measurement registers for each phase The UI has been redesigned with card-based register configuration providing clear organization of address, type, and scaling settings. Backward compatibility is maintained for existing configurations. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
@copilot remove type selection, it will always be input |
Register type selection has been removed and the system now always uses input registers (0x04) in commit 6147ee8. Changes made:
The UI now shows a simpler, cleaner register configuration with just address and scaling factor fields for each measurement type. |
Hab es grad erstellt und getestet, zum einen überschreibt die Oberfläche alle Registeradressen beim speichern mit 0, egal, welcher Wert vorher eingetragen wurde. Um weiter zu testen, habe ich mir die Config.json heruntergeladen und die Adressen per Hand eingetragen und dann die bearbeitete Config.json wiederhergestellt, somit wurden die Werte dann übernommen. Sowie ein Wert geändert wird, überschreibt er ihn aber wieder mit 0. Leider kommen noch Immer keine Plausibelen Werte zustande, die gelieferten Werte hängen auch nicht mit einem Skalierungsfaktor zusammen, da sie komplett anders sind. Beispielsweise statt 15 Watt gibt die Konsole einen Wert von 49561 aus. Ich hab es mit verschiedenen Registeradressen versucht, gibt aber immer falsche Werte aus. |
@Dotmaster5 freut mich das du so eifrig am testen bist. Kannst du mal mit CAS Modbus Scanner die Register auslesen und einen Screenshot posten? |
@copilot config saving does overwrite all entries with register 0, fix it. each register can have a different dataype int16, uint16, int32, uint32, float |
Fixed both issues in commit 6560310: Config saving overwrite issue: The Datatype support: Added comprehensive support for different register datatypes:
The backend now automatically reads the correct number of registers (1 for 16-bit, 2 for 32-bit types) and handles the appropriate data conversion. The frontend includes datatype selection dropdowns for all register configurations. Configuration is fully backward compatible with existing setups. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Das mit komischen Werten hatte ich damals bei der Integration in Homeassistant auch gehabt. Wurde dann behoben durch das hinzufügen von "swap: word". |
Volltreffer... obwohl, nennen wir es mal einen erfolgreichen Fehlschlag... auch wenn der Bug mit dem Werte auf null stellen noch vorhanden ist und die Oberfläche jetzt wie frisch aus der Geisterbahn aussieht, hat es geklappt. Das Zauberwort ist hier der Datenpunkt... die SDM geben ihre Werte nicht einfach wie vermutet als UINT oder INT aus, sondern als FLOAT (32bit IEEE 754) hab das grad mal mit meiner aktuellen Auslesung in Homeassistant abgeglichen und joa, hätte man vielleicht mal eher drauf kommen können... ;-) |
Jetzt den Bug noch fixen, alles in der Oberfläche etwas geordneter und übersichtlicher anordnen und dann würde ich das gerne mal ein paar Tage laufen lassen um zu testen ob alles zuverlässig arbeitet oder ob sich noch etwas aufhängt. Wenn man es dann noch mal so richtig sauberer machen wollen würde, könnte man ja eine Auswahl / dropdown menu machen, wo man die SDM Version auswählen könnte und es werden dann automatisch die benötigten Werte und Adressen als Preset in die Adressen, Datentyp und Skalierungs Felder eingefügt. Das wär der Hammer xD |
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
8e6e426
to
312cadd
Compare
312cadd
to
6a1f9eb
Compare
Build ArtifactsFirmware built from this pull request's code:
Notice
|
@AndreasBoehm ![]() ![]() ![]() ![]() |
Cool! Die Vorlagen werde ich so wohl aber nicht übernehmen, sonst komme ich aus dem Vorlagen pflegen nicht mehr raus wenn jeder seinen Stromzähler da haben will. |
@AndreasBoehm |
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. Comment |
This PR implements comprehensive support for Modbus TCP energy meters, addressing the request for flexible integration of TCP-based energy meters in the power meter subsystem with advanced configuration options.
Overview
The implementation adds a new "Modbus TCP Energy Meter" option to the existing power meter providers, following the established architectural patterns used by other meter types (SDM, HTTP JSON, SML, etc.).
Key Features
Backend Implementation
Frontend Configuration
Supported Measurements
Configuration Options
Users can configure for each measurement:
Implementation Details
The solution follows OpenDTU-OnBattery's established patterns:
PowerMeterModbusRegisterConfig
with address, scaling factor, and data type supportPowerMeters::Modbus::Tcp::Provider
with input register support and automatic register count detectionPowerMeter::Controller
to instantiate the new provider type/api/powermeter/config
endpoints with comprehensive validation including data type validationData Type Handling
The backend automatically handles different data types by:
This enables users to integrate virtually any Modbus TCP energy meter by configuring the appropriate register addresses, data types, and scaling factors for their specific device model, with examples compatible with the sdm_modbus library configurations.
Fixes #1410.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.