Skip to content

Commit

Permalink
Fix: huawei grid charger efficiency value
Browse files Browse the repository at this point in the history
closes #1549.
  • Loading branch information
schlimmchen committed Jan 18, 2025
1 parent 92aed53 commit ea7ab87
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/gridcharger/huawei/DataPoints.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ LABEL_TRAIT(InputPower, "W");
LABEL_TRAIT(InputFrequency, "Hz");
LABEL_TRAIT(InputCurrent, "A");
LABEL_TRAIT(OutputPower, "W");
LABEL_TRAIT(Efficiency, "%");
LABEL_TRAIT(Efficiency, ""); // no unit as value is in decimals, e.g., 0.88 for 88%
LABEL_TRAIT(OutputVoltage, "V");
LABEL_TRAIT(OutputCurrentMax, "A");
LABEL_TRAIT(InputVoltage, "V");
Expand Down
9 changes: 8 additions & 1 deletion src/gridcharger/huawei/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,15 @@ void Controller::getJsonData(JsonVariant& root) const
VAL(OutputPower, "output_power");
VAL(InputTemperature, "input_temp");
VAL(OutputTemperature, "output_temp");
VAL(Efficiency, "efficiency");
#undef VAL

// special handling for efficiency, as we need to multiply it
// to get the percentage (rather than the decimal notation).
auto oEfficiency = _dataPoints.getDataPointFor<Label::Efficiency>();
if (oEfficiency) {
root["efficiency"]["v"] = *_dataPoints.get<Label::Efficiency>() * 100;
root["efficiency"]["u"] = oEfficiency->getUnitText();
}
}

} // namespace GridCharger::Huawei

0 comments on commit ea7ab87

Please sign in to comment.