mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
fix crashes, clean up, update packages
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"adapter": "react",
|
||||
"baseLocale": "pl",
|
||||
"$schema": "https://unpkg.com/typesafe-i18n@5.17.2/schema/typesafe-i18n.json"
|
||||
"$schema": "https://unpkg.com/typesafe-i18n@5.18.0/schema/typesafe-i18n.json"
|
||||
}
|
||||
|
||||
1287
interface/package-lock.json
generated
1287
interface/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,7 @@
|
||||
"@emotion/styled": "^11.10.5",
|
||||
"@msgpack/msgpack": "^2.8.0",
|
||||
"@mui/icons-material": "^5.11.0",
|
||||
"@mui/material": "^5.11.0",
|
||||
"@mui/material": "^5.11.1",
|
||||
"@table-library/react-table-library": "4.0.23",
|
||||
"@types/lodash": "^4.14.191",
|
||||
"@types/node": "^18.11.17",
|
||||
@@ -27,10 +27,10 @@
|
||||
"react-dom": "^18.2.0",
|
||||
"react-dropzone": "^14.2.3",
|
||||
"react-icons": "^4.7.1",
|
||||
"react-router-dom": "^6.5.0",
|
||||
"react-router-dom": "^6.6.0",
|
||||
"react-scripts": "5.0.1",
|
||||
"sockette": "^2.0.6",
|
||||
"typesafe-i18n": "^5.17.2",
|
||||
"typesafe-i18n": "^5.18.0",
|
||||
"typescript": "^4.9.4"
|
||||
},
|
||||
"scripts": {
|
||||
|
||||
@@ -249,14 +249,8 @@ uint8_t Command::call(const uint8_t device_type, const char * cmd, const char *
|
||||
uint8_t Command::call(const uint8_t device_type, const char * cmd, const char * value, const bool is_admin, const int8_t id, JsonObject & output) {
|
||||
uint8_t return_code = CommandRet::OK;
|
||||
|
||||
auto dname = EMSdevice::device_type_2_device_name(device_type);
|
||||
|
||||
uint8_t device_id = 0;
|
||||
for (const auto & emsdevice : emsesp::EMSESP::emsdevices) {
|
||||
if (emsdevice->device_type() == device_type && emsdevice->has_cmd(id, cmd)) {
|
||||
device_id = emsdevice->device_id();
|
||||
}
|
||||
}
|
||||
auto dname = EMSdevice::device_type_2_device_name(device_type);
|
||||
uint8_t device_id = EMSESP::device_id_from_cmd(device_type, id, cmd);
|
||||
|
||||
// see if there is a command registered
|
||||
auto cf = find_command(device_type, device_id, cmd);
|
||||
|
||||
@@ -813,9 +813,9 @@ void EMSdevice::generate_values_web(JsonObject & output) {
|
||||
} else if ((dv.type == DeviceValueType::USHORT) && Helpers::hasValue(*(uint16_t *)(dv.value_p))) {
|
||||
obj["v"] = Helpers::transformNumFloat(*(uint16_t *)(dv.value_p), dv.numeric_operator, fahrenheit);
|
||||
} else if ((dv.type == DeviceValueType::ULONG) && Helpers::hasValue(*(uint32_t *)(dv.value_p))) {
|
||||
obj["v"] = (*(uint32_t *)(dv.value_p) / dv.numeric_operator); // ULONG always have positive num_op
|
||||
obj["v"] = dv.numeric_operator > 0 ? *(uint32_t *)(dv.value_p) / dv.numeric_operator : *(uint32_t *)(dv.value_p);
|
||||
} else if ((dv.type == DeviceValueType::TIME) && Helpers::hasValue(*(uint32_t *)(dv.value_p))) {
|
||||
obj["v"] = (*(uint32_t *)(dv.value_p) / dv.numeric_operator);
|
||||
obj["v"] = dv.numeric_operator > 0 ? *(uint32_t *)(dv.value_p) / dv.numeric_operator : *(uint32_t *)(dv.value_p);
|
||||
} else {
|
||||
obj["v"] = ""; // must have a value for sorting to work
|
||||
}
|
||||
@@ -923,9 +923,9 @@ void EMSdevice::generate_values_web_customization(JsonArray & output) {
|
||||
} else if (dv.type == DeviceValueType::USHORT) {
|
||||
obj["v"] = Helpers::transformNumFloat(*(uint16_t *)(dv.value_p), dv.numeric_operator, fahrenheit);
|
||||
} else if (dv.type == DeviceValueType::ULONG) {
|
||||
obj["v"] = (*(uint32_t *)(dv.value_p) / dv.numeric_operator);
|
||||
obj["v"] = dv.numeric_operator > 0 ? *(uint32_t *)(dv.value_p) / dv.numeric_operator : *(uint32_t *)(dv.value_p);
|
||||
} else if (dv.type == DeviceValueType::TIME) {
|
||||
obj["v"] = (*(uint32_t *)(dv.value_p) / dv.numeric_operator);
|
||||
obj["v"] = dv.numeric_operator > 0 ? *(uint32_t *)(dv.value_p) / dv.numeric_operator : *(uint32_t *)(dv.value_p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,6 +114,15 @@ bool EMSESP::cmd_is_readonly(const uint8_t device_type, const uint8_t device_id,
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t EMSESP::device_id_from_cmd(const uint8_t device_type, const int8_t id, const char * cmd) {
|
||||
for (const auto & emsdevice : emsdevices) {
|
||||
if (emsdevice && emsdevice->device_type() == device_type && emsdevice->has_cmd(id, cmd)) {
|
||||
return emsdevice->device_id();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// clears list of recognized devices
|
||||
void EMSESP::clear_all_devices() {
|
||||
// temporarily removed: clearing the list causes a crash, the associated commands and mqtt should also be removed.
|
||||
|
||||
@@ -131,6 +131,7 @@ class EMSESP {
|
||||
static bool device_exists(const uint8_t device_id);
|
||||
static bool cmd_is_readonly(const uint8_t device_type, const uint8_t device_id, const char * cmd, const int8_t id);
|
||||
|
||||
static uint8_t device_id_from_cmd(const uint8_t device_type, const int8_t id, const char * cmd);
|
||||
static uint8_t count_devices(const uint8_t device_type);
|
||||
static uint8_t count_devices();
|
||||
static uint8_t device_index(const uint8_t device_type, const uint8_t unique_id);
|
||||
|
||||
Reference in New Issue
Block a user