mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-25 11:46:31 +00:00
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])) {
|
if (isnan(apparent_power[i])) {
|
||||||
apparent_power[i] = Energy->voltage[i] * Energy->current[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
|
if (apparent_power[i] < Energy->active_power[i]) { // Should be impossible
|
||||||
Energy->active_power[i] = apparent_power[i];
|
Energy->active_power[i] = apparent_power[i];
|
||||||
}
|
}
|
||||||
@ -1216,6 +1219,9 @@ void EnergyShow(bool json) {
|
|||||||
reactive_power[i] = (float)(SqrtInt((uint32_t)(power_diff)));
|
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])) {
|
if (isnan(apparent_power[i])) {
|
||||||
apparent_power[i] = Energy->voltage[i] * Energy->current[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
|
if (apparent_power[i] < Energy->active_power[i]) { // Should be impossible
|
||||||
Energy->active_power[i] = apparent_power[i];
|
Energy->active_power[i] = apparent_power[i];
|
||||||
}
|
}
|
||||||
@ -1446,6 +1449,9 @@ void EnergyShow(bool json) {
|
|||||||
reactive_power[i] = (float)(SqrtInt((uint32_t)(power_diff)));
|
reactive_power[i] = (float)(SqrtInt((uint32_t)(power_diff)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (0 == Energy->current[i]) {
|
||||||
|
reactive_power[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user