mirror of https://github.com/arendst/Tasmota.git
Fix invalid apparent and reactive power
This commit is contained in:
parent
cadab815ef
commit
5cdd9791f4
|
@ -1189,6 +1189,9 @@ void EnergyShow(bool json) {
|
|||
if (isnan(apparent_power[i])) {
|
||||
apparent_power[i] = Energy->voltage[i] * Energy->current[i];
|
||||
}
|
||||
else if (0 == Energy->current[i]) {
|
||||
apparent_power[i] = 0;
|
||||
}
|
||||
if (apparent_power[i] < Energy->active_power[i]) { // Should be impossible
|
||||
Energy->active_power[i] = apparent_power[i];
|
||||
}
|
||||
|
@ -1216,6 +1219,9 @@ void EnergyShow(bool json) {
|
|||
reactive_power[i] = (float)(SqrtInt((uint32_t)(power_diff)));
|
||||
}
|
||||
}
|
||||
else if (0 == Energy->current[i]) {
|
||||
reactive_power[i] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1419,6 +1419,9 @@ void EnergyShow(bool json) {
|
|||
if (isnan(apparent_power[i])) {
|
||||
apparent_power[i] = Energy->voltage[i] * Energy->current[i];
|
||||
}
|
||||
else if (0 == Energy->current[i]) {
|
||||
apparent_power[i] = 0;
|
||||
}
|
||||
if (apparent_power[i] < Energy->active_power[i]) { // Should be impossible
|
||||
Energy->active_power[i] = apparent_power[i];
|
||||
}
|
||||
|
@ -1446,6 +1449,9 @@ void EnergyShow(bool json) {
|
|||
reactive_power[i] = (float)(SqrtInt((uint32_t)(power_diff)));
|
||||
}
|
||||
}
|
||||
else if (0 == Energy->current[i]) {
|
||||
reactive_power[i] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue