Add common voltage to generic energy modbus driver

This commit is contained in:
Theo Arends 2022-10-06 23:26:54 +02:00
parent a1420e06fd
commit 77cfe80064
1 changed files with 4 additions and 1 deletions

View File

@ -194,6 +194,7 @@ bool EnergyModbusReadRegisters(void) {
// rule3 on file#modbus do {"name":"SDM230","baud":2400,"config":8N1","address":1,"function":4,"voltage":0,"current":6,"active_power":12,"apparent_power":18,"reactive_power":24,"power_factor":30,"frequency":70,"import_active_energy":342} endon
// rule3 on file#modbus do {"name":"SDM230 test1","baud":2400,"config":8N1","address":1,"function":4,"voltage":[0,0,0],"current":[6,6,6],"active_power":[12,12,12],"apparent_power":[18,18,18],"reactive_power":[24,24,24],"power_factor":[30,30,30],"frequency":[70,70,70],"import_active_energy":[342,342,342]} endon
// rule3 on file#modbus do {"name":"SDM230 test2","baud":2400,"config":8N1","address":1,"function":4,"voltage":[0,0,0],"current":[6,6,6],"active_power":[12,12,12],"apparent_power":[18,18,18],"reactive_power":[24,24,24],"power_factor":[30,30,30],"frequency":70,"import_active_energy":[342,342,342]} endon
// rule3 on file#modbus do {"name":"SDM230 test2","baud":2400,"config":8N1","address":1,"function":4,"voltage":0,"current":[6,6,6],"active_power":[12,12,12],"apparent_power":[18,18,18],"reactive_power":[24,24,24],"power_factor":[30,30,30],"frequency":70,"import_active_energy":[342,342,342]} endon
const char* json = modbus.c_str();
uint32_t len = strlen(json) +1;
@ -257,10 +258,12 @@ bool EnergyModbusReadRegisters(void) {
phase++;
}
if (phase) {
if (phase > Energy.phase_count) {
Energy.phase_count = phase;
}
switch(names) {
case NRG_MBS_VOLTAGE:
Energy.voltage_available = true; // Enable if voltage is measured
Energy.phase_count = phase;
if (1 == phase) {
Energy.voltage_common = true; // Use common voltage
}