diff --git a/.gitignore b/.gitignore index db1e0a68f..eabba8255 100644 --- a/.gitignore +++ b/.gitignore @@ -8,5 +8,5 @@ .piolibdeps .clang_complete .gcc-flags.json -.vscode sonoff/user_config_override.h +build diff --git a/sonoff/i18n.h b/sonoff/i18n.h index ea626017c..d0926e4c7 100644 --- a/sonoff/i18n.h +++ b/sonoff/i18n.h @@ -88,6 +88,9 @@ #define D_JSON_PERIOD "Period" #define D_JSON_POWERFACTOR "Factor" #define D_JSON_POWERUSAGE "Power" +#define D_JSON_ACTIVE_POWERUSAGE "ActivePower" +#define D_JSON_APPARENT_POWERUSAGE "ApparentPower" +#define D_JSON_REACTIVE_POWERUSAGE "ReactivePower" #define D_JSON_PRESSURE "Pressure" #define D_JSON_PRESSUREATSEALEVEL "SeaPressure" #define D_JSON_PROGRAMFLASHSIZE "ProgramFlashSize" diff --git a/sonoff/language/bg-BG.h b/sonoff/language/bg-BG.h index dfaebe802..ebc9d82cd 100644 --- a/sonoff/language/bg-BG.h +++ b/sonoff/language/bg-BG.h @@ -121,6 +121,9 @@ #define D_PORT "Порт" #define D_POWER_FACTOR "Фактор на мощността" #define D_POWERUSAGE "Мощност" +#define D_POWERUSAGE_ACTIVE "Active Power" +#define D_POWERUSAGE_APPARENT "Apparent Power" +#define D_POWERUSAGE_REACTIVE "Reactive Power" #define D_PRESSURE "Налягане" #define D_PRESSUREATSEALEVEL "Налягане на морското ниво" #define D_PROGRAM_FLASH_SIZE "Размер на флаш паметта за програми" @@ -479,6 +482,8 @@ #define D_UNIT_PRESSURE "хПа" #define D_UNIT_SECOND "сек" #define D_UNIT_SECTORS "сектори" +#define D_UNIT_VA "VA" +#define D_UNIT_VAR "VAr" #define D_UNIT_VOLT "В" #define D_UNIT_WATT "Вт" #define D_UNIT_WATTHOUR "Вт/ч" diff --git a/sonoff/language/cs-CZ.h b/sonoff/language/cs-CZ.h index 49239eef8..73e2098c5 100644 --- a/sonoff/language/cs-CZ.h +++ b/sonoff/language/cs-CZ.h @@ -121,6 +121,9 @@ #define D_PORT "Port" #define D_POWER_FACTOR "Účiník" #define D_POWERUSAGE "Příkon" +#define D_POWERUSAGE_ACTIVE "Active Power" +#define D_POWERUSAGE_APPARENT "Apparent Power" +#define D_POWERUSAGE_REACTIVE "Reactive Power" #define D_PRESSURE "Tlak" #define D_PRESSUREATSEALEVEL "Tlak na úrovni hladiny moře" #define D_PROGRAM_FLASH_SIZE "Velikost paměti flash" @@ -479,6 +482,8 @@ #define D_UNIT_PRESSURE "hPa" #define D_UNIT_SECOND "sec" #define D_UNIT_SECTORS "sektory" +#define D_UNIT_VA "VA" +#define D_UNIT_VAR "VAr" #define D_UNIT_VOLT "V" #define D_UNIT_WATT "W" #define D_UNIT_WATTHOUR "Wh" diff --git a/sonoff/language/de-DE.h b/sonoff/language/de-DE.h index 0201e00ed..35a9f3dad 100644 --- a/sonoff/language/de-DE.h +++ b/sonoff/language/de-DE.h @@ -121,6 +121,9 @@ #define D_PORT "Port" #define D_POWER_FACTOR "Leistungsfaktor" #define D_POWERUSAGE "Leistung" +#define D_POWERUSAGE_ACTIVE "Active Power" +#define D_POWERUSAGE_APPARENT "Apparent Power" +#define D_POWERUSAGE_REACTIVE "Reactive Power" #define D_PRESSURE "Luftdruck" #define D_PRESSUREATSEALEVEL "Luftdruck auf Meereshöhe" #define D_PROGRAM_FLASH_SIZE "Ges. Flash Speicher" @@ -479,6 +482,8 @@ #define D_UNIT_PRESSURE "hPa" #define D_UNIT_SECOND "sek" #define D_UNIT_SECTORS "Sektoren" +#define D_UNIT_VA "VA" +#define D_UNIT_VAR "VAr" #define D_UNIT_VOLT "V" #define D_UNIT_WATT "W" #define D_UNIT_WATTHOUR "Wh" diff --git a/sonoff/language/el-GR.h b/sonoff/language/el-GR.h index c479b3586..e23f629b0 100644 --- a/sonoff/language/el-GR.h +++ b/sonoff/language/el-GR.h @@ -121,6 +121,9 @@ #define D_PORT "Πόρτα" #define D_POWER_FACTOR "Παράγοντας ισχύος" #define D_POWERUSAGE "Ισχύης" +#define D_POWERUSAGE_ACTIVE "Active Power" +#define D_POWERUSAGE_APPARENT "Apparent Power" +#define D_POWERUSAGE_REACTIVE "Reactive Power" #define D_PRESSURE "Πίεση" #define D_PRESSUREATSEALEVEL "Πίεση στην επιφάνεια της Θάλασσας" #define D_PROGRAM_FLASH_SIZE "Μέγεθος Προγράμματος Flash" @@ -479,6 +482,8 @@ #define D_UNIT_PRESSURE "hPa" #define D_UNIT_SECOND "sec" #define D_UNIT_SECTORS "sectors" +#define D_UNIT_VA "VA" +#define D_UNIT_VAR "VAr" #define D_UNIT_VOLT "V" #define D_UNIT_WATT "W" #define D_UNIT_WATTHOUR "Wh" diff --git a/sonoff/language/en-GB.h b/sonoff/language/en-GB.h index b841f02d5..4f97a5eef 100644 --- a/sonoff/language/en-GB.h +++ b/sonoff/language/en-GB.h @@ -121,6 +121,9 @@ #define D_PORT "Port" #define D_POWER_FACTOR "Power Factor" #define D_POWERUSAGE "Power" +#define D_POWERUSAGE_ACTIVE "Active Power" +#define D_POWERUSAGE_APPARENT "Apparent Power" +#define D_POWERUSAGE_REACTIVE "Reactive Power" #define D_PRESSURE "Pressure" #define D_PRESSUREATSEALEVEL "SeaPressure" #define D_PROGRAM_FLASH_SIZE "Program Flash Size" @@ -478,6 +481,8 @@ #define D_UNIT_PRESSURE "hPa" #define D_UNIT_SECOND "sec" #define D_UNIT_SECTORS "sectors" +#define D_UNIT_VA "VA" +#define D_UNIT_VAR "VAr" #define D_UNIT_VOLT "V" #define D_UNIT_WATT "W" #define D_UNIT_WATTHOUR "Wh" diff --git a/sonoff/language/es-AR.h b/sonoff/language/es-AR.h index a0f80b73f..2e3eb49ca 100644 --- a/sonoff/language/es-AR.h +++ b/sonoff/language/es-AR.h @@ -121,6 +121,9 @@ #define D_PORT "Puerto" #define D_POWER_FACTOR "Factor de Potencia" #define D_POWERUSAGE "Potencia" +#define D_POWERUSAGE_ACTIVE "Active Power" +#define D_POWERUSAGE_APPARENT "Apparent Power" +#define D_POWERUSAGE_REACTIVE "Reactive Power" #define D_PRESSURE "Presión" #define D_PRESSUREATSEALEVEL "Presión al nivel del mar" #define D_PROGRAM_FLASH_SIZE "Tamaño de Flash de Programa" @@ -479,6 +482,8 @@ #define D_UNIT_PRESSURE "hPa" #define D_UNIT_SECOND "seg" #define D_UNIT_SECTORS "sectores" +#define D_UNIT_VA "VA" +#define D_UNIT_VAR "VAr" #define D_UNIT_VOLT "V" #define D_UNIT_WATT "W" #define D_UNIT_WATTHOUR "Wh" diff --git a/sonoff/language/fr-FR.h b/sonoff/language/fr-FR.h index cae6908ae..26cee81e9 100644 --- a/sonoff/language/fr-FR.h +++ b/sonoff/language/fr-FR.h @@ -121,6 +121,9 @@ #define D_PORT "Port" #define D_POWER_FACTOR "Facteur de puissance" #define D_POWERUSAGE "Puissance" +#define D_POWERUSAGE_ACTIVE "Active Power" +#define D_POWERUSAGE_APPARENT "Apparent Power" +#define D_POWERUSAGE_REACTIVE "Reactive Power" #define D_PRESSURE "Pression" #define D_PRESSUREATSEALEVEL "PressionMer" #define D_PROGRAM_FLASH_SIZE "Taille Flash Programme" @@ -479,6 +482,8 @@ #define D_UNIT_PRESSURE "hPa" #define D_UNIT_SECOND "sec" #define D_UNIT_SECTORS "secteurs" +#define D_UNIT_VA "VA" +#define D_UNIT_VAR "VAr" #define D_UNIT_VOLT "V" #define D_UNIT_WATT "W" #define D_UNIT_WATTHOUR "Wh" diff --git a/sonoff/language/hu-HU.h b/sonoff/language/hu-HU.h index 773ff3d2e..5ecab817b 100644 --- a/sonoff/language/hu-HU.h +++ b/sonoff/language/hu-HU.h @@ -121,6 +121,9 @@ #define D_PORT "Port" #define D_POWER_FACTOR "Teljesítmény tényező" #define D_POWERUSAGE "Energiafelhasználás" +#define D_POWERUSAGE_ACTIVE "Active Power" +#define D_POWERUSAGE_APPARENT "Apparent Power" +#define D_POWERUSAGE_REACTIVE "Reactive Power" #define D_PRESSURE "Nyomás" #define D_PRESSUREATSEALEVEL "Tengerszinti nyomás" #define D_PROGRAM_FLASH_SIZE "Program Flash Méret" @@ -479,6 +482,8 @@ #define D_UNIT_PRESSURE "hPa" #define D_UNIT_SECOND "m" #define D_UNIT_SECTORS "szektorok" +#define D_UNIT_VA "VA" +#define D_UNIT_VAR "VAr" #define D_UNIT_VOLT "V" #define D_UNIT_WATT "W" #define D_UNIT_WATTHOUR "Wh" diff --git a/sonoff/language/it-IT.h b/sonoff/language/it-IT.h index 2096fe8c3..91808c973 100644 --- a/sonoff/language/it-IT.h +++ b/sonoff/language/it-IT.h @@ -121,6 +121,9 @@ #define D_PORT "Porta" #define D_POWER_FACTOR "Fattore di potenza" #define D_POWERUSAGE "Potenza" +#define D_POWERUSAGE_ACTIVE "Potenza Attiva" +#define D_POWERUSAGE_APPARENT "Potenza Apparente" +#define D_POWERUSAGE_REACTIVE "Potenza Reattiva" #define D_PRESSURE "Pressione" #define D_PRESSUREATSEALEVEL "Pressione al livello del mare" #define D_PROGRAM_FLASH_SIZE "Dimensione Flash Programma" @@ -479,6 +482,8 @@ #define D_UNIT_PRESSURE "hPa" #define D_UNIT_SECOND "sec" #define D_UNIT_SECTORS "settori" +#define D_UNIT_VA "VA" +#define D_UNIT_VAR "VAr" #define D_UNIT_VOLT "V" #define D_UNIT_WATT "W" #define D_UNIT_WATTHOUR "Wh" diff --git a/sonoff/language/nl-NL.h b/sonoff/language/nl-NL.h index dec9a11de..25727e9bd 100644 --- a/sonoff/language/nl-NL.h +++ b/sonoff/language/nl-NL.h @@ -121,6 +121,9 @@ #define D_PORT "Poort" #define D_POWER_FACTOR "Arbeidsfactor" #define D_POWERUSAGE "Vermogen" +#define D_POWERUSAGE_ACTIVE "Active Power" +#define D_POWERUSAGE_APPARENT "Apparent Power" +#define D_POWERUSAGE_REACTIVE "Reactive Power" #define D_PRESSURE "Luchtdruk" #define D_PRESSUREATSEALEVEL "ZeeLuchtdruk" #define D_PROGRAM_FLASH_SIZE "Programma Flash Grootte" @@ -479,6 +482,8 @@ #define D_UNIT_PRESSURE "hPa" #define D_UNIT_SECOND "sec" #define D_UNIT_SECTORS "sectoren" +#define D_UNIT_VA "VA" +#define D_UNIT_VAR "VAr" #define D_UNIT_VOLT "V" #define D_UNIT_WATT "W" #define D_UNIT_WATTHOUR "Wh" diff --git a/sonoff/language/pl-PL.h b/sonoff/language/pl-PL.h index 5d30ffd7f..688c3507e 100644 --- a/sonoff/language/pl-PL.h +++ b/sonoff/language/pl-PL.h @@ -121,6 +121,9 @@ #define D_PORT "Port" #define D_POWER_FACTOR "Współczynik mocy" #define D_POWERUSAGE "Moc" +#define D_POWERUSAGE_ACTIVE "Active Power" +#define D_POWERUSAGE_APPARENT "Apparent Power" +#define D_POWERUSAGE_REACTIVE "Reactive Power" #define D_PRESSURE "Ciśnienie" #define D_PRESSUREATSEALEVEL "Ciśnienie na poziomie morza" #define D_PROGRAM_FLASH_SIZE "Wielkość programu flash" @@ -479,6 +482,8 @@ #define D_UNIT_PRESSURE "hPa" #define D_UNIT_SECOND "sec" #define D_UNIT_SECTORS "sektory" +#define D_UNIT_VA "VA" +#define D_UNIT_VAR "VAr" #define D_UNIT_VOLT "V" #define D_UNIT_WATT "W" #define D_UNIT_WATTHOUR "Wh" diff --git a/sonoff/language/pt-BR.h b/sonoff/language/pt-BR.h index c29cf9bd9..6bf9a6211 100644 --- a/sonoff/language/pt-BR.h +++ b/sonoff/language/pt-BR.h @@ -121,6 +121,9 @@ #define D_PORT "Porta" #define D_POWER_FACTOR "Fator de potência" #define D_POWERUSAGE "Potência" +#define D_POWERUSAGE_ACTIVE "Active Power" +#define D_POWERUSAGE_APPARENT "Apparent Power" +#define D_POWERUSAGE_REACTIVE "Reactive Power" #define D_PRESSURE "Pressão" #define D_PRESSUREATSEALEVEL "Pressão ao nível do mar" #define D_PROGRAM_FLASH_SIZE "Tamanho do programa na memória" @@ -479,6 +482,8 @@ #define D_UNIT_PRESSURE "hPa" #define D_UNIT_SECOND "s" #define D_UNIT_SECTORS "setores" +#define D_UNIT_VA "VA" +#define D_UNIT_VAR "VAr" #define D_UNIT_VOLT "V" #define D_UNIT_WATT "W" #define D_UNIT_WATTHOUR "W/h" diff --git a/sonoff/language/pt-PT.h b/sonoff/language/pt-PT.h index 4605975c3..68d7cd1c5 100644 --- a/sonoff/language/pt-PT.h +++ b/sonoff/language/pt-PT.h @@ -121,6 +121,9 @@ #define D_PORT "Porta" #define D_POWER_FACTOR "Factor de Potência" #define D_POWERUSAGE "Potência" +#define D_POWERUSAGE_ACTIVE "Active Power" +#define D_POWERUSAGE_APPARENT "Apparent Power" +#define D_POWERUSAGE_REACTIVE "Reactive Power" #define D_PRESSURE "Pressão" #define D_PRESSUREATSEALEVEL "Pressão ao nível do Mar" #define D_PROGRAM_FLASH_SIZE "Tamanho do Programa na Flash" @@ -479,6 +482,8 @@ #define D_UNIT_PRESSURE "hPa" #define D_UNIT_SECOND "sec" #define D_UNIT_SECTORS "sectors" +#define D_UNIT_VA "VA" +#define D_UNIT_VAR "VAr" #define D_UNIT_VOLT "V" #define D_UNIT_WATT "W" #define D_UNIT_WATTHOUR "Wh" diff --git a/sonoff/language/ru-RU.h b/sonoff/language/ru-RU.h index 0de9d88cc..85540343d 100644 --- a/sonoff/language/ru-RU.h +++ b/sonoff/language/ru-RU.h @@ -121,6 +121,9 @@ #define D_PORT "Порт" #define D_POWER_FACTOR "Коэффициент Мощности" #define D_POWERUSAGE "Мощность" +#define D_POWERUSAGE_ACTIVE "Active Power" +#define D_POWERUSAGE_APPARENT "Apparent Power" +#define D_POWERUSAGE_REACTIVE "Reactive Power" #define D_PRESSURE "Давление" #define D_PRESSUREATSEALEVEL "Давление на уровне моря" #define D_PROGRAM_FLASH_SIZE "Размер Flash для программ" @@ -479,6 +482,8 @@ #define D_UNIT_PRESSURE "гПа" #define D_UNIT_SECOND "сек" #define D_UNIT_SECTORS "секторов" +#define D_UNIT_VA "VA" +#define D_UNIT_VAR "VAr" #define D_UNIT_VOLT "В" #define D_UNIT_WATT "Вт" #define D_UNIT_WATTHOUR "ВтЧ" diff --git a/sonoff/language/zh-CN.h b/sonoff/language/zh-CN.h index fce4fe3e7..853c68389 100644 --- a/sonoff/language/zh-CN.h +++ b/sonoff/language/zh-CN.h @@ -121,6 +121,9 @@ #define D_PORT "端口" #define D_POWER_FACTOR "功率因数" #define D_POWERUSAGE "功率" +#define D_POWERUSAGE_ACTIVE "Active Power" +#define D_POWERUSAGE_APPARENT "Apparent Power" +#define D_POWERUSAGE_REACTIVE "Reactive Power" #define D_PRESSURE "气压" #define D_PRESSUREATSEALEVEL "海平面气压" #define D_PROGRAM_FLASH_SIZE "固件 Flash 大小" @@ -479,6 +482,8 @@ #define D_UNIT_PRESSURE "百帕" #define D_UNIT_SECOND "秒" #define D_UNIT_SECTORS "扇区" +#define D_UNIT_VA "VA" +#define D_UNIT_VAR "VAr" #define D_UNIT_VOLT "伏" #define D_UNIT_WATT "瓦" #define D_UNIT_WATTHOUR "瓦时" diff --git a/sonoff/language/zh-TW.h b/sonoff/language/zh-TW.h index f17caf10e..5986dc804 100644 --- a/sonoff/language/zh-TW.h +++ b/sonoff/language/zh-TW.h @@ -121,6 +121,9 @@ #define D_PORT "端口" #define D_POWER_FACTOR "功率因數" #define D_POWERUSAGE "功率" +#define D_POWERUSAGE_ACTIVE "Active Power" +#define D_POWERUSAGE_APPARENT "Apparent Power" +#define D_POWERUSAGE_REACTIVE "Reactive Power" #define D_PRESSURE "氣壓" #define D_PRESSUREATSEALEVEL "海平面氣壓" #define D_PROGRAM_FLASH_SIZE "韌體 Flash 大小" @@ -479,6 +482,8 @@ #define D_UNIT_PRESSURE "百帕" #define D_UNIT_SECOND "秒" #define D_UNIT_SECTORS "扇區" +#define D_UNIT_VA "VA" +#define D_UNIT_VAR "VAr" #define D_UNIT_VOLT "伏" #define D_UNIT_WATT "瓦" #define D_UNIT_WATTHOUR "瓦時" diff --git a/sonoff/user_config.h b/sonoff/user_config.h index e06d1935a..d79735572 100644 --- a/sonoff/user_config.h +++ b/sonoff/user_config.h @@ -292,6 +292,7 @@ #define USE_PZEM004T // Add support for PZEM004T Energy monitor (+2k code) #define USE_SERIAL_BRIDGE // Add support for software Serial Bridge (+0k8 code) #define USE_SDM120 // Add support for Eastron SDM120-Modbus energy meter (+1k2 code) + #define SDM120_SPEED 9600 // SDM120-Modbus RS485 serial speed (default: 2400 baud) // -- Low level interface devices ----------------- #define USE_IR_REMOTE // Send IR remote commands using library IRremoteESP8266 and ArduinoJson (+4k code, 0k3 mem, 48 iram) diff --git a/sonoff/xsns_23_sdm120.ino b/sonoff/xsns_23_sdm120.ino index 69baa35e5..c34e2ed7c 100644 --- a/sonoff/xsns_23_sdm120.ino +++ b/sonoff/xsns_23_sdm120.ino @@ -34,7 +34,9 @@ uint8_t sdm120_state = 0; float sdm120_voltage = 0; float sdm120_current = 0; -float sdm120_power = 0; +float sdm120_active_power = 0; +float sdm120_apparent_power = 0; +float sdm120_reactive_power = 0; float sdm120_power_factor = 0; float sdm120_frequency = 0; float sdm120_energy_total = 0; @@ -123,8 +125,8 @@ const uint16_t sdm_start_addresses[] { 0x0000, // SDM120C_VOLTAGE [V] 0x0006, // SDM120C_CURRENT [A] 0x000C, // SDM120C_POWER [W] - 0x0012, // SDM120C_ACTIVE_APPARENT_POWER [VA] - 0x0018, // SDM120C_REACTIVE_APPARENT_POWER [VAR] + 0x0012, // SDM120C_APPARENT_POWER [VA] + 0x0018, // SDM120C_REACTIVE_POWER [VAR] 0x001E, // SDM120C_POWER_FACTOR 0x0046, // SDM120C_FREQUENCY [Hz] 0x0048, // SDM120C_IMPORT_ACTIVE_ENERGY [Wh] @@ -160,7 +162,15 @@ void SDM12050ms() // Every 50 mSec break; case 2: - sdm120_power = value; + sdm120_active_power = value; + break; + + case 3: + sdm120_apparent_power = value; + break; + + case 4: + sdm120_reactive_power = value; break; case 5: @@ -198,7 +208,11 @@ void SDM120Init() sdm120_type = 0; if ((pin[GPIO_SDM120_RX] < 99) && (pin[GPIO_SDM120_TX] < 99)) { SDM120Serial = new TasmotaSerial(pin[GPIO_SDM120_RX], pin[GPIO_SDM120_TX], 1); - if (SDM120Serial->begin(9600)) { +#ifdef SDM120_SPEED + if (SDM120Serial->begin(SDM120_SPEED)) { +#else + if (SDM120Serial->begin(2400)) { +#endif if (SDM120Serial->hardwareSerial()) { ClaimSerial(); } sdm120_type = 1; } @@ -209,7 +223,9 @@ void SDM120Init() const char HTTP_SNS_SDM120_DATA[] PROGMEM = "%s" "{s}SDM120 " D_VOLTAGE "{m}%s " D_UNIT_VOLT "{e}" "{s}SDM120 " D_CURRENT "{m}%s " D_UNIT_AMPERE "{e}" - "{s}SDM120 " D_POWERUSAGE "{m}%s " D_UNIT_WATT "{e}" + "{s}SDM120 " D_POWERUSAGE_ACTIVE "{m}%s " D_UNIT_WATT "{e}" + "{s}SDM120 " D_POWERUSAGE_APPARENT "{m}%s " D_UNIT_VA "{e}" + "{s}SDM120 " D_POWERUSAGE_REACTIVE "{m}%s " D_UNIT_VAR "{e}" "{s}SDM120 " D_POWER_FACTOR "{m}%s{e}" "{s}SDM120 " D_FREQUENCY "{m}%s " D_UNIT_HERTZ "{e}" "{s}SDM120 " D_ENERGY_TOTAL "{m}%s " D_UNIT_KILOWATTHOUR "{e}"; @@ -219,31 +235,35 @@ void SDM120Show(boolean json) { char voltage[10]; char current[10]; - char power[10]; + char active_power[10]; + char apparent_power[10]; + char reactive_power[10]; char power_factor[10]; char frequency[10]; char energy_total[10]; dtostrfd(sdm120_voltage, Settings.flag2.voltage_resolution, voltage); dtostrfd(sdm120_current, Settings.flag2.current_resolution, current); - dtostrfd(sdm120_power, Settings.flag2.wattage_resolution, power); + dtostrfd(sdm120_active_power, Settings.flag2.wattage_resolution, active_power); + dtostrfd(sdm120_apparent_power, Settings.flag2.wattage_resolution, apparent_power); + dtostrfd(sdm120_reactive_power, Settings.flag2.wattage_resolution, reactive_power); dtostrfd(sdm120_power_factor, 2, power_factor); dtostrfd(sdm120_frequency, 2, frequency); dtostrfd(sdm120_energy_total, Settings.flag2.energy_resolution, energy_total); if (json) { - snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"" D_RSLT_ENERGY "\":{\"" D_JSON_TOTAL "\":%s,\"" D_JSON_POWERUSAGE "\":%s,\"" D_JSON_FREQUENCY "\":%s,\"" D_JSON_POWERFACTOR "\":%s,\"" D_JSON_VOLTAGE "\":%s,\"" D_JSON_CURRENT "\":%s}"), - mqtt_data, energy_total, power, frequency, power_factor, voltage, current); + snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"" D_RSLT_ENERGY "\":{\"" D_JSON_TOTAL "\":%s,\"" D_JSON_ACTIVE_POWERUSAGE "\":%s,\"" D_JSON_APPARENT_POWERUSAGE "\":%s,\"" D_JSON_REACTIVE_POWERUSAGE "\":%s,\"" D_JSON_FREQUENCY "\":%s,\"" D_JSON_POWERFACTOR "\":%s,\"" D_JSON_VOLTAGE "\":%s,\"" D_JSON_CURRENT "\":%s}"), + mqtt_data, energy_total, active_power, apparent_power, reactive_power, frequency, power_factor, voltage, current); #ifdef USE_DOMOTICZ if (0 == tele_period) { DomoticzSensor(DZ_VOLTAGE, voltage); DomoticzSensor(DZ_CURRENT, current); - DomoticzSensorPowerEnergy((uint16_t)sdm120_power, energy_total); + DomoticzSensorPowerEnergy((uint16_t)sdm120_active_power, energy_total); } #endif // USE_DOMOTICZ #ifdef USE_WEBSERVER } else { - snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_SDM120_DATA, mqtt_data, voltage, current, power, power_factor, frequency, energy_total); + snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_SDM120_DATA, mqtt_data, voltage, current, active_power, apparent_power, reactive_power, power_factor, frequency, energy_total); } #endif // USE_WEBSERVER } @@ -280,3 +300,4 @@ boolean Xsns23(byte function) } #endif // USE_SDM120 +