Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
helgeerbe committed Nov 15, 2023
2 parents 6e336f1 + 8cccce5 commit a1d0dad
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: "3.x"
python-version: "3.9"

- name: Install PlatformIO
run: |
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
python-version: "3.9"

- name: Install PlatformIO
run: |
Expand Down
1 change: 1 addition & 0 deletions include/Huawei_can.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class HuaweiCanClass {

private:
void processReceivedParameters();
void _setValue(float in, uint8_t parameterType);

TaskHandle_t _HuaweiCanCommunicationTaskHdl = NULL;
bool _initialized = false;
Expand Down
21 changes: 14 additions & 7 deletions src/Huawei_can.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ void HuaweiCanClass::loop()
// Set voltage limit in periodic intervals
if ( _nextAutoModePeriodicIntMillis < millis()) {
MessageOutput.printf("[HuaweiCanClass::loop] Periodically setting voltage limit: %f \r\n", config.Huawei_Auto_Power_Voltage_Limit);
setValue(config.Huawei_Auto_Power_Voltage_Limit, HUAWEI_ONLINE_VOLTAGE);
_setValue(config.Huawei_Auto_Power_Voltage_Limit, HUAWEI_ONLINE_VOLTAGE);
_nextAutoModePeriodicIntMillis = millis() + 60000;
}

Expand All @@ -319,7 +319,7 @@ void HuaweiCanClass::loop()

if (inverter != nullptr) {
if(inverter->isProducing()) {
setValue(0.0, HUAWEI_ONLINE_CURRENT);
_setValue(0.0, HUAWEI_ONLINE_CURRENT);
// Don't run auto mode for a second now. Otherwise we may send too much over the CAN bus
_autoModeBlockedTillMillis = millis() + 1000;
MessageOutput.printf("[HuaweiCanClass::loop] Inverter is active, disable\r\n");
Expand Down Expand Up @@ -349,7 +349,7 @@ void HuaweiCanClass::loop()
_autoPowerEnabledCounter--;
if (_autoPowerEnabledCounter == 0) {
_autoPowerEnabled = false;
setValue(0, HUAWEI_ONLINE_CURRENT);
_setValue(0, HUAWEI_ONLINE_CURRENT);
return;
}
} else {
Expand All @@ -366,20 +366,27 @@ void HuaweiCanClass::loop()
float outputCurrent = efficiency * (newPowerLimit / _rp.output_voltage);
MessageOutput.printf("[HuaweiCanClass::loop] Output current %f \r\n", outputCurrent);
_autoPowerEnabled = true;
setValue(outputCurrent, HUAWEI_ONLINE_CURRENT);
_setValue(outputCurrent, HUAWEI_ONLINE_CURRENT);

// Don't run auto mode some time to allow for output stabilization after issuing a new value
_autoModeBlockedTillMillis = millis() + 2 * HUAWEI_DATA_REQUEST_INTERVAL_MS;
} else {
// requested PL is below minium. Set current to 0
_autoPowerEnabled = false;
setValue(0.0, HUAWEI_ONLINE_CURRENT);
_setValue(0.0, HUAWEI_ONLINE_CURRENT);
}
}
}
}

void HuaweiCanClass::setValue(float in, uint8_t parameterType)
{
if (_mode != HUAWEI_MODE_AUTO_INT) {
_setValue(in, parameterType);
}
}

void HuaweiCanClass::_setValue(float in, uint8_t parameterType)
{

const CONFIG_T& config = Configuration.get();
Expand All @@ -391,7 +398,7 @@ void HuaweiCanClass::setValue(float in, uint8_t parameterType)
uint16_t value;

if (in < 0) {
MessageOutput.printf("[HuaweiCanClass::setValue] Error: Tried to set voltage/current to negative value %f \r\n", in);
MessageOutput.printf("[HuaweiCanClass::_setValue] Error: Tried to set voltage/current to negative value %f \r\n", in);
}

// Start PSU if needed
Expand Down Expand Up @@ -435,7 +442,7 @@ void HuaweiCanClass::setMode(uint8_t mode) {

if (_mode == HUAWEI_MODE_AUTO_INT && mode != HUAWEI_MODE_AUTO_INT) {
_autoPowerEnabled = false;
setValue(0, HUAWEI_ONLINE_CURRENT);
_setValue(0, HUAWEI_ONLINE_CURRENT);
}

if(mode == HUAWEI_MODE_AUTO_EXT || mode == HUAWEI_MODE_AUTO_INT) {
Expand Down
2 changes: 1 addition & 1 deletion src/MqttHandlVedirectHass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void MqttHandleVedirectHassClass::publishConfig()
publishSensor("Battery voltage", NULL, "V", "voltage", "measurement", "V");
publishSensor("Battery current", NULL, "I", "current", "measurement", "A");
publishSensor("Battery power (calculated)", NULL, "P", "power", "measurement", "W");
publishSensor("Battery efficiency (calculated)", NULL, "E", "efficiency", "measurement", "%");
publishSensor("Battery efficiency (calculated)", NULL, "E", NULL, "measurement", "%");

// panel info
publishSensor("Panel voltage", NULL, "VPV", "voltage", "measurement", "V");
Expand Down
2 changes: 1 addition & 1 deletion src/WebApi_Huawei.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void WebApiHuaweiClass::getJsonData(JsonObject& root) {
root[F("input_temp")]["u"] = "°C";
root[F("output_temp")]["v"] = rp->output_temp;
root[F("output_temp")]["u"] = "°C";
root[F("efficiency")]["v"] = rp->efficiency;
root[F("efficiency")]["v"] = rp->efficiency * 100;
root[F("efficiency")]["u"] = "%";

}
Expand Down
2 changes: 1 addition & 1 deletion src/WebApi_ws_Huawei.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void WebApiWsHuaweiLiveClass::generateJsonResponse(JsonVariant& root)
root[F("input_temp")]["u"] = "°C";
root[F("output_temp")]["v"] = rp->output_temp;
root[F("output_temp")]["u"] = "°C";
root[F("efficiency")]["v"] = rp->efficiency;
root[F("efficiency")]["v"] = rp->efficiency * 100;
root[F("efficiency")]["u"] = "%";

}
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/components/HuaweiView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
</tr>
<tr>
<th scope="row">{{ $t('huawei.efficiency') }}</th>
<td style="text-align: right">{{ huaweiData.efficiency.v.toFixed(3) }}</td>
<td style="text-align: right">{{ huaweiData.efficiency.v.toFixed(1) }}</td>
<td>{{ huaweiData.efficiency.u }}</td>
</tr>
</tbody>
Expand Down
Binary file modified webapp_dist/js/app.js.gz
Binary file not shown.

0 comments on commit a1d0dad

Please sign in to comment.