diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 9178e61a3..56c70b0ff 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -23,10 +23,10 @@ _Make sure your have performed every step and checked the applicable boxes befor - [ ] Searched the issue in [discussions](https://github.com/emsesp/EMS-ESP32/discussions) - [ ] Searched the issue in the [docs](https://emsesp.github.io/docs/Troubleshooting/) - [ ] Searched the issue in the [chat](https://discord.gg/3J3GgnzpyT) -- [ ] Provide the output of : +- [ ] Provide the System information in the area below, taken from `http:///api/system` -```lua - System information output here: +```json + Paste System information here.... ``` @@ -47,4 +47,4 @@ _If applicable, add screenshots to help explain your issue._ _Add any other context about the issue here._ -**(Please, remember to close the issue when it has been addressed)** +**(Please remember to close the issue when it has been addressed)** diff --git a/CHANGELOG_LATEST.md b/CHANGELOG_LATEST.md index 0006be584..41c203aa4 100644 --- a/CHANGELOG_LATEST.md +++ b/CHANGELOG_LATEST.md @@ -2,12 +2,12 @@ ## [3.7.0] -## **IMPORTANT! BREAKING CHANGES** +## **IMPORTANT! BREAKING CHANGES with 3.6.5** - new device WATER shows dhw entities from MM100 and SM100 in dhw setting - renamed WWC to DHW, always create DHW nests/topics, remove ww prefix from mqtt names [#1634](https://github.com/emsesp/EMS-ESP32/issues/1634) - change temperaturesensor id to underscore -- system/info API command has the word 'Info' removed from the object name for each section (E.g. 'Network Info' is now just 'Network') +- system/info API command has it's JSON keys and names changed to camelCase ## Added @@ -52,3 +52,4 @@ - Include TXT file along with the generated CSV for Device Data export/download - thermostat/remotetemp as command [#1835](https://github.com/emsesp/EMS-ESP32/discussions/1835) - temperaturesensor id notation with underscore [#1794](https://github.com/emsesp/EMS-ESP32/discussions/1794) +- Change key-names in JSON to be compliant and consistent [#1860](https://github.com/emsesp/EMS-ESP32/issues/1860) diff --git a/interface/package.json b/interface/package.json index 06a9f0717..2958936ce 100644 --- a/interface/package.json +++ b/interface/package.json @@ -26,8 +26,8 @@ "@alova/scene-react": "^1.6.1", "@emotion/react": "^11.13.0", "@emotion/styled": "^11.13.0", - "@mui/icons-material": "^5.16.4", - "@mui/material": "^5.16.4", + "@mui/icons-material": "^5.16.5", + "@mui/material": "^5.16.5", "@table-library/react-table-library": "4.1.7", "@types/lodash-es": "^4.17.12", "@types/node": "^20.14.12", @@ -59,12 +59,12 @@ "concurrently": "^8.2.2", "eslint": "^9.7.0", "eslint-config-prettier": "^9.1.0", - "preact": "^10.23.0", + "preact": "^10.23.1", "prettier": "^3.3.3", "rollup-plugin-visualizer": "^5.12.0", "terser": "^5.31.3", "typescript-eslint": "8.0.0-alpha.10", - "vite": "^5.3.4", + "vite": "^5.3.5", "vite-plugin-imagemin": "^0.6.1", "vite-tsconfig-paths": "^4.3.2" }, diff --git a/interface/src/api/system.ts b/interface/src/api/system.ts index 832809fe1..04e65484d 100644 --- a/interface/src/api/system.ts +++ b/interface/src/api/system.ts @@ -3,13 +3,13 @@ /* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/no-unsafe-return */ -import type { ESPSystemStatus, LogSettings, SystemStatus } from 'types'; +import type { HardwareStatus, LogSettings, SystemStatus } from 'types'; import { alovaInstance, alovaInstanceGH } from './endpoints'; -// ESPSystemStatus - also used to ping in Restart monitor for pinging -export const readESPSystemStatus = () => - alovaInstance.Get('/rest/ESPSystemStatus'); +// HardwareStatus - also used to ping in Restart monitor for pinging +export const readHardwareStatus = () => + alovaInstance.Get('/rest/HardwareStatus'); // SystemStatus export const readSystemStatus = () => diff --git a/interface/src/app/settings/UploadDownload.tsx b/interface/src/app/settings/UploadDownload.tsx index 6c49d6842..c041631db 100644 --- a/interface/src/app/settings/UploadDownload.tsx +++ b/interface/src/app/settings/UploadDownload.tsx @@ -57,7 +57,7 @@ const UploadDownload: FC = () => { data: data, send: loadData, error - } = useRequest(SystemApi.readESPSystemStatus, { force: true }); + } = useRequest(SystemApi.readHardwareStatus, { force: true }); const { data: latestVersion } = useRequest(SystemApi.getStableVersion, { immediate: true, diff --git a/interface/src/app/status/HardwareStatus.tsx b/interface/src/app/status/HardwareStatus.tsx index e97d77a55..2b7c00340 100644 --- a/interface/src/app/status/HardwareStatus.tsx +++ b/interface/src/app/status/HardwareStatus.tsx @@ -32,7 +32,7 @@ function formatNumber(num: number) { return new Intl.NumberFormat().format(num); } -const ESPSystemStatus: FC = () => { +const HardwareStatus: FC = () => { const { LL } = useI18nContext(); useLayoutTitle(LL.STATUS_OF(LL.HARDWARE())); @@ -41,7 +41,7 @@ const ESPSystemStatus: FC = () => { data: data, send: loadData, error - } = useRequest(SystemApi.readESPSystemStatus, { force: true }); + } = useRequest(SystemApi.readHardwareStatus, { force: true }); const content = () => { if (!data) { @@ -117,7 +117,9 @@ const ESPSystemStatus: FC = () => { formatNumber(data.free_heap) + ' KB (' + formatNumber(data.max_alloc_heap) + - ' KB max alloc)' + ' KB max alloc, ' + + formatNumber(data.free_caps) + + ' KB caps)' } /> @@ -218,4 +220,4 @@ const ESPSystemStatus: FC = () => { return {content()}; }; -export default ESPSystemStatus; +export default HardwareStatus; diff --git a/interface/src/types/system.ts b/interface/src/types/system.ts index 5dfca23c3..b1f2173db 100644 --- a/interface/src/types/system.ts +++ b/interface/src/types/system.ts @@ -2,7 +2,7 @@ import type { busConnectionStatus } from 'app/main/types'; import type { NetworkConnectionStatus } from './network'; -export interface ESPSystemStatus { +export interface HardwareStatus { emsesp_version: string; esp_platform: string; max_alloc_heap: number; @@ -24,6 +24,7 @@ export interface ESPSystemStatus { psram_size?: number; free_psram?: number; has_loader: boolean; + free_caps: number; model: string; } diff --git a/interface/yarn.lock b/interface/yarn.lock index a67fdcdba..19ceffcf8 100644 --- a/interface/yarn.lock +++ b/interface/yarn.lock @@ -1187,16 +1187,16 @@ __metadata: languageName: node linkType: hard -"@mui/core-downloads-tracker@npm:^5.16.4": - version: 5.16.4 - resolution: "@mui/core-downloads-tracker@npm:5.16.4" - checksum: 10c0/639099e14132a66a472a92432d2b0fca7c2ebb718afcc22b4a1ebd537fe34f96fed57d95e84525461d1ab2a41672a14a746da7de8060ed3a60fafc0beadb3ebb +"@mui/core-downloads-tracker@npm:^5.16.5": + version: 5.16.5 + resolution: "@mui/core-downloads-tracker@npm:5.16.5" + checksum: 10c0/f8052e42e0694b4c95b0edf1893325417ac76fbe9b7714ddad56f607f251d5edbdecf3e7ae34b28ecd7e6d9eee4d3f958d3ff743db98cb35d4e69eef30dd0e23 languageName: node linkType: hard -"@mui/icons-material@npm:^5.16.4": - version: 5.16.4 - resolution: "@mui/icons-material@npm:5.16.4" +"@mui/icons-material@npm:^5.16.5": + version: 5.16.5 + resolution: "@mui/icons-material@npm:5.16.5" dependencies: "@babel/runtime": "npm:^7.23.9" peerDependencies: @@ -1206,19 +1206,19 @@ __metadata: peerDependenciesMeta: "@types/react": optional: true - checksum: 10c0/e6cd3b64dd02d21182f0a0509d412a084fdea8752e4a202907cd1cf92a5476ec87e6074a409ebcb9a35e29c91d20729e9eddd9530c1d3755a93b0f56cf3be519 + checksum: 10c0/6ba9cbb5bc7a5d3fbc297683973c7c15c4a95f8b12cf55cadd069d4ecbaf5639bb9044da82ddc029c04203ee81a8ac691ea5ada769dc86fef3f25a13fcec44fe languageName: node linkType: hard -"@mui/material@npm:^5.16.4": - version: 5.16.4 - resolution: "@mui/material@npm:5.16.4" +"@mui/material@npm:^5.16.5": + version: 5.16.5 + resolution: "@mui/material@npm:5.16.5" dependencies: "@babel/runtime": "npm:^7.23.9" - "@mui/core-downloads-tracker": "npm:^5.16.4" - "@mui/system": "npm:^5.16.4" + "@mui/core-downloads-tracker": "npm:^5.16.5" + "@mui/system": "npm:^5.16.5" "@mui/types": "npm:^7.2.15" - "@mui/utils": "npm:^5.16.4" + "@mui/utils": "npm:^5.16.5" "@popperjs/core": "npm:^2.11.8" "@types/react-transition-group": "npm:^4.4.10" clsx: "npm:^2.1.0" @@ -1239,16 +1239,16 @@ __metadata: optional: true "@types/react": optional: true - checksum: 10c0/ab12f3219d3a6b5dd3564e7b3826e283167c64b947774e3e35301419d35cd9875d45d8625e8c145d59fe38c7a7ef110251b11a47b94e5468fa96afbb179d2e1f + checksum: 10c0/d147f4c0b8b7cb640da2c4e2511bb8a8dd4152caaf49dc4f380dc37bac4960722b30e7fc310f3339e34a560a3c873f764cac6c37295407ca1f771d4e0854febb languageName: node linkType: hard -"@mui/private-theming@npm:^5.16.4": - version: 5.16.4 - resolution: "@mui/private-theming@npm:5.16.4" +"@mui/private-theming@npm:^5.16.5": + version: 5.16.5 + resolution: "@mui/private-theming@npm:5.16.5" dependencies: "@babel/runtime": "npm:^7.23.9" - "@mui/utils": "npm:^5.16.4" + "@mui/utils": "npm:^5.16.5" prop-types: "npm:^15.8.1" peerDependencies: "@types/react": ^17.0.0 || ^18.0.0 @@ -1256,7 +1256,7 @@ __metadata: peerDependenciesMeta: "@types/react": optional: true - checksum: 10c0/3c191afe4025cac9bbdecae1ea6232155e71c45c2929acce1ce31dd4c913800d6e9eaa38897e91dd7bff74529de3247768d26120c54c33ef69e40136c9ec6b04 + checksum: 10c0/4850ff47b5a4b1b19356fbd30ed675db6f688eda02bebf16d8b23bebc67bd55baaf4fdba1acae7d5b5e6bbdc2ac0f01c1c85005886b1ba098df65a9b26d4d4c7 languageName: node linkType: hard @@ -1281,15 +1281,15 @@ __metadata: languageName: node linkType: hard -"@mui/system@npm:^5.16.4": - version: 5.16.4 - resolution: "@mui/system@npm:5.16.4" +"@mui/system@npm:^5.16.5": + version: 5.16.5 + resolution: "@mui/system@npm:5.16.5" dependencies: "@babel/runtime": "npm:^7.23.9" - "@mui/private-theming": "npm:^5.16.4" + "@mui/private-theming": "npm:^5.16.5" "@mui/styled-engine": "npm:^5.16.4" "@mui/types": "npm:^7.2.15" - "@mui/utils": "npm:^5.16.4" + "@mui/utils": "npm:^5.16.5" clsx: "npm:^2.1.0" csstype: "npm:^3.1.3" prop-types: "npm:^15.8.1" @@ -1305,7 +1305,7 @@ __metadata: optional: true "@types/react": optional: true - checksum: 10c0/1665e2f9b6b30f2177b49b19bc778980e3f076167a1436f8b8bf513075674192e33684ab3a9262144f6008d3f9521ac4c073f5e15abfb4c989efc78cd09f8ecc + checksum: 10c0/af3eccfa96e78e00a8b5a71c025b57baeb85b02adb44a7e1e96779ddcb3f0070d9880dcb6b8a7bdb78339fa1bbf892b63ef80b81d0497c9bbd45f5ea14958c91 languageName: node linkType: hard @@ -1321,11 +1321,12 @@ __metadata: languageName: node linkType: hard -"@mui/utils@npm:^5.16.4": - version: 5.16.4 - resolution: "@mui/utils@npm:5.16.4" +"@mui/utils@npm:^5.16.5": + version: 5.16.5 + resolution: "@mui/utils@npm:5.16.5" dependencies: "@babel/runtime": "npm:^7.23.9" + "@mui/types": "npm:^7.2.15" "@types/prop-types": "npm:^15.7.12" clsx: "npm:^2.1.1" prop-types: "npm:^15.8.1" @@ -1336,7 +1337,7 @@ __metadata: peerDependenciesMeta: "@types/react": optional: true - checksum: 10c0/f3d6c22a61440b76c3396c437669668e5733db7fcbb82de571a98b9d8259d690b6817081269e961cb20a67a28bedcfa85f234342ee560daf6a981fcce85ab088 + checksum: 10c0/8b51190232c192db7dfd9fd33e054a789bf162d7ccfb40ee21d6b2636f07aa69d60e3f5bdc6ded1b3520fa4f93134101a5c4158772f589e56eff3a04f1a59a10 languageName: node linkType: hard @@ -2077,8 +2078,8 @@ __metadata: "@emotion/react": "npm:^11.13.0" "@emotion/styled": "npm:^11.13.0" "@eslint/js": "npm:^9.7.0" - "@mui/icons-material": "npm:^5.16.4" - "@mui/material": "npm:^5.16.4" + "@mui/icons-material": "npm:^5.16.5" + "@mui/material": "npm:^5.16.5" "@preact/compat": "npm:^17.1.2" "@preact/preset-vite": "npm:^2.9.0" "@table-library/react-table-library": "npm:4.1.7" @@ -2098,7 +2099,7 @@ __metadata: jwt-decode: "npm:^4.0.0" lodash-es: "npm:^4.17.21" mime-types: "npm:^2.1.35" - preact: "npm:^10.23.0" + preact: "npm:^10.23.1" prettier: "npm:^3.3.3" react: "npm:latest" react-dom: "npm:latest" @@ -2111,7 +2112,7 @@ __metadata: typesafe-i18n: "npm:^5.26.2" typescript: "npm:^5.5.4" typescript-eslint: "npm:8.0.0-alpha.10" - vite: "npm:^5.3.4" + vite: "npm:^5.3.5" vite-plugin-imagemin: "npm:^0.6.1" vite-tsconfig-paths: "npm:^4.3.2" languageName: unknown @@ -6070,10 +6071,10 @@ __metadata: languageName: node linkType: hard -"preact@npm:^10.23.0": - version: 10.23.0 - resolution: "preact@npm:10.23.0" - checksum: 10c0/00bcf490ce13c0fd70e3d2e2418466419b31f201b28d35f173d7ddcb66b421a3f6ca569541de581cbbf4ec7b2adef3f391d631dca7a4fd86708d81ca08259c1c +"preact@npm:^10.23.1": + version: 10.23.1 + resolution: "preact@npm:10.23.1" + checksum: 10c0/f0eb37999bfa9cbc725e57e189387c77919fa05d17cdc3c4ff41660298805159867689f1d974eb8e6496288c0212760490d0e6f1c12022e0f5a74d06cc618e85 languageName: node linkType: hard @@ -7496,9 +7497,9 @@ __metadata: languageName: node linkType: hard -"vite@npm:^5.3.4": - version: 5.3.4 - resolution: "vite@npm:5.3.4" +"vite@npm:^5.3.5": + version: 5.3.5 + resolution: "vite@npm:5.3.5" dependencies: esbuild: "npm:^0.21.3" fsevents: "npm:~2.3.3" @@ -7532,7 +7533,7 @@ __metadata: optional: true bin: vite: bin/vite.js - checksum: 10c0/604a1c8698bcf09d6889533c552f20137c80cb5027e9e7ddf6215d51e3df763414f8712168c22b3c8c16383aff9447094c05f21d7cca3c115874ff9d12e1538e + checksum: 10c0/795c7e0dbc94b96c4a0aff0d5d4b349dd28ad8b7b70979c1010f96b4d83f7d6c1700ebd6fed91de2e021b0a3689b9abc2d8017f6dfa8c9a6ca5c7af637d6afc6 languageName: node linkType: hard diff --git a/mock-api/rest_server.ts b/mock-api/rest_server.ts index a79e400a6..8ff3bba1c 100644 --- a/mock-api/rest_server.ts +++ b/mock-api/rest_server.ts @@ -336,7 +336,7 @@ const SYSTEM_STATUS_ENDPOINT = REST_ENDPOINT_ROOT + 'systemStatus'; const ACTIVITY_ENDPOINT = REST_ENDPOINT_ROOT + 'activity'; // SETTINGS -const ESPSYSTEM_STATUS_ENDPOINT = REST_ENDPOINT_ROOT + 'ESPSystemStatus'; +const HARDWARE_STATUS_ENDPOINT = REST_ENDPOINT_ROOT + 'HardwareStatus'; const SECURITY_SETTINGS_ENDPOINT = REST_ENDPOINT_ROOT + 'securitySettings'; const RESTART_ENDPOINT = REST_ENDPOINT_ROOT + 'restart'; const RESTART_PARTITION_ENDPOINT = REST_ENDPOINT_ROOT + 'partition'; @@ -347,28 +347,29 @@ const VERIFY_AUTHORIZATION_ENDPOINT = REST_ENDPOINT_ROOT + 'verifyAuthorization' const SIGN_IN_ENDPOINT = REST_ENDPOINT_ROOT + 'signIn'; const GENERATE_TOKEN_ENDPOINT = REST_ENDPOINT_ROOT + 'generateToken'; -const ESPsystem_status = { +const hardware_status = { emsesp_version: '3.7-demo', esp_platform: 'ESP32', - max_alloc_heap: 89, + max_alloc_heap: 107, cpu_type: 'ESP32-S3', - cpu_rev: '0', + cpu_rev: 3, cpu_cores: 2, cpu_freq_mhz: 240, - free_heap: 143, - arduino_version: 'ESP32 Arduino v2.0.14', - sdk_version: 'v4.4.2', + free_heap: 166, + arduino_version: 'ESP32 Arduino v2.0.16', + sdk_version: 'v4.4.7', partition: 'app0', flash_chip_size: 4096, flash_chip_speed: 40000000, app_used: 1863, app_free: 121, - fs_used: 40, - fs_free: 24, + fs_used: 24, + fs_free: 2024, free_mem: 100, - psram_size: 0, - free_psram: 0, + psram_size: 4093, + free_psram: 4074, has_loader: true, + free_caps: 4204, // model: '' model: 'BBQKees Electronics EMS Gateway E32 V2 (E32 V2.0 P3/2024011)' }; @@ -4203,7 +4204,7 @@ router router .get(SYSTEM_STATUS_ENDPOINT, () => system_status) .get(ACTIVITY_ENDPOINT, () => activity) - .get(ESPSYSTEM_STATUS_ENDPOINT, () => ESPsystem_status) + .get(HARDWARE_STATUS_ENDPOINT, () => hardware_status) .get(SECURITY_SETTINGS_ENDPOINT, () => security_settings) .post(SECURITY_SETTINGS_ENDPOINT, async (request: any) => { security_settings = await request.json(); diff --git a/src/system.cpp b/src/system.cpp index 98f5e8555..60e0b774e 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -1358,30 +1358,29 @@ bool System::get_value_info(JsonObject root, const char * command) { // export status information including the device information // http://ems-esp/api/system/info -// TODO camelCase - #1860 bool System::command_info(const char * value, const int8_t id, JsonObject output) { JsonObject node; // System - node = output["System"].to(); - node["version"] = EMSESP_APP_VERSION; - node["uptime"] = uuid::log::format_timestamp_ms(uuid::get_uptime_ms(), 3); - node["uptime (seconds)"] = uuid::get_uptime_sec(); + node = output["system"].to(); + node["version"] = EMSESP_APP_VERSION; + node["uptime"] = uuid::log::format_timestamp_ms(uuid::get_uptime_ms(), 3); + node["uptimeSec"] = uuid::get_uptime_sec(); #ifndef EMSESP_STANDALONE node["platform"] = EMSESP_PLATFORM; node["arduino"] = ARDUINO_VERSION; node["sdk"] = ESP.getSdkVersion(); - node["free mem"] = getHeapMem(); - node["max alloc"] = getMaxAllocMem(); - node["free caps"] = heap_caps_get_free_size(MALLOC_CAP_8BIT) / 1024; // includes heap and psram - node["used app"] = EMSESP::system_.appUsed(); // kilobytes - node["free app"] = EMSESP::system_.appFree(); // kilobytes + node["freeMem"] = getHeapMem(); + node["maxAlloc"] = getMaxAllocMem(); + node["freeCaps"] = heap_caps_get_free_size(MALLOC_CAP_8BIT) / 1024; // includes heap and psram + node["usedApp"] = EMSESP::system_.appUsed(); // kilobytes + node["freeApp"] = EMSESP::system_.appFree(); // kilobytes node["partition"] = esp_ota_get_running_partition()->label; #endif - node["reset reason"] = EMSESP::system_.reset_reason(0) + " / " + EMSESP::system_.reset_reason(1); + node["resetReason"] = EMSESP::system_.reset_reason(0) + " / " + EMSESP::system_.reset_reason(1); // Network Status - node = output["Network"].to(); + node = output["network"].to(); #ifndef EMSESP_STANDALONE if (EMSESP::system_.ethernet_connected()) { node["network"] = "Ethernet"; @@ -1415,201 +1414,202 @@ bool System::command_info(const char * value, const int8_t id, JsonObject output if (WiFi.status() == WL_CONNECTED && !settings.bssid.isEmpty()) { node["BSSID"] = "set"; // we don't disclose the name } - node["TxPower setting"] = settings.tx_power; - node["static ip config"] = settings.staticIPConfig; - node["low bandwidth"] = settings.bandwidth20; - node["disable sleep"] = settings.nosleep; - node["enable MDNS"] = settings.enableMDNS; - node["enable CORS"] = settings.enableCORS; + node["TxPowerSetting"] = settings.tx_power; + node["staticIP"] = settings.staticIPConfig; + node["lowBandwidth"] = settings.bandwidth20; + node["disableSleep"] = settings.nosleep; + node["enableMDNS"] = settings.enableMDNS; + node["enableCORS"] = settings.enableCORS; if (settings.enableCORS) { - node["CORS origin"] = settings.CORSOrigin; + node["CORSOrigin"] = settings.CORSOrigin; } }); #ifndef EMSESP_STANDALONE EMSESP::esp8266React.getAPSettingsService()->read([&](APSettings & settings) { - const char * pM[] = {"always", "disconnected", "never"}; - node["AP provision mode"] = pM[settings.provisionMode]; - node["AP security"] = settings.password.length() ? "wpa2" : "open"; - node["AP ssid"] = settings.ssid; + const char * pM[] = {"always", "disconnected", "never"}; + node["APProvisionMode"] = pM[settings.provisionMode]; + node["APSecurity"] = settings.password.length() ? "wpa2" : "open"; + node["APSSID"] = settings.ssid; }); #endif // NTP status - node = output["NTP"].to(); + node = output["ntp"].to(); #ifndef EMSESP_STANDALONE - node["NTP status"] = EMSESP::system_.ntp_connected() ? "connected" : "disconnected"; + node["NTPStatus"] = EMSESP::system_.ntp_connected() ? "connected" : "disconnected"; EMSESP::esp8266React.getNTPSettingsService()->read([&](NTPSettings & settings) { - node["enabled"] = settings.enabled; - node["server"] = settings.server; - node["tz label"] = settings.tzLabel; + node["enabled"] = settings.enabled; + node["server"] = settings.server; + node["tzLabel"] = settings.tzLabel; // node["tz format"] = settings.tzFormat; }); #endif // MQTT Status - node = output["MQTT"].to(); - node["MQTT status"] = Mqtt::connected() ? F_(connected) : F_(disconnected); + node = output["mqtt"].to(); + node["MQTTStatus"] = Mqtt::connected() ? F_(connected) : F_(disconnected); if (Mqtt::enabled()) { - node["MQTT publishes"] = Mqtt::publish_count(); - node["MQTT queued"] = Mqtt::publish_queued(); - node["MQTT publish fails"] = Mqtt::publish_fails(); - node["MQTT connects"] = Mqtt::connect_count(); + node["MQTTPublishes"] = Mqtt::publish_count(); + node["MQTTQueued"] = Mqtt::publish_queued(); + node["MQTTPublishFails"] = Mqtt::publish_fails(); + node["MQTTConnects"] = Mqtt::connect_count(); } EMSESP::esp8266React.getMqttSettingsService()->read([&](MqttSettings & settings) { - node["enabled"] = settings.enabled; - node["client id"] = settings.clientId; - node["keep alive"] = settings.keepAlive; - node["clean session"] = settings.cleanSession; - node["entity format"] = settings.entity_format; - node["base"] = settings.base; - node["discovery prefix"] = settings.discovery_prefix; - node["discovery type"] = settings.discovery_type; - node["nested format"] = settings.nested_format; - node["ha enabled"] = settings.ha_enabled; - node["mqtt qos"] = settings.mqtt_qos; - node["mqtt retain"] = settings.mqtt_retain; - node["publish time heartbeat"] = settings.publish_time_heartbeat; - node["publish time boiler"] = settings.publish_time_boiler; - node["publish time thermostat"] = settings.publish_time_thermostat; - node["publish time solar"] = settings.publish_time_solar; - node["publish time mixer"] = settings.publish_time_mixer; - node["publish time water"] = settings.publish_time_water; - node["publish time other"] = settings.publish_time_other; - node["publish time sensor"] = settings.publish_time_sensor; - node["publish single"] = settings.publish_single; - node["publish2command"] = settings.publish_single2cmd; - node["send response"] = settings.send_response; + node["enabled"] = settings.enabled; + node["clientID"] = settings.clientId; + node["keepAlive"] = settings.keepAlive; + node["cleanSession"] = settings.cleanSession; + node["entityFormat"] = settings.entity_format; + node["base"] = settings.base; + node["discoveryPrefix"] = settings.discovery_prefix; + node["discoveryType"] = settings.discovery_type; + node["nestedFormat"] = settings.nested_format; + node["haEnabled"] = settings.ha_enabled; + node["mqttQos"] = settings.mqtt_qos; + node["mqttRetain"] = settings.mqtt_retain; + node["publishTimeHeartbeat"] = settings.publish_time_heartbeat; + node["publishTimeBoiler"] = settings.publish_time_boiler; + node["publishTimeThermostat"] = settings.publish_time_thermostat; + node["publishTimeSolar"] = settings.publish_time_solar; + node["publishTimeMixer"] = settings.publish_time_mixer; + node["publishTimeWater"] = settings.publish_time_water; + node["publishTimeOther"] = settings.publish_time_other; + node["publishTimeSensor"] = settings.publish_time_sensor; + node["publishSingle"] = settings.publish_single; + node["publish2command"] = settings.publish_single2cmd; + node["sendResponse"] = settings.send_response; }); // Syslog Status - node = output["Syslog"].to(); + node = output["syslog"].to(); node["enabled"] = EMSESP::system_.syslog_enabled_; #ifndef EMSESP_STANDALONE if (EMSESP::system_.syslog_enabled_) { - node["syslog started"] = syslog_.started(); - node["syslog level"] = FL_(list_syslog_level)[syslog_.log_level() + 1]; - node["syslog ip"] = syslog_.ip(); - node["syslog queue"] = syslog_.queued(); + node["syslogStarted"] = syslog_.started(); + node["syslogLevel"] = FL_(list_syslog_level)[syslog_.log_level() + 1]; + node["syslogIP"] = syslog_.ip(); + node["syslogQueue"] = syslog_.queued(); } #endif // Sensor Status - node = output["Sensor"].to(); + node = output["sensor"].to(); if (EMSESP::sensor_enabled()) { - node["temperature sensors"] = EMSESP::temperaturesensor_.no_sensors(); - node["temperature sensor reads"] = EMSESP::temperaturesensor_.reads(); - node["temperature sensor fails"] = EMSESP::temperaturesensor_.fails(); + node["temperatureSensors"] = EMSESP::temperaturesensor_.no_sensors(); + node["temperatureSensorReads"] = EMSESP::temperaturesensor_.reads(); + node["temperatureSensorFails"] = EMSESP::temperaturesensor_.fails(); } if (EMSESP::analog_enabled()) { - node["analog sensors"] = EMSESP::analogsensor_.no_sensors(); - node["analog sensor reads"] = EMSESP::analogsensor_.reads(); - node["analog sensor fails"] = EMSESP::analogsensor_.fails(); + node["analogSensors"] = EMSESP::analogsensor_.no_sensors(); + node["analogSensorReads"] = EMSESP::analogsensor_.reads(); + node["analogSensorFails"] = EMSESP::analogsensor_.fails(); } // API Status - node = output["API"].to(); - node["API calls"] = WebAPIService::api_count(); - node["API fails"] = WebAPIService::api_fails(); + node = output["api"].to(); + node["APICalls"] = WebAPIService::api_count(); + node["APIFails"] = WebAPIService::api_fails(); // EMS Bus Status - node = output["Bus"].to(); + node = output["bus"].to(); switch (EMSESP::bus_status()) { case EMSESP::BUS_STATUS_OFFLINE: - node["bus status"] = "disconnected"; + node["busStatus"] = "disconnected"; break; case EMSESP::BUS_STATUS_TX_ERRORS: - node["bus status"] = "connected, tx issues - try a different Tx Mode"; + node["busStatus"] = "connected, tx issues - try a different Tx Mode"; break; case EMSESP::BUS_STATUS_CONNECTED: - node["bus status"] = "connected"; + node["busStatus"] = "connected"; break; default: - node["bus status"] = "unknown"; + node["busStatus"] = "unknown"; break; } // if (EMSESP::bus_status() != EMSESP::BUS_STATUS_OFFLINE) { - node["bus protocol"] = EMSbus::is_ht3() ? "HT3" : "Buderus"; - node["bus telegrams received (rx)"] = EMSESP::rxservice_.telegram_count(); - node["bus reads (tx)"] = EMSESP::txservice_.telegram_read_count(); - node["bus writes (tx)"] = EMSESP::txservice_.telegram_write_count(); - node["bus incomplete telegrams"] = EMSESP::rxservice_.telegram_error_count(); - node["bus reads failed"] = EMSESP::txservice_.telegram_read_fail_count(); - node["bus writes failed"] = EMSESP::txservice_.telegram_write_fail_count(); - node["bus rx line quality"] = EMSESP::rxservice_.quality(); - node["bus tx line quality"] = (EMSESP::txservice_.read_quality() + EMSESP::txservice_.read_quality()) / 2; + node["busProtocol"] = EMSbus::is_ht3() ? "HT3" : "Buderus"; + node["busTelegramsReceived"] = EMSESP::rxservice_.telegram_count(); + node["busReads"] = EMSESP::txservice_.telegram_read_count(); + node["busWrites"] = EMSESP::txservice_.telegram_write_count(); + node["busIncompleteTelegrams"] = EMSESP::rxservice_.telegram_error_count(); + node["busReadsFailed"] = EMSESP::txservice_.telegram_read_fail_count(); + node["busWritesFailed"] = EMSESP::txservice_.telegram_write_fail_count(); + node["busRxLineQuality"] = EMSESP::rxservice_.quality(); + node["busTxLineQuality"] = (EMSESP::txservice_.read_quality() + EMSESP::txservice_.read_quality()) / 2; // } // Settings - node = output["Settings"].to(); + node = output["settings"].to(); EMSESP::webSettingsService.read([&](WebSettings & settings) { - node["board profile"] = settings.board_profile; - node["locale"] = settings.locale; - node["tx mode"] = settings.tx_mode; - node["ems bus id"] = settings.ems_bus_id; - node["shower timer"] = settings.shower_timer; - node["shower min duration"] = settings.shower_min_duration; // seconds - node["shower alert"] = settings.shower_alert; + node["boardProfile"] = settings.board_profile; + node["locale"] = settings.locale; + node["txMode"] = settings.tx_mode; + node["emsBusID"] = settings.ems_bus_id; + node["showerTimer"] = settings.shower_timer; + node["showerMinDuration"] = settings.shower_min_duration; // seconds + node["showerAlert"] = settings.shower_alert; if (settings.shower_alert) { - node["shower alert coldshot"] = settings.shower_alert_coldshot; // seconds - node["shower alert trigger"] = settings.shower_alert_trigger; // minutes + node["showerAlertColdshot"] = settings.shower_alert_coldshot; // seconds + node["showerAlertTrigger"] = settings.shower_alert_trigger; // minutes } if (settings.board_profile == "CUSTOM") { - node["phy type"] = settings.phy_type; + node["phyType"] = settings.phy_type; if (settings.phy_type != PHY_type::PHY_TYPE_NONE) { - node["eth power"] = settings.eth_power; - node["eth phy addr"] = settings.eth_phy_addr; - node["eth clock_mode"] = settings.eth_clock_mode; + node["ethPower"] = settings.eth_power; + node["ethPhyAddr"] = settings.eth_phy_addr; + node["ethClockMmode"] = settings.eth_clock_mode; } - node["rx gpio"] = settings.rx_gpio; - node["tx gpio"] = settings.tx_gpio; - node["dallas gpio"] = settings.dallas_gpio; - node["pbutton gpio"] = settings.pbutton_gpio; - node["led gpio"] = settings.led_gpio; + node["rxGPIO"] = settings.rx_gpio; + node["txGPIO"] = settings.tx_gpio; + node["dallasGPIO"] = settings.dallas_gpio; + node["pbuttonGPIO"] = settings.pbutton_gpio; + node["ledGPIO"] = settings.led_gpio; } - node["hide led"] = settings.hide_led; - node["notoken api"] = settings.notoken_api; - node["readonly mode"] = settings.readonly_mode; - node["fahrenheit"] = settings.fahrenheit; - node["dallas parasite"] = settings.dallas_parasite; - node["bool format"] = settings.bool_format; - node["bool dashboard"] = settings.bool_dashboard; - node["enum format"] = settings.enum_format; - node["analog enabled"] = settings.analog_enabled; - node["telnet enabled"] = settings.telnet_enabled; - node["max web log buffer"] = settings.weblog_buffer; - node["web log buffer"] = EMSESP::webLogService.num_log_messages(); + node["hideLed"] = settings.hide_led; + node["noTokenApi"] = settings.notoken_api; + node["readonlyMode"] = settings.readonly_mode; + node["fahrenheit"] = settings.fahrenheit; + node["dallasParasite"] = settings.dallas_parasite; + node["boolFormat"] = settings.bool_format; + node["boolDashboard"] = settings.bool_dashboard; + node["enumFormat"] = settings.enum_format; + node["analogEnabled"] = settings.analog_enabled; + node["telnetEnabled"] = settings.telnet_enabled; + node["maxWebLogBuffer"] = settings.weblog_buffer; + node["webLogBuffer"] = EMSESP::webLogService.num_log_messages(); + node["modbusEnabled"] = settings.modbus_enabled; }); // Devices - show EMS devices if we have any if (!EMSESP::emsdevices.empty()) { - JsonArray devices = output["Devices"].to(); + JsonArray devices = output["devices"].to(); for (const auto & device_class : EMSFactory::device_handlers()) { for (const auto & emsdevice : EMSESP::emsdevices) { if (emsdevice && (emsdevice->device_type() == device_class.first)) { - JsonObject obj = devices.add(); - obj["type"] = emsdevice->device_type_name(); // non translated name - obj["name"] = emsdevice->name(); // custom name - obj["device id"] = Helpers::hextoa(emsdevice->device_id()); - obj["product id"] = emsdevice->product_id(); - obj["brand"] = emsdevice->brand_to_char(); - obj["version"] = emsdevice->version(); - obj["entities"] = emsdevice->count_entities(); + JsonObject obj = devices.add(); + obj["type"] = emsdevice->device_type_name(); // non translated name + obj["name"] = emsdevice->name(); // custom name + obj["deviceID"] = Helpers::hextoa(emsdevice->device_id()); + obj["productID"] = emsdevice->product_id(); + obj["brand"] = emsdevice->brand_to_char(); + obj["version"] = emsdevice->version(); + obj["entities"] = emsdevice->count_entities(); char result[500]; (void)emsdevice->show_telegram_handlers(result, sizeof(result), EMSdevice::Handlers::RECEIVED); if (result[0] != '\0') { - obj["handlers received"] = result; // don't show handlers if there aren't any + obj["handlersReceived"] = result; // don't show handlers if there aren't any } (void)emsdevice->show_telegram_handlers(result, sizeof(result), EMSdevice::Handlers::FETCHED); if (result[0] != '\0') { - obj["handlers fetched"] = result; + obj["handlersFetched"] = result; } (void)emsdevice->show_telegram_handlers(result, sizeof(result), EMSdevice::Handlers::PENDING); if (result[0] != '\0') { - obj["handlers pending"] = result; + obj["handlersPending"] = result; } (void)emsdevice->show_telegram_handlers(result, sizeof(result), EMSdevice::Handlers::IGNORED); if (result[0] != '\0') { - obj["handlers ignored"] = result; + obj["handlersIgnored"] = result; } } } diff --git a/src/test/test.h b/src/test/test.h index 93fa81e01..5f672358f 100644 --- a/src/test/test.h +++ b/src/test/test.h @@ -41,7 +41,7 @@ namespace emsesp { // #define EMSESP_DEBUG_DEFAULT "310" // #define EMSESP_DEBUG_DEFAULT "render" // #define EMSESP_DEBUG_DEFAULT "api" -#define EMSESP_DEBUG_DEFAULT "api3" +// #define EMSESP_DEBUG_DEFAULT "api3" // #define EMSESP_DEBUG_DEFAULT "crash" // #define EMSESP_DEBUG_DEFAULT "dv" // #define EMSESP_DEBUG_DEFAULT "lastcode" diff --git a/src/web/WebStatusService.cpp b/src/web/WebStatusService.cpp index 63cbd1766..d306085a7 100644 --- a/src/web/WebStatusService.cpp +++ b/src/web/WebStatusService.cpp @@ -24,9 +24,9 @@ namespace emsesp { -// /rest/ESPSystemStatus +// /rest/HardwareStatus WebStatusService::WebStatusService(AsyncWebServer * server, SecurityManager * securityManager) { - server->on(ESPSYSTEM_STATUS_SERVICE_PATH, HTTP_GET, [this](AsyncWebServerRequest * request) { ESPsystemStatus(request); }); + server->on(HARDWARE_STATUS_SERVICE_PATH, HTTP_GET, [this](AsyncWebServerRequest * request) { HardwareStatus(request); }); server->on(SYSTEM_STATUS_SERVICE_PATH, HTTP_GET, [this](AsyncWebServerRequest * request) { systemStatus(request); }); } @@ -85,7 +85,7 @@ void WebStatusService::systemStatus(AsyncWebServerRequest * request) { request->send(response); } -void WebStatusService::ESPsystemStatus(AsyncWebServerRequest * request) { +void WebStatusService::HardwareStatus(AsyncWebServerRequest * request) { EMSESP::system_.refreshHeapMem(); // refresh free heap and max alloc heap auto * response = new AsyncJsonResponse(false); @@ -119,6 +119,7 @@ void WebStatusService::ESPsystemStatus(AsyncWebServerRequest * request) { uint32_t FSused = LittleFS.usedBytes() / 1024; root["fs_used"] = FSused; root["fs_free"] = EMSESP::system_.FStotal() - FSused; + root["free_caps"] = heap_caps_get_free_size(MALLOC_CAP_8BIT) / 1024; // includes heap and psram if (EMSESP::system_.PSram()) { root["psram_size"] = EMSESP::system_.PSram(); diff --git a/src/web/WebStatusService.h b/src/web/WebStatusService.h index 0099364aa..4fe30f450 100644 --- a/src/web/WebStatusService.h +++ b/src/web/WebStatusService.h @@ -1,7 +1,7 @@ #ifndef WebStatusService_h #define WebStatusService_h -#define ESPSYSTEM_STATUS_SERVICE_PATH "/rest/ESPSystemStatus" +#define HARDWARE_STATUS_SERVICE_PATH "/rest/HardwareStatus" #define SYSTEM_STATUS_SERVICE_PATH "/rest/systemStatus" namespace emsesp { @@ -12,7 +12,7 @@ class WebStatusService { private: void systemStatus(AsyncWebServerRequest * request); - void ESPsystemStatus(AsyncWebServerRequest * request); + void HardwareStatus(AsyncWebServerRequest * request); }; } // namespace emsesp