From ad3cfa6cbbe5d6c0095f0aee10e326ed5b8d2fc0 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sat, 3 Oct 2020 12:46:58 +0200 Subject: [PATCH] Add SDM630 three phase ImportActive Energy display Add SDM630 three phase ImportActive Energy display when ``#define SDM630_IMPORT`` is enabled by Janusz Kostorz (#9124) --- RELEASENOTES.md | 1 + tasmota/CHANGELOG.md | 1 + tasmota/my_user_config.h | 2 +- tasmota/xdrv_03_energy.ino | 14 +++++++------- tasmota/xnrg_10_sdm630.ino | 8 ++++---- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index d36b14a0c..19b30f3d2 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -69,3 +69,4 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota - Change pulsetime to allow use for all relays with 8 interleaved so ``Pulsetime1`` is valid for Relay1, Relay9, Relay17 etc. (#9279) - Add optional support for Mitsubishi Electric HVAC by David Gwynne (#9237) - Add optional support for Orno WE517-Modbus energy meter by Maxime Vincent (#9353) +- Add SDM630 three phase ImportActive Energy display when ``#define SDM630_IMPORT`` is enabled by Janusz Kostorz (#9124) diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index 18e1336a2..b7f84b270 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -10,6 +10,7 @@ - Change pulsetime to allow use for all relays with 8 interleaved so ``Pulsetime1`` is valid for Relay1, Relay9, Relay17 etc. (#9279) - Add optional support for Mitsubishi Electric HVAC by David Gwynne (#9237) - Add optional support for Orno WE517-Modbus energy meter by Maxime Vincent (#9353) +- Add SDM630 three phase ImportActive Energy display when ``#define SDM630_IMPORT`` is enabled by Janusz Kostorz (#9124) ## Released diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index 3df0a428f..e08a486ce 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -652,7 +652,7 @@ #define SDM120_SPEED 2400 // SDM120-Modbus RS485 serial speed (default: 2400 baud) //#define USE_SDM630 // Add support for Eastron SDM630-Modbus energy monitor (+0k6 code) #define SDM630_SPEED 9600 // SDM630-Modbus RS485 serial speed (default: 9600 baud) -//#define SDM630_IMPORT // Show import active energy in MQTT and Web (+0k3 code) +// #define SDM630_IMPORT // Show import active energy in MQTT and Web (+0k3 code) //#define USE_DDS2382 // Add support for Hiking DDS2382 Modbus energy monitor (+0k6 code) #define DDS2382_SPEED 9600 // Hiking DDS2382 Modbus RS485 serial speed (default: 9600 baud) //#define USE_DDSU666 // Add support for Chint DDSU666 Modbus energy monitor (+0k6 code) diff --git a/tasmota/xdrv_03_energy.ino b/tasmota/xdrv_03_energy.ino index b221291d1..789f9fab4 100644 --- a/tasmota/xdrv_03_energy.ino +++ b/tasmota/xdrv_03_energy.ino @@ -80,9 +80,9 @@ struct ENERGY { float power_factor[3] = { NAN, NAN, NAN }; // 0.12 float frequency[3] = { NAN, NAN, NAN }; // 123.1 Hz - #ifdef SDM630_IMPORT +#ifdef SDM630_IMPORT float import_active[3] = { NAN, NAN, NAN }; // 123.123 kWh -#endif +#endif // SDM630_IMPORT float export_active[3] = { NAN, NAN, NAN }; // 123.123 kWh float start_energy = 0; // 12345.12345 kWh total previous @@ -994,7 +994,7 @@ void EnergyShow(bool json) char active_power_chr[Energy.phase_count][FLOATSZ]; #ifdef SDM630_IMPORT char import_active_chr[Energy.phase_count][FLOATSZ]; -#endif +#endif // SDM630_IMPORT char export_active_chr[Energy.phase_count][FLOATSZ]; for (uint32_t i = 0; i < Energy.phase_count; i++) { dtostrfd(Energy.voltage[i], Settings.flag2.voltage_resolution, voltage_chr[i]); @@ -1002,7 +1002,7 @@ void EnergyShow(bool json) dtostrfd(Energy.active_power[i], Settings.flag2.wattage_resolution, active_power_chr[i]); #ifdef SDM630_IMPORT dtostrfd(Energy.import_active[i], Settings.flag2.energy_resolution, import_active_chr[i]); -#endif +#endif // SDM630_IMPORT dtostrfd(Energy.export_active[i], Settings.flag2.energy_resolution, export_active_chr[i]); } @@ -1054,7 +1054,7 @@ void EnergyShow(bool json) EnergyFormatIndex(value_chr, energy_return_chr[0], json, 2)); } } -#endif +#endif // SDM630_IMPORT if (!isnan(Energy.export_active[0])) { ResponseAppend_P(PSTR(",\"" D_JSON_EXPORT_ACTIVE "\":%s"), @@ -1160,11 +1160,11 @@ void EnergyShow(bool json) if (!isnan(Energy.export_active[0])) { WSContentSend_PD(HTTP_ENERGY_SNS3, EnergyFormat(value_chr, export_active_chr[0], json)); } - #ifdef SDM630_IMPORT +#ifdef SDM630_IMPORT if (!isnan(Energy.import_active[0])) { WSContentSend_PD(HTTP_ENERGY_SNS4, EnergyFormat(value_chr, import_active_chr[0], json)); } -#endif +#endif // SDM630_IMPORT XnrgCall(FUNC_WEB_SENSOR); #endif // USE_WEBSERVER diff --git a/tasmota/xnrg_10_sdm630.ino b/tasmota/xnrg_10_sdm630.ino index 92b8e98e4..c1f36b110 100644 --- a/tasmota/xnrg_10_sdm630.ino +++ b/tasmota/xnrg_10_sdm630.ino @@ -60,11 +60,11 @@ const uint16_t sdm630_start_addresses[] { 0x0160, // + + + kWh Phase 1 export active energy 0x0162, // + + + kWh Phase 2 export active energy 0x0164, // + + + kWh Phase 3 export active energy - #ifdef SDM630_IMPORT +#ifdef SDM630_IMPORT 0x015A, // + + + kWh Phase 1 import active energy 0x015C, // + + + kWh Phase 2 import active energy 0x015E, // + + + kWh Phase 3 import active energy -#endif +#endif // SDM630_IMPORT 0x0156 // + + + kWh Total active energy }; @@ -179,7 +179,7 @@ void SDM630Every250ms(void) break; case 19: - #ifdef SDM630_IMPORT +#ifdef SDM630_IMPORT Energy.import_active[0] = value; break; @@ -192,7 +192,7 @@ void SDM630Every250ms(void) break; case 22: -#endif +#endif // SDM630_IMPORT EnergyUpdateTotal(value, true); break; }