Fix the calculation for "net".

This commit is contained in:
Victor Chang
2024-01-27 23:30:09 -08:00
parent 4a9adb7615
commit 21b4753cbd

View File

@@ -480,13 +480,10 @@ class EmporiaVueUtility : public Component, public UARTDevice {
kWh_consumed->publish_state(float(consumed) / 1000.0);
kWh_returned->publish_state(float(returned) / 1000.0);
// Calculate watt-hour change from the previous reading.
if (prev_consumed > 0 || prev_returned > 0) {
// Initialized
net = consumed_diff - returned_diff;
Wh_net->publish_state(float(net));
kWh_net->publish_state(float(net) / 1000.0);
}
net = consumed - returned;
Wh_net->publish_state(float(net));
kWh_net->publish_state(float(net) / 1000.0);
prev_consumed = consumed;
prev_returned = returned;