From 798edc20c2600aabe1a170a0fedb7d2a728403f6 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 21 Aug 2024 16:27:43 +0200 Subject: [PATCH] Version v14.2.0.2 - Changed Energy BL09xx command ``CurrentSet`` input changed from Ampere to milliAmpere --- CHANGELOG.md | 16 +++++++++++--- RELEASENOTES.md | 3 ++- tasmota/include/tasmota_version.h | 2 +- .../tasmota_xnrg_energy/xnrg_01_hlw8012.ino | 18 +++++++++------- .../tasmota_xnrg_energy/xnrg_02_cse7766.ino | 18 +++++++++------- .../tasmota_xnrg_energy/xnrg_04_mcp39f501.ino | 12 ++++++----- .../tasmota_xnrg_energy/xnrg_14_bl09xx.ino | 13 ++++++++---- .../tasmota_xnrg_energy/xnrg_19_cse7761.ino | 21 ++++++++----------- .../tasmota_xnrg_energy/xnrg_22_bl6523.ino | 4 +++- tasmota/tasmota_xnrg_energy/xnrg_30_dummy.ino | 4 +++- 10 files changed, 69 insertions(+), 42 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 443243fee..d6ea73792 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,14 +3,24 @@ All notable changes to this project will be documented in this file. ## [Unreleased] - Development -## [14.2.0.1] +## [14.2.0.2] +### Added + +### Breaking Changed + +### Changed +- Energy BL09xx command ``CurrentSet`` input changed from Ampere to milliAmpere + +### Fixed + +### Removed + +## [14.2.0.1] 20240821 ### Added - Energy Log level 4 message when (Calculated) Apparent Power is less than Active Power indicating wrong calibration (#20653) - Energy command ``PowerSet 60,230`` to calibrate both Current and Power with known resistive load of 60W at 230V using calibrated Voltage - Energy command ``CurrentSet 60,230`` to calibrate both Power and Current with known resistive load of 60W at 230V using calibrated Voltage -### Breaking Changed - ### Changed - Energy force Apparent Power equals Active Power when (Calculated) Apparent Power is less than Active Power (#20653) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 6167cb6cd..b398d6ae3 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -119,7 +119,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm [Complete list](BUILDS.md) of available feature and sensors. -## Changelog v14.2.0.1 +## Changelog v14.2.0.2 ### Added - Energy command ``PowerSet 60,230`` to calibrate both Current and Power with known resistive load of 60W at 230V using calibrated Voltage - Energy command ``CurrentSet 60,230`` to calibrate both Power and Current with known resistive load of 60W at 230V using calibrated Voltage @@ -128,6 +128,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm ### Breaking Changed ### Changed +- Energy BL09xx command ``CurrentSet`` input changed from Ampere to milliAmpere - Energy force Apparent Power equals Active Power when (Calculated) Apparent Power is less than Active Power [#20653](https://github.com/arendst/Tasmota/issues/20653) ### Fixed diff --git a/tasmota/include/tasmota_version.h b/tasmota/include/tasmota_version.h index e6b23a469..044db53f8 100644 --- a/tasmota/include/tasmota_version.h +++ b/tasmota/include/tasmota_version.h @@ -22,6 +22,6 @@ #define TASMOTA_SHA_SHORT // Filled by Github sed -const uint32_t TASMOTA_VERSION = 0x0E020001; // 14.2.0.1 +const uint32_t TASMOTA_VERSION = 0x0E020002; // 14.2.0.2 #endif // _TASMOTA_VERSION_H_ diff --git a/tasmota/tasmota_xnrg_energy/xnrg_01_hlw8012.ino b/tasmota/tasmota_xnrg_energy/xnrg_01_hlw8012.ino index 58980fee6..71d4fef5c 100644 --- a/tasmota/tasmota_xnrg_energy/xnrg_01_hlw8012.ino +++ b/tasmota/tasmota_xnrg_energy/xnrg_01_hlw8012.ino @@ -284,22 +284,26 @@ void HlwDrvInit(void) { bool HlwCommand(void) { bool serviced = true; - if ((CMND_POWERCAL == Energy->command_code) || (CMND_VOLTAGECAL == Energy->command_code) || (CMND_CURRENTCAL == Energy->command_code)) { + float value = CharToFloat(XdrvMailbox.data); + + if ((CMND_POWERCAL == Energy->command_code) || + (CMND_VOLTAGECAL == Energy->command_code) || + (CMND_CURRENTCAL == Energy->command_code)) { // Service in xdrv_03_energy.ino } - else if (CMND_POWERSET == Energy->command_code) { + else if (CMND_POWERSET == Energy->command_code) { // xxx.x W if (XdrvMailbox.data_len && Hlw.cf_power_pulse_length ) { - XdrvMailbox.payload = ((uint32_t)(CharToFloat(XdrvMailbox.data) * 10) * Hlw.cf_power_pulse_length ) / Hlw.power_ratio; + XdrvMailbox.payload = ((uint32_t)(value * 10) * Hlw.cf_power_pulse_length ) / Hlw.power_ratio; } } - else if (CMND_VOLTAGESET == Energy->command_code) { + else if (CMND_VOLTAGESET == Energy->command_code) { // xxx.x V if (XdrvMailbox.data_len && Hlw.cf1_voltage_pulse_length ) { - XdrvMailbox.payload = ((uint32_t)(CharToFloat(XdrvMailbox.data) * 10) * Hlw.cf1_voltage_pulse_length ) / Hlw.voltage_ratio; + XdrvMailbox.payload = ((uint32_t)(value * 10) * Hlw.cf1_voltage_pulse_length ) / Hlw.voltage_ratio; } } - else if (CMND_CURRENTSET == Energy->command_code) { + else if (CMND_CURRENTSET == Energy->command_code) { // xxx mA if (XdrvMailbox.data_len && Hlw.cf1_current_pulse_length) { - XdrvMailbox.payload = ((uint32_t)(CharToFloat(XdrvMailbox.data)) * Hlw.cf1_current_pulse_length) / Hlw.current_ratio; + XdrvMailbox.payload = ((uint32_t)(value) * Hlw.cf1_current_pulse_length) / Hlw.current_ratio; } } else serviced = false; // Unknown command diff --git a/tasmota/tasmota_xnrg_energy/xnrg_02_cse7766.ino b/tasmota/tasmota_xnrg_energy/xnrg_02_cse7766.ino index 6e33897dd..f2caf1728 100644 --- a/tasmota/tasmota_xnrg_energy/xnrg_02_cse7766.ino +++ b/tasmota/tasmota_xnrg_energy/xnrg_02_cse7766.ino @@ -258,22 +258,26 @@ void CseDrvInit(void) { bool CseCommand(void) { bool serviced = true; - if ((CMND_POWERCAL == Energy->command_code) || (CMND_VOLTAGECAL == Energy->command_code) || (CMND_CURRENTCAL == Energy->command_code)) { + float value = CharToFloat(XdrvMailbox.data); + + if ((CMND_POWERCAL == Energy->command_code) || + (CMND_VOLTAGECAL == Energy->command_code) || + (CMND_CURRENTCAL == Energy->command_code)) { // Service in xdrv_03_energy.ino } - else if (CMND_POWERSET == Energy->command_code) { + else if (CMND_POWERSET == Energy->command_code) { // xxx W if (XdrvMailbox.data_len && Cse.power_cycle) { - XdrvMailbox.payload = (unsigned long)(CharToFloat(XdrvMailbox.data) * Cse.power_cycle) / CSE_PREF; + XdrvMailbox.payload = (uint32_t)(value * Cse.power_cycle) / CSE_PREF; } } - else if (CMND_VOLTAGESET == Energy->command_code) { + else if (CMND_VOLTAGESET == Energy->command_code) { // xxx V if (XdrvMailbox.data_len && Cse.voltage_cycle) { - XdrvMailbox.payload = (unsigned long)(CharToFloat(XdrvMailbox.data) * Cse.voltage_cycle) / CSE_UREF; + XdrvMailbox.payload = (uint32_t)(value * Cse.voltage_cycle) / CSE_UREF; } } - else if (CMND_CURRENTSET == Energy->command_code) { + else if (CMND_CURRENTSET == Energy->command_code) { // xxx mA if (XdrvMailbox.data_len && Cse.current_cycle) { - XdrvMailbox.payload = (unsigned long)(CharToFloat(XdrvMailbox.data) * Cse.current_cycle) / 1000; + XdrvMailbox.payload = (uint32_t)(value * Cse.current_cycle) / 1000; } } else serviced = false; // Unknown command diff --git a/tasmota/tasmota_xnrg_energy/xnrg_04_mcp39f501.ino b/tasmota/tasmota_xnrg_energy/xnrg_04_mcp39f501.ino index f3b6a580b..f781fff43 100644 --- a/tasmota/tasmota_xnrg_energy/xnrg_04_mcp39f501.ino +++ b/tasmota/tasmota_xnrg_energy/xnrg_04_mcp39f501.ino @@ -599,11 +599,13 @@ void McpDrvInit(void) bool McpCommand(void) { bool serviced = true; - unsigned long value = 0; + + float value_f = CharToFloat(XdrvMailbox.data); + uint32_t value = 0; if (CMND_POWERSET == Energy->command_code) { if (XdrvMailbox.data_len && mcp_active_power) { - value = (unsigned long)(CharToFloat(XdrvMailbox.data) * 100); + value = (uint32_t)(value_f * 100); if ((value > 100) && (value < 2000000)) { // Between 1W and 20000W XdrvMailbox.payload = value; mcp_calibrate |= MCP_CALIBRATE_POWER; @@ -613,7 +615,7 @@ bool McpCommand(void) } else if (CMND_VOLTAGESET == Energy->command_code) { if (XdrvMailbox.data_len && mcp_voltage_rms) { - value = (unsigned long)(CharToFloat(XdrvMailbox.data) * 10); + value = (uint32_t)(value_f * 10); if ((value > 1000) && (value < 4000)) { // Between 100V and 400V XdrvMailbox.payload = value; mcp_calibrate |= MCP_CALIBRATE_VOLTAGE; @@ -623,7 +625,7 @@ bool McpCommand(void) } else if (CMND_CURRENTSET == Energy->command_code) { if (XdrvMailbox.data_len && mcp_current_rms) { - value = (unsigned long)(CharToFloat(XdrvMailbox.data) * 10); + value = (uint32_t)(value_f * 10); if ((value > 100) && (value < 800000)) { // Between 10mA and 80A XdrvMailbox.payload = value; mcp_calibrate |= MCP_CALIBRATE_CURRENT; @@ -633,7 +635,7 @@ bool McpCommand(void) } else if (CMND_FREQUENCYSET == Energy->command_code) { if (XdrvMailbox.data_len && mcp_line_frequency) { - value = (unsigned long)(CharToFloat(XdrvMailbox.data) * 1000); + value = (uint32_t)(value_f * 1000); if ((value > 45000) && (value < 65000)) { // Between 45Hz and 65Hz XdrvMailbox.payload = value; mcp_calibrate |= MCP_CALIBRATE_FREQUENCY; diff --git a/tasmota/tasmota_xnrg_energy/xnrg_14_bl09xx.ino b/tasmota/tasmota_xnrg_energy/xnrg_14_bl09xx.ino index da66a5cf4..3c49d0913 100644 --- a/tasmota/tasmota_xnrg_energy/xnrg_14_bl09xx.ino +++ b/tasmota/tasmota_xnrg_energy/xnrg_14_bl09xx.ino @@ -393,19 +393,24 @@ bool Bl09XXCommand(void) { uint32_t channel = (2 == XdrvMailbox.index) && (Energy->phase_count > 1) ? 1 : 0; uint32_t value = (uint32_t)(CharToFloat(XdrvMailbox.data) * 100); // 1.23 = 123 - if (CMND_POWERSET == Energy->command_code) { + if ((CMND_POWERCAL == Energy->command_code) || + (CMND_VOLTAGECAL == Energy->command_code) || + (CMND_CURRENTCAL == Energy->command_code)) { + // Service in xdrv_03_energy.ino + } + else if (CMND_POWERSET == Energy->command_code) { // xxx.xx W if (XdrvMailbox.data_len && Bl09XX.power[channel]) { XdrvMailbox.payload = (Bl09XX.power[channel] * 100) / value; } } - else if (CMND_VOLTAGESET == Energy->command_code) { + else if (CMND_VOLTAGESET == Energy->command_code) { // xxx.xx V if (XdrvMailbox.data_len && Bl09XX.voltage) { XdrvMailbox.payload = (Bl09XX.voltage * 100) / value; } } - else if (CMND_CURRENTSET == Energy->command_code) { + else if (CMND_CURRENTSET == Energy->command_code) { // xxx.xx mA if (XdrvMailbox.data_len && Bl09XX.current[channel]) { - XdrvMailbox.payload = (Bl09XX.current[channel] * 100) / value; + XdrvMailbox.payload = ((Bl09XX.current[channel] * 100) / value) * 1000; } } else serviced = false; // Unknown command diff --git a/tasmota/tasmota_xnrg_energy/xnrg_19_cse7761.ino b/tasmota/tasmota_xnrg_energy/xnrg_19_cse7761.ino index 2f1493c58..1a4bd3002 100644 --- a/tasmota/tasmota_xnrg_energy/xnrg_19_cse7761.ino +++ b/tasmota/tasmota_xnrg_energy/xnrg_19_cse7761.ino @@ -640,16 +640,21 @@ void Cse7761DrvInit(void) { bool Cse7761Command(void) { bool serviced = true; - uint32_t channel = 0; - if (Energy->phase_count > 1) { - channel = (2 == XdrvMailbox.index) ? 1 : 0; - } + uint32_t channel = (2 == XdrvMailbox.index) && (Energy->phase_count > 1) ? 1 : 0; uint32_t value = (uint32_t)(CharToFloat(XdrvMailbox.data) * 100); // 1.23 = 123 if (CMND_POWERCAL == Energy->command_code) { if (1 == XdrvMailbox.payload) { XdrvMailbox.payload = Cse7761Ref(PowerPAC); } // Service in xdrv_03_energy.ino } + else if (CMND_VOLTAGECAL == Energy->command_code) { + if (1 == XdrvMailbox.payload) { XdrvMailbox.payload = Cse7761Ref(RmsUC); } + // Service in xdrv_03_energy.ino + } + else if (CMND_CURRENTCAL == Energy->command_code) { + if (1 == XdrvMailbox.payload) { XdrvMailbox.payload = Cse7761Ref(RmsIAC); } + // Service in xdrv_03_energy.ino + } else if (CMND_POWERSET == Energy->command_code) { if (XdrvMailbox.data_len && CSE7761Data.active_power[channel]) { if ((value > 100) && (value < 2000000)) { // Between 1W and 20000W @@ -657,10 +662,6 @@ bool Cse7761Command(void) { } } } - else if (CMND_VOLTAGECAL == Energy->command_code) { - if (1 == XdrvMailbox.payload) { XdrvMailbox.payload = Cse7761Ref(RmsUC); } - // Service in xdrv_03_energy.ino - } else if (CMND_VOLTAGESET == Energy->command_code) { if (XdrvMailbox.data_len && CSE7761Data.voltage_rms) { if ((value > 10000) && (value < 40000)) { // Between 100V and 400V @@ -668,10 +669,6 @@ bool Cse7761Command(void) { } } } - else if (CMND_CURRENTCAL == Energy->command_code) { - if (1 == XdrvMailbox.payload) { XdrvMailbox.payload = Cse7761Ref(RmsIAC); } - // Service in xdrv_03_energy.ino - } else if (CMND_CURRENTSET == Energy->command_code) { if (XdrvMailbox.data_len && CSE7761Data.current_rms[channel]) { if ((value > 1000) && (value < 10000000)) { // Between 10mA and 100A diff --git a/tasmota/tasmota_xnrg_energy/xnrg_22_bl6523.ino b/tasmota/tasmota_xnrg_energy/xnrg_22_bl6523.ino index 1e95abf6f..311ea7ffe 100644 --- a/tasmota/tasmota_xnrg_energy/xnrg_22_bl6523.ino +++ b/tasmota/tasmota_xnrg_energy/xnrg_22_bl6523.ino @@ -259,7 +259,9 @@ bool Bl6523Command(void) { int32_t value = (int32_t)(CharToFloat(XdrvMailbox.data) * 1000); // 1.234 = 1234, -1.234 = -1234 uint32_t abs_value = abs(value) / 10; // 1.23 = 123, -1.23 = 123 - if ((CMND_POWERCAL == Energy->command_code) || (CMND_VOLTAGECAL == Energy->command_code) || (CMND_CURRENTCAL == Energy->command_code)) { + if ((CMND_POWERCAL == Energy->command_code) || + (CMND_VOLTAGECAL == Energy->command_code) || + (CMND_CURRENTCAL == Energy->command_code)) { // Service in xdrv_03_energy.ino } else if (CMND_POWERSET == Energy->command_code) { diff --git a/tasmota/tasmota_xnrg_energy/xnrg_30_dummy.ino b/tasmota/tasmota_xnrg_energy/xnrg_30_dummy.ino index 7fe78946f..d12cf89df 100644 --- a/tasmota/tasmota_xnrg_energy/xnrg_30_dummy.ino +++ b/tasmota/tasmota_xnrg_energy/xnrg_30_dummy.ino @@ -90,7 +90,9 @@ bool NrgDummyCommand(void) { int32_t value = (int32_t)(CharToFloat(XdrvMailbox.data) * 1000); // 1.234 = 1234, -1.234 = -1234 uint32_t abs_value = abs(value) / 10; // 1.23 = 123, -1.23 = 123 - if ((CMND_POWERCAL == Energy->command_code) || (CMND_VOLTAGECAL == Energy->command_code) || (CMND_CURRENTCAL == Energy->command_code)) { + if ((CMND_POWERCAL == Energy->command_code) || + (CMND_VOLTAGECAL == Energy->command_code) || + (CMND_CURRENTCAL == Energy->command_code)) { // Service in xdrv_03_energy.ino } else if (CMND_POWERSET == Energy->command_code) {