From efa98757446a9475b6a70d4c2d223a4ac5588c50 Mon Sep 17 00:00:00 2001 From: Proddy Date: Sat, 4 Feb 2023 14:08:25 +0100 Subject: [PATCH 1/3] fix bug with custom name --- mock-api/server.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/mock-api/server.js b/mock-api/server.js index 93af73526..3ea2ca635 100644 --- a/mock-api/server.js +++ b/mock-api/server.js @@ -127,6 +127,12 @@ network_settings = { enableMDNS: true, enableCORS: false, CORSOrigin: '*', + enableIPv6: false, + local_ip: '', + gateway_ip: '', + subnet_mask: '', + dns_ip_1: '', + dns_ip_2: '', } const network_status = { status: 3, @@ -348,6 +354,7 @@ settings = { bool_format: 1, bool_dashboard: 1, enum_format: 1, + fahrenheit: false, } const emsesp_devices = { @@ -411,6 +418,7 @@ const emsesp_coredata = { e: 3, }, ], + s_n: 'Sensors', active_sensors: 8, analog_enabled: true, } @@ -589,7 +597,7 @@ const emsesp_devicedata_4 = { ], } -// CUSTOMIZATION +// CUSTOMIZATIONS const emsesp_deviceentities_1 = [ { @@ -934,7 +942,10 @@ rest_server.post(EMSESP_DEVICEENTITIES_ENDPOINT, (req, res) => { function updateMask(entity, de, dd) { const current_mask = parseInt(entity.slice(0, 2), 16) - const shortname_with_customname = entity.slice(2) + + // strip of any min/max ranges + const shortname_with_customname = entity.slice(2).split('>')[0] + const shortname = shortname_with_customname.split('|')[0] const new_custom_name = shortname_with_customname.split('|')[1] @@ -961,6 +972,7 @@ function updateMask(entity, de, dd) { // see if the custom name has changed const old_custom_name = dd.data[dd_objIndex].cn + console.log('comparing old ' + old_custom_name + ' with new ' + new_custom_name) if (old_custom_name !== new_custom_name) { changed = true new_fullname = new_custom_name @@ -976,6 +988,7 @@ function updateMask(entity, de, dd) { de[de_objIndex].m = current_mask de[de_objIndex].cn = new_fullname dd.data[dd_objIndex].id = current_mask.toString(16).padStart(2, '0') + new_fullname + dd.data[dd_objIndex].cn = new_fullname } console.log('new dd:') From 50e73e2a04ec3d2513e8d2cd18e990d46a1b3e0f Mon Sep 17 00:00:00 2001 From: Proddy Date: Sat, 4 Feb 2023 14:08:41 +0100 Subject: [PATCH 2/3] formatting --- interface/src/project/SettingsCustomization.tsx | 8 ++++---- src/emsdevicevalue.h | 10 +++++----- src/emsesp.cpp | 2 +- src/mqtt.cpp | 8 ++++---- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/interface/src/project/SettingsCustomization.tsx b/interface/src/project/SettingsCustomization.tsx index 37130fbad..eae53f2e4 100644 --- a/interface/src/project/SettingsCustomization.tsx +++ b/interface/src/project/SettingsCustomization.tsx @@ -499,7 +499,7 @@ const SettingsCustomization: FC = () => { value={getMaskString(de.m)} onChange={(event, mask) => { de.m = getMaskNumber(mask); - if (de.n === '' && (de.m & DeviceEntityMask.DV_READONLY)) { + if (de.n === '' && de.m & DeviceEntityMask.DV_READONLY) { de.m = de.m | DeviceEntityMask.DV_WEB_EXCLUDE; } if (de.m & DeviceEntityMask.DV_WEB_EXCLUDE) { @@ -534,7 +534,7 @@ const SettingsCustomization: FC = () => { isSet={(de.m & DeviceEntityMask.DV_WEB_EXCLUDE) === DeviceEntityMask.DV_WEB_EXCLUDE} /> - + { )} - {!deviceEntity && (formatName(de))} + {!deviceEntity && formatName(de)} {!deviceEntity && !(de.m & DeviceEntityMask.DV_READONLY) && formatValue(de.mi)} {!deviceEntity && !(de.m & DeviceEntityMask.DV_READONLY) && formatValue(de.ma)} - {!deviceEntity && (formatValue(de.v))} + {!deviceEntity && formatValue(de.v)} ))} diff --git a/src/emsdevicevalue.h b/src/emsdevicevalue.h index 5d768b7e7..dd7107b08 100644 --- a/src/emsdevicevalue.h +++ b/src/emsdevicevalue.h @@ -181,11 +181,11 @@ class DeviceValue { bool hasValue() const; bool get_min_max(int16_t & dv_set_min, uint16_t & dv_set_max); - void set_custom_minmax(); - bool get_custom_min(int16_t & val); - bool get_custom_max(uint16_t & val); - std::string get_custom_fullname() const; - std::string get_fullname() const; + void set_custom_minmax(); + bool get_custom_min(int16_t & val); + bool get_custom_max(uint16_t & val); + std::string get_custom_fullname() const; + std::string get_fullname() const; static std::string get_name(std::string & entity); // dv state flags diff --git a/src/emsesp.cpp b/src/emsesp.cpp index bfb4ee506..1d2dc4873 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -1078,7 +1078,7 @@ bool EMSESP::add_device(const uint8_t device_id, const uint8_t product_id, const name = "Modem"; device_type = DeviceType::CONNECT; } else if (device_id == EMSdevice::EMS_DEVICE_ID_CONVERTER) { - name = "Converter"; // generic + name = "Converter"; // generic } else if (device_id == EMSdevice::EMS_DEVICE_ID_CLOCK) { name = "Clock"; // generic device_type = DeviceType::CONTROLLER; diff --git a/src/mqtt.cpp b/src/mqtt.cpp index 2034bd354..9afa18c29 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -629,10 +629,10 @@ void Mqtt::ha_status() { dev["sw"] = "v" + std::string(EMSESP_APP_VERSION); dev["mf"] = "proddy"; dev["mdl"] = "EMS-ESP"; - if (EMSESP::system_.ethernet_connected()) - dev["cu"] = "http://" + ETH.localIP().toString(); - else - dev["cu"] = "http://" + WiFi.localIP().toString(); +#ifndef EMSESP_STANDALONE + dev["cu"] = "http://" + (EMSESP::system_.ethernet_connected() ? ETH.localIP().toString() : WiFi.localIP().toString()); +#endif + JsonArray ids = dev.createNestedArray("ids"); ids.add("ems-esp"); From 39bc0d5fb256208f048b38a153a5a534dec86e14 Mon Sep 17 00:00:00 2001 From: Proddy Date: Sat, 4 Feb 2023 14:08:49 +0100 Subject: [PATCH 3/3] update packages --- interface/.typesafe-i18n.json | 8 ++++---- interface/package-lock.json | 26 +++++++++++++------------- interface/package.json | 8 ++++---- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/interface/.typesafe-i18n.json b/interface/.typesafe-i18n.json index e3832546d..d4c1b88f5 100644 --- a/interface/.typesafe-i18n.json +++ b/interface/.typesafe-i18n.json @@ -1,5 +1,5 @@ { - "adapter": "react", - "baseLocale": "pl", - "$schema": "https://unpkg.com/typesafe-i18n@5.21.0/schema/typesafe-i18n.json" -} \ No newline at end of file + "adapter": "react", + "baseLocale": "pl", + "$schema": "https://unpkg.com/typesafe-i18n@5.22.0/schema/typesafe-i18n.json" +} diff --git a/interface/package-lock.json b/interface/package-lock.json index 164588769..4861f1b53 100644 --- a/interface/package-lock.json +++ b/interface/package-lock.json @@ -12,15 +12,15 @@ "@emotion/styled": "^11.10.5", "@msgpack/msgpack": "^2.8.0", "@mui/icons-material": "^5.11.0", - "@mui/material": "^5.11.6", - "@table-library/react-table-library": "4.0.23", + "@mui/material": "^5.11.7", + "@table-library/react-table-library": "4.0.24", "@types/lodash": "^4.14.191", "@types/node": "^18.11.18", "@types/react": "^18.0.27", "@types/react-dom": "^18.0.10", "@types/react-router-dom": "^5.3.3", "async-validator": "^4.2.5", - "axios": "^1.2.6", + "axios": "^1.3.2", "jwt-decode": "^3.1.2", "lodash": "^4.17.21", "notistack": "^2.0.8", @@ -32,7 +32,7 @@ "react-router-dom": "^6.8.0", "react-scripts": "5.0.1", "sockette": "^2.0.6", - "typesafe-i18n": "^5.21.0", + "typesafe-i18n": "^5.22.0", "typescript": "^4.9.5" }, "devDependencies": { @@ -3775,9 +3775,9 @@ } }, "node_modules/@table-library/react-table-library": { - "version": "4.0.23", - "resolved": "https://registry.npmjs.org/@table-library/react-table-library/-/react-table-library-4.0.23.tgz", - "integrity": "sha512-o2L/fqhwQNxsNbbm3LIiyZzEwaTslhG1tY9ArkYdS0xJyRhJxcOLfbJ3+dcnOOn+aIJpmPmQH+gr7RYJC0P8uw==", + "version": "4.0.24", + "resolved": "https://registry.npmjs.org/@table-library/react-table-library/-/react-table-library-4.0.24.tgz", + "integrity": "sha512-tOeKermNhSDKGVvzBlF8gtLVWl+lWbCHk0XH/7s1ybZ9XI8TXpogzXavyRfObGFAIyeazr7Qy5bWGWnE4uueUg==", "dependencies": { "clsx": "1.1.1", "react-virtualized-auto-sizer": "1.0.6", @@ -5077,9 +5077,9 @@ } }, "node_modules/axios": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.2.6.tgz", - "integrity": "sha512-rC/7F08XxZwjMV4iuWv+JpD3E0Ksqg9nac4IIg6RwNuF0JTeWoCo/mBNG54+tNhhI11G3/VDRbdDQTs9hGp4pQ==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.3.2.tgz", + "integrity": "sha512-1M3O703bYqYuPhbHeya5bnhpYVsDDRyQSabNja04mZtboLNSuZ4YrltestrLXfHgmzua4TpUqRiVKbiQuo2epw==", "dependencies": { "follow-redirects": "^1.15.0", "form-data": "^4.0.0", @@ -16790,9 +16790,9 @@ } }, "node_modules/typesafe-i18n": { - "version": "5.21.0", - "resolved": "https://registry.npmjs.org/typesafe-i18n/-/typesafe-i18n-5.21.0.tgz", - "integrity": "sha512-hfJQ7j0jvz21s2Iiv92Nx7rGyEQZJnVaQ64ek6Bn3IDaADiGFoUbSc7ZPYqeI9iTO8mOe35ACJ9MTn2cEp1ECA==", + "version": "5.22.0", + "resolved": "https://registry.npmjs.org/typesafe-i18n/-/typesafe-i18n-5.22.0.tgz", + "integrity": "sha512-I6dH/lmBEOOMdLmHbxOZK4x7wQrf7ZrgT2ynTzcJZAIJIfj0QdU8ncKOfrMOuTf3ddpe/MLSH1NKLxfPS7l2dQ==", "bin": { "typesafe-i18n": "cli/typesafe-i18n.mjs" }, diff --git a/interface/package.json b/interface/package.json index f9681274c..59cd376cf 100644 --- a/interface/package.json +++ b/interface/package.json @@ -8,15 +8,15 @@ "@emotion/styled": "^11.10.5", "@msgpack/msgpack": "^2.8.0", "@mui/icons-material": "^5.11.0", - "@mui/material": "^5.11.6", - "@table-library/react-table-library": "4.0.23", + "@mui/material": "^5.11.7", + "@table-library/react-table-library": "4.0.24", "@types/lodash": "^4.14.191", "@types/node": "^18.11.18", "@types/react": "^18.0.27", "@types/react-dom": "^18.0.10", "@types/react-router-dom": "^5.3.3", "async-validator": "^4.2.5", - "axios": "^1.2.6", + "axios": "^1.3.2", "jwt-decode": "^3.1.2", "lodash": "^4.17.21", "notistack": "^2.0.8", @@ -28,7 +28,7 @@ "react-router-dom": "^6.8.0", "react-scripts": "5.0.1", "sockette": "^2.0.6", - "typesafe-i18n": "^5.21.0", + "typesafe-i18n": "^5.22.0", "typescript": "^4.9.5" }, "scripts": {