From 845681b6dc58463396b9cd114de3c5ea8fd8b474 Mon Sep 17 00:00:00 2001 From: Proddy Date: Thu, 10 Nov 2022 22:11:54 +0100 Subject: [PATCH 1/2] package update --- interface/.typesafe-i18n.json | 8 ++-- interface/package-lock.json | 76 +++++++++++++++++------------------ interface/package.json | 4 +- mock-api/package-lock.json | 14 +++---- mock-api/package.json | 2 +- 5 files changed, 52 insertions(+), 52 deletions(-) diff --git a/interface/.typesafe-i18n.json b/interface/.typesafe-i18n.json index a4bf6e3e9..4fb6ee852 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.16.2/schema/typesafe-i18n.json" -} + "adapter": "react", + "baseLocale": "pl", + "$schema": "https://unpkg.com/typesafe-i18n@5.16.3/schema/typesafe-i18n.json" +} \ No newline at end of file diff --git a/interface/package-lock.json b/interface/package-lock.json index 9abd36cf0..a2f0aa159 100644 --- a/interface/package-lock.json +++ b/interface/package-lock.json @@ -12,7 +12,7 @@ "@emotion/styled": "^11.10.5", "@msgpack/msgpack": "^2.8.0", "@mui/icons-material": "^5.10.9", - "@mui/material": "^5.10.12", + "@mui/material": "^5.10.13", "@table-library/react-table-library": "4.0.23", "@types/lodash": "^4.14.188", "@types/node": "^18.11.9", @@ -34,7 +34,7 @@ "react-router-dom": "^6.4.3", "react-scripts": "5.0.1", "sockette": "^2.0.6", - "typesafe-i18n": "^5.16.2", + "typesafe-i18n": "^5.16.3", "typescript": "^4.8.4" }, "devDependencies": { @@ -3091,9 +3091,9 @@ } }, "node_modules/@mui/base": { - "version": "5.0.0-alpha.104", - "resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-alpha.104.tgz", - "integrity": "sha512-tQPxZTzfYMwxYfKhEwufbTfdLpNjFdW7bXq6dK0j8651AAyZL4M8wynWUQ98hH1362R26mZFhVxHB2UD9t7VuA==", + "version": "5.0.0-alpha.105", + "resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-alpha.105.tgz", + "integrity": "sha512-4IPBcJQIgVVXQvN6DQMoCHed52GBtwSqYs0jD0dDcMR3o76AodQtpEeWFz3p7mJoc6f/IHBl9U6jEfL1r/kM4g==", "dependencies": { "@babel/runtime": "^7.19.0", "@emotion/is-prop-valid": "^1.2.0", @@ -3123,9 +3123,9 @@ } }, "node_modules/@mui/core-downloads-tracker": { - "version": "5.10.12", - "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.10.12.tgz", - "integrity": "sha512-cR8lOS606G++iVHR8I6ySgMAEiPoA3DxO/nLeqiv7w7d1707kvKoV4/7SWjh4ui+kHb052xlf/G196q2EKx31w==", + "version": "5.10.13", + "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.10.13.tgz", + "integrity": "sha512-zWkWPV/SaNdsIdxAWiuVGZ+Ue3BkfSIlU/BFIrJmuUcwiIa7gQsbI/DOpj1KzLvqZhdEe2wC1aG4nCHfzgc1Hg==", "funding": { "type": "opencollective", "url": "https://opencollective.com/mui" @@ -3157,14 +3157,14 @@ } }, "node_modules/@mui/material": { - "version": "5.10.12", - "resolved": "https://registry.npmjs.org/@mui/material/-/material-5.10.12.tgz", - "integrity": "sha512-rG9ZTkG9qUwujyAY1I+uQAa9pkGdsWY3KN+wvS/6H6ZbYIA06QRwmig6ySC6LbeB3WL/I/1ngwJqWX7nfINSbA==", + "version": "5.10.13", + "resolved": "https://registry.npmjs.org/@mui/material/-/material-5.10.13.tgz", + "integrity": "sha512-TkkT1rNc0/hhL4/+zv4gYcA6egNWBH/1Tz+azoTnQIUdZ32fgwFI2pFX2KVJNTt30xnLznxDWtTv7ilmJQ52xw==", "dependencies": { "@babel/runtime": "^7.19.0", - "@mui/base": "5.0.0-alpha.104", - "@mui/core-downloads-tracker": "^5.10.12", - "@mui/system": "^5.10.12", + "@mui/base": "5.0.0-alpha.105", + "@mui/core-downloads-tracker": "^5.10.13", + "@mui/system": "^5.10.13", "@mui/types": "^7.2.0", "@mui/utils": "^5.10.9", "@types/react-transition-group": "^4.4.5", @@ -3258,9 +3258,9 @@ } }, "node_modules/@mui/system": { - "version": "5.10.12", - "resolved": "https://registry.npmjs.org/@mui/system/-/system-5.10.12.tgz", - "integrity": "sha512-9DcN3hF2KTTTpZ0K5Tn20B+Tz7tIqDmJLk1M6P0CYoAGUN/xrcF/6dn1zZ829rxE5tmauoDUekTfomrvPsvlSQ==", + "version": "5.10.13", + "resolved": "https://registry.npmjs.org/@mui/system/-/system-5.10.13.tgz", + "integrity": "sha512-Xzx26Asu5fVlm0ucm+gnJmeX4Y1isrpVDvqxX4yJaOT7Fzmd8Lfq9ih3QMfZajns5LMtUiOuCQlVFRtUG5IY7A==", "dependencies": { "@babel/runtime": "^7.19.0", "@mui/private-theming": "^5.10.9", @@ -16398,9 +16398,9 @@ } }, "node_modules/typesafe-i18n": { - "version": "5.16.2", - "resolved": "https://registry.npmjs.org/typesafe-i18n/-/typesafe-i18n-5.16.2.tgz", - "integrity": "sha512-s1eVQUhq7e0nbVm5Ntb3fLmA1UNi3yEUZN0VCPGGAzVAyS2IUdtDP1J9DINGgbFmBUkHwEAZ6DPSRl9Ca1cPaA==", + "version": "5.16.3", + "resolved": "https://registry.npmjs.org/typesafe-i18n/-/typesafe-i18n-5.16.3.tgz", + "integrity": "sha512-9KxHDFzNW5vA1a4kVPEm9Jslch0H5W2IkPcJjuaqofr86U0EXkrkvF3IbPjzwnWwEf/wC900ZE7RPnePW5KYKg==", "bin": { "typesafe-i18n": "cli/typesafe-i18n.mjs" }, @@ -19614,9 +19614,9 @@ "integrity": "sha512-h9u4u/jiIRKbq25PM+zymTyW6bhTzELvOoUd+AvYriWOAKpLGnIamaET3pnHYoI5iYphAHBI4ayx0MehR+VVPQ==" }, "@mui/base": { - "version": "5.0.0-alpha.104", - "resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-alpha.104.tgz", - "integrity": "sha512-tQPxZTzfYMwxYfKhEwufbTfdLpNjFdW7bXq6dK0j8651AAyZL4M8wynWUQ98hH1362R26mZFhVxHB2UD9t7VuA==", + "version": "5.0.0-alpha.105", + "resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-alpha.105.tgz", + "integrity": "sha512-4IPBcJQIgVVXQvN6DQMoCHed52GBtwSqYs0jD0dDcMR3o76AodQtpEeWFz3p7mJoc6f/IHBl9U6jEfL1r/kM4g==", "requires": { "@babel/runtime": "^7.19.0", "@emotion/is-prop-valid": "^1.2.0", @@ -19629,9 +19629,9 @@ } }, "@mui/core-downloads-tracker": { - "version": "5.10.12", - "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.10.12.tgz", - "integrity": "sha512-cR8lOS606G++iVHR8I6ySgMAEiPoA3DxO/nLeqiv7w7d1707kvKoV4/7SWjh4ui+kHb052xlf/G196q2EKx31w==" + "version": "5.10.13", + "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.10.13.tgz", + "integrity": "sha512-zWkWPV/SaNdsIdxAWiuVGZ+Ue3BkfSIlU/BFIrJmuUcwiIa7gQsbI/DOpj1KzLvqZhdEe2wC1aG4nCHfzgc1Hg==" }, "@mui/icons-material": { "version": "5.10.9", @@ -19642,14 +19642,14 @@ } }, "@mui/material": { - "version": "5.10.12", - "resolved": "https://registry.npmjs.org/@mui/material/-/material-5.10.12.tgz", - "integrity": "sha512-rG9ZTkG9qUwujyAY1I+uQAa9pkGdsWY3KN+wvS/6H6ZbYIA06QRwmig6ySC6LbeB3WL/I/1ngwJqWX7nfINSbA==", + "version": "5.10.13", + "resolved": "https://registry.npmjs.org/@mui/material/-/material-5.10.13.tgz", + "integrity": "sha512-TkkT1rNc0/hhL4/+zv4gYcA6egNWBH/1Tz+azoTnQIUdZ32fgwFI2pFX2KVJNTt30xnLznxDWtTv7ilmJQ52xw==", "requires": { "@babel/runtime": "^7.19.0", - "@mui/base": "5.0.0-alpha.104", - "@mui/core-downloads-tracker": "^5.10.12", - "@mui/system": "^5.10.12", + "@mui/base": "5.0.0-alpha.105", + "@mui/core-downloads-tracker": "^5.10.13", + "@mui/system": "^5.10.13", "@mui/types": "^7.2.0", "@mui/utils": "^5.10.9", "@types/react-transition-group": "^4.4.5", @@ -19682,9 +19682,9 @@ } }, "@mui/system": { - "version": "5.10.12", - "resolved": "https://registry.npmjs.org/@mui/system/-/system-5.10.12.tgz", - "integrity": "sha512-9DcN3hF2KTTTpZ0K5Tn20B+Tz7tIqDmJLk1M6P0CYoAGUN/xrcF/6dn1zZ829rxE5tmauoDUekTfomrvPsvlSQ==", + "version": "5.10.13", + "resolved": "https://registry.npmjs.org/@mui/system/-/system-5.10.13.tgz", + "integrity": "sha512-Xzx26Asu5fVlm0ucm+gnJmeX4Y1isrpVDvqxX4yJaOT7Fzmd8Lfq9ih3QMfZajns5LMtUiOuCQlVFRtUG5IY7A==", "requires": { "@babel/runtime": "^7.19.0", "@mui/private-theming": "^5.10.9", @@ -29064,9 +29064,9 @@ } }, "typesafe-i18n": { - "version": "5.16.2", - "resolved": "https://registry.npmjs.org/typesafe-i18n/-/typesafe-i18n-5.16.2.tgz", - "integrity": "sha512-s1eVQUhq7e0nbVm5Ntb3fLmA1UNi3yEUZN0VCPGGAzVAyS2IUdtDP1J9DINGgbFmBUkHwEAZ6DPSRl9Ca1cPaA==", + "version": "5.16.3", + "resolved": "https://registry.npmjs.org/typesafe-i18n/-/typesafe-i18n-5.16.3.tgz", + "integrity": "sha512-9KxHDFzNW5vA1a4kVPEm9Jslch0H5W2IkPcJjuaqofr86U0EXkrkvF3IbPjzwnWwEf/wC900ZE7RPnePW5KYKg==", "requires": {} }, "typescript": { diff --git a/interface/package.json b/interface/package.json index 2e6b7353a..56ea316c8 100644 --- a/interface/package.json +++ b/interface/package.json @@ -8,7 +8,7 @@ "@emotion/styled": "^11.10.5", "@msgpack/msgpack": "^2.8.0", "@mui/icons-material": "^5.10.9", - "@mui/material": "^5.10.12", + "@mui/material": "^5.10.13", "@table-library/react-table-library": "4.0.23", "@types/lodash": "^4.14.188", "@types/node": "^18.11.9", @@ -30,7 +30,7 @@ "react-router-dom": "^6.4.3", "react-scripts": "5.0.1", "sockette": "^2.0.6", - "typesafe-i18n": "^5.16.2", + "typesafe-i18n": "^5.16.3", "typescript": "^4.8.4" }, "scripts": { diff --git a/mock-api/package-lock.json b/mock-api/package-lock.json index 42b2b5215..eec37582f 100644 --- a/mock-api/package-lock.json +++ b/mock-api/package-lock.json @@ -14,7 +14,7 @@ "express": "^4.18.2", "express-sse": "^0.5.3", "nodemon": "^2.0.20", - "ws": "^8.10.0" + "ws": "^8.11.0" } }, "node_modules/@msgpack/msgpack": { @@ -1015,9 +1015,9 @@ } }, "node_modules/ws": { - "version": "8.10.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.10.0.tgz", - "integrity": "sha512-+s49uSmZpvtAsd2h37vIPy1RBusaLawVe8of+GyEPsaJTCMpj/2v8NpeK1SHXjBlQ95lQTmQofOJnFiLoaN3yw==", + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", + "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", "engines": { "node": ">=10.0.0" }, @@ -1765,9 +1765,9 @@ "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==" }, "ws": { - "version": "8.10.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.10.0.tgz", - "integrity": "sha512-+s49uSmZpvtAsd2h37vIPy1RBusaLawVe8of+GyEPsaJTCMpj/2v8NpeK1SHXjBlQ95lQTmQofOJnFiLoaN3yw==", + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", + "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", "requires": {} } } diff --git a/mock-api/package.json b/mock-api/package.json index 22dc7589c..a20eb0454 100644 --- a/mock-api/package.json +++ b/mock-api/package.json @@ -16,6 +16,6 @@ "express": "^4.18.2", "express-sse": "^0.5.3", "nodemon": "^2.0.20", - "ws": "^8.10.0" + "ws": "^8.11.0" } } From 57775af24b542c3cbf023167c46bf43d82ecd2fd Mon Sep 17 00:00:00 2001 From: Proddy Date: Thu, 10 Nov 2022 22:12:10 +0100 Subject: [PATCH 2/2] lower case days, hours, minutes, seconds --- interface/src/i18n/en/index.ts | 8 ++--- interface/src/i18n/nl/index.ts | 8 ++--- interface/src/i18n/no/index.ts | 8 ++--- interface/src/i18n/se/index.ts | 8 ++--- lib/framework/MqttSettingsService.cpp | 1 - src/helpers.cpp | 4 +-- src/mqtt.cpp | 48 +++------------------------ src/system.cpp | 34 +++++++++++++++++++ src/system.h | 1 + src/web/WebStatusService.cpp | 4 ++- 10 files changed, 61 insertions(+), 63 deletions(-) diff --git a/interface/src/i18n/en/index.ts b/interface/src/i18n/en/index.ts index 79f5662b1..c5f8aa953 100644 --- a/interface/src/i18n/en/index.ts +++ b/interface/src/i18n/en/index.ts @@ -98,10 +98,10 @@ const en: BaseTranslation = { NUM_DEVICES: '{num} Device{{s}}', NUM_TEMP_SENSORS: '{num} Temperature Sensor{{s}}', NUM_ANALOG_SENSORS: '{num} Analog Sensor{{s}}', - NUM_DAYS: '{num} Day{{s}}', - NUM_SECONDS: '{num} Second{{s}}', - NUM_HOURS: '{num} Hour{{s}}', - NUM_MINUTES: '{num} Minute{{s}}', + NUM_DAYS: '{num} day{{s}}', + NUM_SECONDS: '{num} second{{s}}', + NUM_HOURS: '{num} hour{{s}}', + NUM_MINUTES: '{num} minute{{s}}', APPLICATION_SETTINGS: 'Application Settings', CUSTOMIZATION: 'Customization', APPLICATION_RESTARTING: 'EMS-ESP is restarting', diff --git a/interface/src/i18n/nl/index.ts b/interface/src/i18n/nl/index.ts index 84e748247..496ea4a35 100644 --- a/interface/src/i18n/nl/index.ts +++ b/interface/src/i18n/nl/index.ts @@ -98,10 +98,10 @@ const nl: Translation = { NUM_DEVICES: '{num} Apparaat{{en}}', NUM_TEMP_SENSORS: '{num} Temperatuursensor{{en}}', NUM_ANALOG_SENSORS: '{num} Analoge sensor{{en}}', - NUM_DAYS: '{num} Dag{{en}}', - NUM_SECONDS: '{num} Second{{en}}', - NUM_HOURS: '{num} Uur{{en}}', - NUM_MINUTES: '{num} Minuut{{en}}', + NUM_DAYS: '{num} dag{{en}}', + NUM_SECONDS: '{num} second{{en}}', + NUM_HOURS: '{num} uur{{en}}', + NUM_MINUTES: '{num} minuut{{en}}', APPLICATION_SETTINGS: 'Applicatieinstellingen', CUSTOMIZATION: 'Custom aanpassingen', APPLICATION_RESTARTING: 'EMS-ESP herstarten', diff --git a/interface/src/i18n/no/index.ts b/interface/src/i18n/no/index.ts index e4cd75a06..851876219 100644 --- a/interface/src/i18n/no/index.ts +++ b/interface/src/i18n/no/index.ts @@ -98,10 +98,10 @@ const no: Translation = { NUM_DEVICES: '{num} Enhet{{er}}', NUM_TEMP_SENSORS: '{num} Temperatursensor{{er}}', NUM_ANALOG_SENSORS: '{num} Analogsensor{{er}}', - NUM_DAYS: '{num} Dag{{er}}', - NUM_SECONDS: '{num} Sekund{{er}}', - NUM_HOURS: '{num} Time{{r}}', - NUM_MINUTES: '{num} Minutt{{er}}', + NUM_DAYS: '{num} sag{{er}}', + NUM_SECONDS: '{num} sekund{{er}}', + NUM_HOURS: '{num} time{{r}}', + NUM_MINUTES: '{num} minutt{{er}}', APPLICATION_SETTINGS: 'Innstillinger', CUSTOMIZATION: 'Tilpasninger', APPLICATION_RESTARTING: 'EMS-ESP restarter', diff --git a/interface/src/i18n/se/index.ts b/interface/src/i18n/se/index.ts index dd64e08ca..923c9617e 100644 --- a/interface/src/i18n/se/index.ts +++ b/interface/src/i18n/se/index.ts @@ -98,10 +98,10 @@ const se: Translation = { NUM_DEVICES: '{num} Enhet{{er}}', NUM_TEMP_SENSORS: '{num} Temperatur-sensor{{er}}', NUM_ANALOG_SENSORS: '{num} Analoga Sensor{{er}}', - NUM_DAYS: '{num} Dag{{ar}}', - NUM_SECONDS: '{num} Sekund{{er}}', - NUM_HOURS: '{num} Timmar', - NUM_MINUTES: '{num} Minut{{er}}', + NUM_DAYS: '{num} dag{{ar}}', + NUM_SECONDS: '{num} sekund{{er}}', + NUM_HOURS: '{num} timmar', + NUM_MINUTES: '{num} minut{{er}}', APPLICATION_SETTINGS: 'Inställningar', CUSTOMIZATION: 'Anpassa', APPLICATION_RESTARTING: 'EMS-ESP startar om', diff --git a/lib/framework/MqttSettingsService.cpp b/lib/framework/MqttSettingsService.cpp index 3056de814..6a2c13413 100644 --- a/lib/framework/MqttSettingsService.cpp +++ b/lib/framework/MqttSettingsService.cpp @@ -113,7 +113,6 @@ void MqttSettingsService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) { if (_state.enabled) { // emsesp::EMSESP::logger().info("Network connection dropped, stopping MQTT client"); _mqttClient.disconnect(); - // onConfigUpdated(); } break; diff --git a/src/helpers.cpp b/src/helpers.cpp index a653e371a..c2b99638d 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -260,8 +260,8 @@ char * Helpers::render_value(char * result, const float value, const int8_t form result++; } - *result++ = '.'; - int32_t decimal = abs((int32_t)((value - whole) * p[format])); + *result++ = '.'; + auto decimal = abs((int32_t)((value - whole) * p[format])); for (int8_t i = 1; i < format; i++) { if (decimal < p[i]) { *result++ = '0'; // add leading zeros diff --git a/src/mqtt.cpp b/src/mqtt.cpp index 923f603a5..a37b00f77 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -537,57 +537,18 @@ bool Mqtt::get_publish_onchange(uint8_t device_type) { } // MQTT onConnect - when an MQTT connect is established -// send out some inital MQTT messages void Mqtt::on_connect() { - if (connecting_) { // prevent duplicated connections - return; + if (connecting_) { + return; // prevent duplicated connections } LOG_INFO("MQTT connected"); connecting_ = true; - connectcount_++; + connectcount_++; // count # reconnects. not currently used. load_settings(); // reload MQTT settings - in case they have changes - // send info topic appended with the version information as JSON - StaticJsonDocument doc; - // first time to connect - if (connectcount_ == 1) { - doc["event"] = "start"; - } else { - doc["event"] = "reconnect"; - } - - doc["version"] = EMSESP_APP_VERSION; -#ifndef EMSESP_STANDALONE - if (WiFi.status() == WL_CONNECTED) { - doc["connection"] = "WiFi"; - doc["hostname"] = WiFi.getHostname(); - doc["SSID"] = WiFi.SSID(); - doc["BSSID"] = WiFi.BSSIDstr(); - doc["RSSI"] = WiFi.RSSI(); - doc["MAC"] = WiFi.macAddress(); - doc["IPv4 address"] = uuid::printable_to_string(WiFi.localIP()) + "/" + uuid::printable_to_string(WiFi.subnetMask()); - doc["IPv4 gateway"] = uuid::printable_to_string(WiFi.gatewayIP()); - doc["IPv4 nameserver"] = uuid::printable_to_string(WiFi.dnsIP()); - if (WiFi.localIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000") { - doc["IPv6 address"] = uuid::printable_to_string(WiFi.localIPv6()); - } - } else if (EMSESP::system_.ethernet_connected()) { - doc["connection"] = "Ethernet"; - doc["hostname"] = ETH.getHostname(); - doc["MAC"] = ETH.macAddress(); - doc["IPv4 address"] = uuid::printable_to_string(ETH.localIP()) + "/" + uuid::printable_to_string(ETH.subnetMask()); - doc["IPv4 gateway"] = uuid::printable_to_string(ETH.gatewayIP()); - doc["IPv4 nameserver"] = uuid::printable_to_string(ETH.dnsIP()); - if (ETH.localIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000") { - doc["IPv6 address"] = uuid::printable_to_string(ETH.localIPv6()); - } - } -#endif - publish(F_(info), doc.as()); // topic called "info" - if (ha_enabled_) { queue_unsubscribe_message(discovery_prefix_ + "/+/" + mqtt_basename_ + "/#"); EMSESP::reset_mqtt_ha(); // re-create all HA devices if there are any @@ -595,7 +556,8 @@ void Mqtt::on_connect() { ha_climate_reset(true); } else { // with disabled HA we subscribe and the broker sends all stored HA-emsesp-configs. - // In line 272 they are removed. If HA is enabled the subscriptions are removed. + // Around line 272 they are removed (search for "// remove HA topics if we don't use discover") + // If HA is enabled the subscriptions are removed. // As described in the doc (https://emsesp.github.io/docs/#/Troubleshooting?id=home-assistant): // disable HA, wait 5 minutes (to allow the broker to send all), than reenable HA again. queue_subscribe_message(discovery_prefix_ + "/+/" + mqtt_basename_ + "/#"); diff --git a/src/system.cpp b/src/system.cpp index 967c63da5..6b857b4a8 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -535,6 +535,40 @@ void System::loop() { #endif } +// send MQTT info topic appended with the version information as JSON, as a retained flag +void System::send_info_mqtt(const char * event_str) { + StaticJsonDocument doc; + doc["event"] = event_str; + doc["version"] = EMSESP_APP_VERSION; +#ifndef EMSESP_STANDALONE + if (WiFi.status() == WL_CONNECTED) { + doc["connection"] = "wifi"; + doc["hostname"] = WiFi.getHostname(); + doc["SSID"] = WiFi.SSID(); + doc["BSSID"] = WiFi.BSSIDstr(); + doc["RSSI"] = WiFi.RSSI(); + doc["MAC"] = WiFi.macAddress(); + doc["IPv4 address"] = uuid::printable_to_string(WiFi.localIP()) + "/" + uuid::printable_to_string(WiFi.subnetMask()); + doc["IPv4 gateway"] = uuid::printable_to_string(WiFi.gatewayIP()); + doc["IPv4 nameserver"] = uuid::printable_to_string(WiFi.dnsIP()); + if (WiFi.localIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000") { + doc["IPv6 address"] = uuid::printable_to_string(WiFi.localIPv6()); + } + } else if (EMSESP::system_.ethernet_connected()) { + doc["connection"] = "ethernet"; + doc["hostname"] = ETH.getHostname(); + doc["MAC"] = ETH.macAddress(); + doc["IPv4 address"] = uuid::printable_to_string(ETH.localIP()) + "/" + uuid::printable_to_string(ETH.subnetMask()); + doc["IPv4 gateway"] = uuid::printable_to_string(ETH.gatewayIP()); + doc["IPv4 nameserver"] = uuid::printable_to_string(ETH.dnsIP()); + if (ETH.localIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000") { + doc["IPv6 address"] = uuid::printable_to_string(ETH.localIPv6()); + } + } +#endif + Mqtt::publish_retain(F_(info), doc.as(), true); // topic called "info" and it's Retained +} + // create the json for heartbeat bool System::heartbeat_json(JsonObject & output) { uint8_t bus_status = EMSESP::bus_status(); diff --git a/src/system.h b/src/system.h index 156bcc3f2..3cf4106f1 100644 --- a/src/system.h +++ b/src/system.h @@ -77,6 +77,7 @@ class System { bool check_upgrade(); bool heartbeat_json(JsonObject & output); void send_heartbeat(); + void send_info_mqtt(const char * event_str); bool syslog_enabled() { return syslog_enabled_; diff --git a/src/web/WebStatusService.cpp b/src/web/WebStatusService.cpp index 97eac7156..f3bfb9003 100644 --- a/src/web/WebStatusService.cpp +++ b/src/web/WebStatusService.cpp @@ -44,6 +44,7 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) { #endif EMSESP::system_.syslog_init(); mDNS_start(); + EMSESP::system_.send_info_mqtt("connected"); break; case ARDUINO_EVENT_ETH_START: @@ -69,6 +70,7 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) { EMSESP::system_.syslog_init(); EMSESP::system_.ethernet_connected(true); mDNS_start(); + EMSESP::system_.send_info_mqtt("connected"); } break; @@ -106,9 +108,9 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) { } else { EMSESP::logger().info("WiFi connected with IPv6=%s, hostname=%s", WiFi.localIPv6().toString().c_str(), WiFi.getHostname()); } - // EMSESP::system_.send_heartbeat(); EMSESP::system_.syslog_init(); mDNS_start(); + EMSESP::system_.send_info_mqtt("connected"); break; #endif