Skip to content

Commit

Permalink
v24.8.1-0.2.2 based on v24.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Alois Klingler committed Aug 1, 2024
1 parent ef9612e commit 38aac57
Show file tree
Hide file tree
Showing 84 changed files with 2,596 additions and 1,653 deletions.
30 changes: 29 additions & 1 deletion docs/DeviceProfiles/wt32-eth01.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,34 @@
"clk_mode": 0
}
},
{
"name": "WT32-ETH01 with SH1106",
"links": [
{"name": "Datasheet", "url": "http://www.wireless-tag.com/portfolio/wt32-eth01/"}
],
"nrf24": {
"miso": 4,
"mosi": 2,
"clk": 32,
"irq": 33,
"en": 14,
"cs": 15
},
"eth": {
"enabled": true,
"phy_addr": 1,
"power": 16,
"mdc": 23,
"mdio": 18,
"type": 0,
"clk_mode": 0
},
"display": {
"type": 3,
"data": 5,
"clk": 17
}
},
{
"name": "WT32-ETH01 with SSD1306",
"links": [
Expand Down Expand Up @@ -78,4 +106,4 @@
"clk": 17
}
}
]
]
2 changes: 1 addition & 1 deletion include/MqttHandleHass.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class MqttHandleHassClass {
void publishDtuBinarySensor(const char* name, const char* device_class, const char* category, const char* payload_on, const char* payload_off, const char* subTopic = "");
void publishInverterField(std::shared_ptr<InverterAbstract> inv, const ChannelType_t type, const ChannelNum_t channel, const byteAssign_fieldDeviceClass_t fieldType, const bool clear = false);
void publishInverterButton(std::shared_ptr<InverterAbstract> inv, const char* caption, const char* icon, const char* category, const char* deviceClass, const char* subTopic, const char* payload);
void publishInverterNumber(std::shared_ptr<InverterAbstract> inv, const char* caption, const char* icon, const char* category, const char* commandTopic, const char* stateTopic, const char* unitOfMeasure, const int16_t min = 1, const int16_t max = 100);
void publishInverterNumber(std::shared_ptr<InverterAbstract> inv, const char* caption, const char* icon, const char* category, const char* commandTopic, const char* stateTopic, const char* unitOfMeasure, const int16_t min = 1, const int16_t max = 100, float step = 1.0);
void publishInverterBinarySensor(std::shared_ptr<InverterAbstract> inv, const char* caption, const char* subTopic, const char* payload_on, const char* payload_off);

static void createInverterInfo(JsonDocument& doc, std::shared_ptr<InverterAbstract> inv);
Expand Down
2 changes: 1 addition & 1 deletion lib/Hoymiles/src/commands/ActivePowerControlCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ bool ActivePowerControlCommand::handleResponse(const fragment_t fragment[], cons

float ActivePowerControlCommand::getLimit() const
{
const uint16_t l = (((uint16_t)_payload[12] << 8) | _payload[13]);
const float l = (((uint16_t)_payload[12] << 8) | _payload[13]);
return l / 10;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Hoymiles/src/inverters/HMS_2CH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ bool HMS_2CH::isValidSerial(const uint64_t serial)
{
// serial >= 0x114400000000 && serial <= 0x1144ffffffff
uint16_t preSerial = (serial >> 32) & 0xffff;
return preSerial == 0x1144;
return preSerial == 0x1144 || preSerial == 0x1143;
}

String HMS_2CH::typeName() const
Expand Down
2 changes: 1 addition & 1 deletion lib/Hoymiles/src/inverters/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
| HM_4CH | HM-1000/1200/1500-4T | 1161 |
| HMS_1CH | HMS-300/350/400/450/500-1T | 1124 |
| HMS_1CHv2 | HMS-500-1T v2 | 1125 |
| HMS_2CH | HMS-600/700/800/900/1000-2T | 1144 |
| HMS_2CH | HMS-600/700/800/900/1000-2T | 1143, 1144 |
| HMS_4CH | HMS-1600/1800/2000-4T | 1164 |
| HMT_4CH | HMT-1600/1800/2000-4T | 1361 |
| HMT_6CH | HMT-1800/2250-6T | 1382 |
Expand Down
12 changes: 6 additions & 6 deletions lib/Hoymiles/src/parser/AlarmLogParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ ID Source Addr Target Addr Idx ? wcode ? Start End ?

const std::array<const AlarmMessage_t, ALARM_MSG_COUNT> AlarmLogParser::_alarmMessages = { {
{ AlarmMessageType_t::ALL, 1, "Inverter start", "Wechselrichter gestartet", "L'onduleur a démarré" },
{ AlarmMessageType_t::ALL, 2, "Time calibration", "", "" },
{ AlarmMessageType_t::ALL, 2, "Time calibration", "Zeitabgleich", "" },
{ AlarmMessageType_t::ALL, 3, "EEPROM reading and writing error during operation", "", "" },
{ AlarmMessageType_t::ALL, 4, "Offline", "Offline", "Non connecté" },

{ AlarmMessageType_t::ALL, 11, "Grid voltage surge", "", "" },
{ AlarmMessageType_t::ALL, 12, "Grid voltage sharp drop", "", "" },
{ AlarmMessageType_t::ALL, 13, "Grid frequency mutation", "", "" },
{ AlarmMessageType_t::ALL, 14, "Grid phase mutation", "", "" },
{ AlarmMessageType_t::ALL, 15, "Grid transient fluctuation", "", "" },
{ AlarmMessageType_t::ALL, 11, "Grid voltage surge", "Netz: Überspannungsimpuls", "" },
{ AlarmMessageType_t::ALL, 12, "Grid voltage sharp drop", "Netz: Spannungseinbruch", "" },
{ AlarmMessageType_t::ALL, 13, "Grid frequency mutation", "Netz: Frequenzänderung", "" },
{ AlarmMessageType_t::ALL, 14, "Grid phase mutation", "Netz: Phasenänderung", "" },
{ AlarmMessageType_t::ALL, 15, "Grid transient fluctuation", "Netz: vorübergehende Schwankung", "" },

{ AlarmMessageType_t::ALL, 36, "INV overvoltage or overcurrent", "", "" },

Expand Down
1 change: 1 addition & 0 deletions lib/Hoymiles/src/parser/DevInfoParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const devInfo_t devInfo[] = {
{ { 0x10, 0x20, 0x71, ALL }, 500, "HMS-500-1T v2" }, // 02
{ { 0x10, 0x21, 0x11, ALL }, 600, "HMS-600-2T" }, // 01
{ { 0x10, 0x21, 0x41, ALL }, 800, "HMS-800-2T" }, // 00
{ { 0x10, 0x11, 0x41, ALL }, 800, "HMS-800-2T-LV" }, // 00
{ { 0x10, 0x11, 0x51, ALL }, 900, "HMS-900-2T" }, // 01
{ { 0x10, 0x21, 0x51, ALL }, 900, "HMS-900-2T" }, // 03
{ { 0x10, 0x21, 0x71, ALL }, 1000, "HMS-1000-2T" }, // 05
Expand Down
9 changes: 5 additions & 4 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ extra_configs =
custom_ci_action = generic,generic_esp32,generic_esp32s3,generic_esp32s3_usb

framework = arduino
platform = espressif32@6.7.0
platform = espressif32@6.8.1

build_flags =
-DPIOENV=\"$PIOENV\"
-D_TASK_STD_FUNCTION=1
-D_TASK_THREAD_SAFE=1
-DCONFIG_ASYNC_TCP_EVENT_QUEUE_SIZE=128
-DCONFIG_ASYNC_TCP_QUEUE_SIZE=128
-DEMC_TASK_STACK_SIZE=6400
-Wall -Wextra -Wunused -Wmisleading-indentation -Wduplicated-cond -Wlogical-op -Wnull-dereference
; Have to remove -Werror because of
; https://github.com/espressif/arduino-esp32/issues/9044 and
Expand All @@ -38,10 +39,10 @@ build_unflags =
-std=gnu++11

lib_deps =
mathieucarbou/ESP Async WebServer @ 2.10.8
bblanchon/ArduinoJson @ 7.0.4
mathieucarbou/ESPAsyncWebServer @ 3.1.2
bblanchon/ArduinoJson @ 7.1.0
https://github.com/bertmelis/espMqttClient.git#v1.7.0
nrf24/RF24 @ 1.4.8
nrf24/RF24 @ 1.4.9
olikraus/U8g2 @ 2.35.19
buelowp/sunset @ 1.1.7
https://github.com/emelianov/modbus-esp8266#master
Expand Down
7 changes: 4 additions & 3 deletions src/MqttHandleHass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ void MqttHandleHassClass::publishConfig()
publishInverterButton(inv, "Turn Inverter On", "mdi:power-plug", "config", "", "cmd/power", "1");
publishInverterButton(inv, "Restart Inverter", "", "config", "restart", "cmd/restart", "1");

publishInverterNumber(inv, "Limit NonPersistent Relative", "mdi:speedometer", "config", "cmd/limit_nonpersistent_relative", "status/limit_relative", "%", 0, 100);
publishInverterNumber(inv, "Limit Persistent Relative", "mdi:speedometer", "config", "cmd/limit_persistent_relative", "status/limit_relative", "%", 0, 100);
publishInverterNumber(inv, "Limit NonPersistent Relative", "mdi:speedometer", "config", "cmd/limit_nonpersistent_relative", "status/limit_relative", "%", 0, 100, 0.1);
publishInverterNumber(inv, "Limit Persistent Relative", "mdi:speedometer", "config", "cmd/limit_persistent_relative", "status/limit_relative", "%", 0, 100, 0.1);

publishInverterNumber(inv, "Limit NonPersistent Absolute", "mdi:speedometer", "config", "cmd/limit_nonpersistent_absolute", "status/limit_absolute", "W", 0, MAX_INVERTER_LIMIT);
publishInverterNumber(inv, "Limit Persistent Absolute", "mdi:speedometer", "config", "cmd/limit_persistent_absolute", "status/limit_absolute", "W", 0, MAX_INVERTER_LIMIT);
Expand Down Expand Up @@ -215,7 +215,7 @@ void MqttHandleHassClass::publishInverterButton(std::shared_ptr<InverterAbstract
void MqttHandleHassClass::publishInverterNumber(
std::shared_ptr<InverterAbstract> inv, const char* caption, const char* icon, const char* category,
const char* commandTopic, const char* stateTopic, const char* unitOfMeasure,
const int16_t min, const int16_t max)
const int16_t min, const int16_t max, float step)
{
const String serial = inv->serialString();

Expand Down Expand Up @@ -243,6 +243,7 @@ void MqttHandleHassClass::publishInverterNumber(
root["unit_of_meas"] = unitOfMeasure;
root["min"] = min;
root["max"] = max;
root["step"] = step;

createInverterInfo(root, inv);

Expand Down
16 changes: 8 additions & 8 deletions src/MqttHandleInverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ void MqttHandleInverterClass::onMqttMessage(const espMqttClientTypes::MessagePro
char* strlimit = new char[len + 1];
memcpy(strlimit, payload, len);
strlimit[len] = '\0';
const int32_t payload_val = strtol(strlimit, NULL, 10);
const float payload_val = strtof(strlimit, NULL);
delete[] strlimit;

if (payload_val < 0) {
Expand All @@ -193,17 +193,17 @@ void MqttHandleInverterClass::onMqttMessage(const espMqttClientTypes::MessagePro

if (!strcmp(setting, TOPIC_SUB_LIMIT_PERSISTENT_RELATIVE)) {
// Set inverter limit relative persistent
MessageOutput.printf("Limit Persistent: %d %%\r\n", payload_val);
MessageOutput.printf("Limit Persistent: %.1f %%\r\n", payload_val);
inv->sendActivePowerControlRequest(payload_val, PowerLimitControlType::RelativPersistent);

} else if (!strcmp(setting, TOPIC_SUB_LIMIT_PERSISTENT_ABSOLUTE)) {
// Set inverter limit absolute persistent
MessageOutput.printf("Limit Persistent: %d W\r\n", payload_val);
MessageOutput.printf("Limit Persistent: %.1f W\r\n", payload_val);
inv->sendActivePowerControlRequest(payload_val, PowerLimitControlType::AbsolutPersistent);

} else if (!strcmp(setting, TOPIC_SUB_LIMIT_NONPERSISTENT_RELATIVE)) {
// Set inverter limit relative non persistent
MessageOutput.printf("Limit Non-Persistent: %d %%\r\n", payload_val);
MessageOutput.printf("Limit Non-Persistent: %.1f %%\r\n", payload_val);
if (!properties.retain) {
inv->sendActivePowerControlRequest(payload_val, PowerLimitControlType::RelativNonPersistent);
} else {
Expand All @@ -212,7 +212,7 @@ void MqttHandleInverterClass::onMqttMessage(const espMqttClientTypes::MessagePro

} else if (!strcmp(setting, TOPIC_SUB_LIMIT_NONPERSISTENT_ABSOLUTE)) {
// Set inverter limit absolute non persistent
MessageOutput.printf("Limit Non-Persistent: %d W\r\n", payload_val);
MessageOutput.printf("Limit Non-Persistent: %.1f W\r\n", payload_val);
if (!properties.retain) {
inv->sendActivePowerControlRequest(payload_val, PowerLimitControlType::AbsolutNonPersistent);
} else {
Expand All @@ -221,16 +221,16 @@ void MqttHandleInverterClass::onMqttMessage(const espMqttClientTypes::MessagePro

} else if (!strcmp(setting, TOPIC_SUB_POWER)) {
// Turn inverter on or off
MessageOutput.printf("Set inverter power to: %d\r\n", payload_val);
inv->sendPowerControlRequest(payload_val > 0);
MessageOutput.printf("Set inverter power to: %d\r\n", static_cast<int32_t>(payload_val));
inv->sendPowerControlRequest(static_cast<int32_t>(payload_val) > 0);

} else if (!strcmp(setting, TOPIC_SUB_RESTART)) {
// Restart inverter
MessageOutput.printf("Restart inverter\r\n");
if (!properties.retain && payload_val == 1) {
inv->sendRestartControlRequest();
} else {
MessageOutput.println("Ignored because retained");
MessageOutput.println("Ignored because retained or numeric value not '1'");
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/NetworkSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ void NetworkSettingsClass::init(Scheduler& scheduler)
WiFi.setScanMethod(WIFI_ALL_CHANNEL_SCAN);
WiFi.setSortMethod(WIFI_CONNECT_AP_BY_SIGNAL);

WiFi.disconnect(true, true);

WiFi.onEvent(std::bind(&NetworkSettingsClass::NetworkEvent, this, _1));
setupMode();

Expand Down Expand Up @@ -77,6 +79,7 @@ void NetworkSettingsClass::NetworkEvent(const WiFiEvent_t event)
MessageOutput.println("WiFi disconnected");
if (_networkMode == network_mode::WiFi) {
MessageOutput.println("Try reconnecting");
WiFi.disconnect(true, true);
WiFi.reconnect();
raiseEvent(network_event::NETWORK_DISCONNECTED);
}
Expand Down
4 changes: 2 additions & 2 deletions src/WebApi_limit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void WebApiLimitClass::onLimitPost(AsyncWebServerRequest* request)
return;
}

if (root["limit_value"].as<uint16_t>() > MAX_INVERTER_LIMIT) {
if (root["limit_value"].as<float>() > MAX_INVERTER_LIMIT) {
retMsg["message"] = "Limit must between 0 and " STR(MAX_INVERTER_LIMIT) "!";
retMsg["code"] = WebApiError::LimitInvalidLimit;
retMsg["param"]["max"] = MAX_INVERTER_LIMIT;
Expand All @@ -102,7 +102,7 @@ void WebApiLimitClass::onLimitPost(AsyncWebServerRequest* request)
return;
}

uint16_t limit = root["limit_value"].as<uint16_t>();
float limit = root["limit_value"].as<float>();
PowerLimitControlType type = root["limit_type"].as<PowerLimitControlType>();

auto inv = Hoymiles.getInverterBySerial(serial);
Expand Down
2 changes: 1 addition & 1 deletion src/WebApi_webapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void WebApiWebappClass::responseBinaryDataWithETagCache(AsyncWebServerRequest *r
if (eTagMatch) {
response = request->beginResponse(304);
} else {
response = request->beginResponse_P(200, contentType, content, len);
response = request->beginResponse(200, contentType, content, len);
if (contentEncoding.length() > 0) {
response->addHeader("Content-Encoding", contentEncoding);
}
Expand Down
8 changes: 8 additions & 0 deletions webapp/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/prettierrc",
"semi": true,
"tabWidth": 4,
"singleQuote": true,
"printWidth": 120,
"trailingComma": "es5"
}
8 changes: 8 additions & 0 deletions webapp/env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
/// <reference types="vite/client" />

import { Router, Route } from 'vue-router'
declare module '@vue/runtime-core' {
interface ComponentCustomProperties {
$router: Router
$route: Route
}
}
24 changes: 13 additions & 11 deletions webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"preview": "vite preview --port 4173",
"build-only": "vite build",
"type-check": "vue-tsc --noEmit",
"lint": "eslint ."
"lint": "eslint .",
"format": "prettier --write src/"
},
"dependencies": {
"@popperjs/core": "^2.11.8",
Expand All @@ -18,31 +19,32 @@
"mitt": "^3.0.1",
"sortablejs": "^1.15.2",
"spark-md5": "^3.0.2",
"vue": "^3.4.31",
"vue": "^3.4.35",
"vue-i18n": "^9.13.1",
"vue-router": "^4.4.0"
"vue-router": "^4.4.2"
},
"devDependencies": {
"@intlify/unplugin-vue-i18n": "^4.0.0",
"@tsconfig/node18": "^18.2.4",
"@types/bootstrap": "^5.2.10",
"@types/node": "^20.14.9",
"@types/node": "^22.0.2",
"@types/pulltorefreshjs": "^0.1.7",
"@types/sortablejs": "^1.15.8",
"@types/spark-md5": "^3.0.4",
"@vitejs/plugin-vue": "^5.0.5",
"@vitejs/plugin-vue": "^5.1.2",
"@vue/eslint-config-typescript": "^13.0.0",
"@vue/tsconfig": "^0.5.1",
"eslint": "^9.6.0",
"eslint-plugin-vue": "^9.26.0",
"eslint": "^9.8.0",
"eslint-plugin-vue": "^9.27.0",
"npm-run-all": "^4.1.5",
"prettier": "^3.3.3",
"pulltorefreshjs": "^0.1.22",
"sass": "^1.77.6",
"terser": "^5.31.1",
"typescript": "^5.5.2",
"vite": "^5.3.2",
"terser": "^5.31.3",
"typescript": "^5.5.4",
"vite": "^5.3.5",
"vite-plugin-compression": "^0.5.1",
"vite-plugin-css-injected-by-js": "^3.5.1",
"vue-tsc": "^2.0.22"
"vue-tsc": "^2.0.29"
}
}
4 changes: 2 additions & 2 deletions webapp/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

<script lang="ts">
import { defineComponent } from 'vue';
import NavBar from "./components/NavBar.vue";
import NavBar from './components/NavBar.vue';
export default defineComponent({
name: "App",
name: 'App',
components: {
NavBar,
},
Expand Down
Loading

0 comments on commit 38aac57

Please sign in to comment.