Skip to content

Commit

Permalink
Version v14.2.0.2
Browse files Browse the repository at this point in the history
- Changed Energy BL09xx command ``CurrentSet`` input changed from Ampere to milliAmpere
  • Loading branch information
arendst committed Aug 21, 2024
1 parent ba7161f commit 798edc2
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 42 deletions.
16 changes: 13 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 2 additions & 1 deletion RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tasmota/include/tasmota_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_
18 changes: 11 additions & 7 deletions tasmota/tasmota_xnrg_energy/xnrg_01_hlw8012.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 11 additions & 7 deletions tasmota/tasmota_xnrg_energy/xnrg_02_cse7766.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions tasmota/tasmota_xnrg_energy/xnrg_04_mcp39f501.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
13 changes: 9 additions & 4 deletions tasmota/tasmota_xnrg_energy/xnrg_14_bl09xx.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 9 additions & 12 deletions tasmota/tasmota_xnrg_energy/xnrg_19_cse7761.ino
Original file line number Diff line number Diff line change
Expand Up @@ -640,38 +640,35 @@ 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
XdrvMailbox.payload = ((CSE7761Data.active_power[channel]) / value) * 100;
}
}
}
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
XdrvMailbox.payload = (CSE7761Data.voltage_rms * 100) / value;
}
}
}
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
Expand Down
4 changes: 3 additions & 1 deletion tasmota/tasmota_xnrg_energy/xnrg_22_bl6523.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion tasmota/tasmota_xnrg_energy/xnrg_30_dummy.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 798edc2

Please sign in to comment.