Merge pull request #741 from proddy/dev

minor updates, also implements #707
This commit is contained in:
Proddy
2022-11-10 16:12:21 -05:00
committed by GitHub
15 changed files with 113 additions and 115 deletions

View File

@@ -1,5 +1,5 @@
{ {
"adapter": "react", "adapter": "react",
"baseLocale": "pl", "baseLocale": "pl",
"$schema": "https://unpkg.com/typesafe-i18n@5.16.2/schema/typesafe-i18n.json" "$schema": "https://unpkg.com/typesafe-i18n@5.16.3/schema/typesafe-i18n.json"
} }

View File

@@ -12,7 +12,7 @@
"@emotion/styled": "^11.10.5", "@emotion/styled": "^11.10.5",
"@msgpack/msgpack": "^2.8.0", "@msgpack/msgpack": "^2.8.0",
"@mui/icons-material": "^5.10.9", "@mui/icons-material": "^5.10.9",
"@mui/material": "^5.10.12", "@mui/material": "^5.10.13",
"@table-library/react-table-library": "4.0.23", "@table-library/react-table-library": "4.0.23",
"@types/lodash": "^4.14.188", "@types/lodash": "^4.14.188",
"@types/node": "^18.11.9", "@types/node": "^18.11.9",
@@ -34,7 +34,7 @@
"react-router-dom": "^6.4.3", "react-router-dom": "^6.4.3",
"react-scripts": "5.0.1", "react-scripts": "5.0.1",
"sockette": "^2.0.6", "sockette": "^2.0.6",
"typesafe-i18n": "^5.16.2", "typesafe-i18n": "^5.16.3",
"typescript": "^4.8.4" "typescript": "^4.8.4"
}, },
"devDependencies": { "devDependencies": {
@@ -3091,9 +3091,9 @@
} }
}, },
"node_modules/@mui/base": { "node_modules/@mui/base": {
"version": "5.0.0-alpha.104", "version": "5.0.0-alpha.105",
"resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-alpha.104.tgz", "resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-alpha.105.tgz",
"integrity": "sha512-tQPxZTzfYMwxYfKhEwufbTfdLpNjFdW7bXq6dK0j8651AAyZL4M8wynWUQ98hH1362R26mZFhVxHB2UD9t7VuA==", "integrity": "sha512-4IPBcJQIgVVXQvN6DQMoCHed52GBtwSqYs0jD0dDcMR3o76AodQtpEeWFz3p7mJoc6f/IHBl9U6jEfL1r/kM4g==",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.19.0", "@babel/runtime": "^7.19.0",
"@emotion/is-prop-valid": "^1.2.0", "@emotion/is-prop-valid": "^1.2.0",
@@ -3123,9 +3123,9 @@
} }
}, },
"node_modules/@mui/core-downloads-tracker": { "node_modules/@mui/core-downloads-tracker": {
"version": "5.10.12", "version": "5.10.13",
"resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.10.12.tgz", "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.10.13.tgz",
"integrity": "sha512-cR8lOS606G++iVHR8I6ySgMAEiPoA3DxO/nLeqiv7w7d1707kvKoV4/7SWjh4ui+kHb052xlf/G196q2EKx31w==", "integrity": "sha512-zWkWPV/SaNdsIdxAWiuVGZ+Ue3BkfSIlU/BFIrJmuUcwiIa7gQsbI/DOpj1KzLvqZhdEe2wC1aG4nCHfzgc1Hg==",
"funding": { "funding": {
"type": "opencollective", "type": "opencollective",
"url": "https://opencollective.com/mui" "url": "https://opencollective.com/mui"
@@ -3157,14 +3157,14 @@
} }
}, },
"node_modules/@mui/material": { "node_modules/@mui/material": {
"version": "5.10.12", "version": "5.10.13",
"resolved": "https://registry.npmjs.org/@mui/material/-/material-5.10.12.tgz", "resolved": "https://registry.npmjs.org/@mui/material/-/material-5.10.13.tgz",
"integrity": "sha512-rG9ZTkG9qUwujyAY1I+uQAa9pkGdsWY3KN+wvS/6H6ZbYIA06QRwmig6ySC6LbeB3WL/I/1ngwJqWX7nfINSbA==", "integrity": "sha512-TkkT1rNc0/hhL4/+zv4gYcA6egNWBH/1Tz+azoTnQIUdZ32fgwFI2pFX2KVJNTt30xnLznxDWtTv7ilmJQ52xw==",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.19.0", "@babel/runtime": "^7.19.0",
"@mui/base": "5.0.0-alpha.104", "@mui/base": "5.0.0-alpha.105",
"@mui/core-downloads-tracker": "^5.10.12", "@mui/core-downloads-tracker": "^5.10.13",
"@mui/system": "^5.10.12", "@mui/system": "^5.10.13",
"@mui/types": "^7.2.0", "@mui/types": "^7.2.0",
"@mui/utils": "^5.10.9", "@mui/utils": "^5.10.9",
"@types/react-transition-group": "^4.4.5", "@types/react-transition-group": "^4.4.5",
@@ -3258,9 +3258,9 @@
} }
}, },
"node_modules/@mui/system": { "node_modules/@mui/system": {
"version": "5.10.12", "version": "5.10.13",
"resolved": "https://registry.npmjs.org/@mui/system/-/system-5.10.12.tgz", "resolved": "https://registry.npmjs.org/@mui/system/-/system-5.10.13.tgz",
"integrity": "sha512-9DcN3hF2KTTTpZ0K5Tn20B+Tz7tIqDmJLk1M6P0CYoAGUN/xrcF/6dn1zZ829rxE5tmauoDUekTfomrvPsvlSQ==", "integrity": "sha512-Xzx26Asu5fVlm0ucm+gnJmeX4Y1isrpVDvqxX4yJaOT7Fzmd8Lfq9ih3QMfZajns5LMtUiOuCQlVFRtUG5IY7A==",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.19.0", "@babel/runtime": "^7.19.0",
"@mui/private-theming": "^5.10.9", "@mui/private-theming": "^5.10.9",
@@ -16398,9 +16398,9 @@
} }
}, },
"node_modules/typesafe-i18n": { "node_modules/typesafe-i18n": {
"version": "5.16.2", "version": "5.16.3",
"resolved": "https://registry.npmjs.org/typesafe-i18n/-/typesafe-i18n-5.16.2.tgz", "resolved": "https://registry.npmjs.org/typesafe-i18n/-/typesafe-i18n-5.16.3.tgz",
"integrity": "sha512-s1eVQUhq7e0nbVm5Ntb3fLmA1UNi3yEUZN0VCPGGAzVAyS2IUdtDP1J9DINGgbFmBUkHwEAZ6DPSRl9Ca1cPaA==", "integrity": "sha512-9KxHDFzNW5vA1a4kVPEm9Jslch0H5W2IkPcJjuaqofr86U0EXkrkvF3IbPjzwnWwEf/wC900ZE7RPnePW5KYKg==",
"bin": { "bin": {
"typesafe-i18n": "cli/typesafe-i18n.mjs" "typesafe-i18n": "cli/typesafe-i18n.mjs"
}, },
@@ -19614,9 +19614,9 @@
"integrity": "sha512-h9u4u/jiIRKbq25PM+zymTyW6bhTzELvOoUd+AvYriWOAKpLGnIamaET3pnHYoI5iYphAHBI4ayx0MehR+VVPQ==" "integrity": "sha512-h9u4u/jiIRKbq25PM+zymTyW6bhTzELvOoUd+AvYriWOAKpLGnIamaET3pnHYoI5iYphAHBI4ayx0MehR+VVPQ=="
}, },
"@mui/base": { "@mui/base": {
"version": "5.0.0-alpha.104", "version": "5.0.0-alpha.105",
"resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-alpha.104.tgz", "resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-alpha.105.tgz",
"integrity": "sha512-tQPxZTzfYMwxYfKhEwufbTfdLpNjFdW7bXq6dK0j8651AAyZL4M8wynWUQ98hH1362R26mZFhVxHB2UD9t7VuA==", "integrity": "sha512-4IPBcJQIgVVXQvN6DQMoCHed52GBtwSqYs0jD0dDcMR3o76AodQtpEeWFz3p7mJoc6f/IHBl9U6jEfL1r/kM4g==",
"requires": { "requires": {
"@babel/runtime": "^7.19.0", "@babel/runtime": "^7.19.0",
"@emotion/is-prop-valid": "^1.2.0", "@emotion/is-prop-valid": "^1.2.0",
@@ -19629,9 +19629,9 @@
} }
}, },
"@mui/core-downloads-tracker": { "@mui/core-downloads-tracker": {
"version": "5.10.12", "version": "5.10.13",
"resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.10.12.tgz", "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.10.13.tgz",
"integrity": "sha512-cR8lOS606G++iVHR8I6ySgMAEiPoA3DxO/nLeqiv7w7d1707kvKoV4/7SWjh4ui+kHb052xlf/G196q2EKx31w==" "integrity": "sha512-zWkWPV/SaNdsIdxAWiuVGZ+Ue3BkfSIlU/BFIrJmuUcwiIa7gQsbI/DOpj1KzLvqZhdEe2wC1aG4nCHfzgc1Hg=="
}, },
"@mui/icons-material": { "@mui/icons-material": {
"version": "5.10.9", "version": "5.10.9",
@@ -19642,14 +19642,14 @@
} }
}, },
"@mui/material": { "@mui/material": {
"version": "5.10.12", "version": "5.10.13",
"resolved": "https://registry.npmjs.org/@mui/material/-/material-5.10.12.tgz", "resolved": "https://registry.npmjs.org/@mui/material/-/material-5.10.13.tgz",
"integrity": "sha512-rG9ZTkG9qUwujyAY1I+uQAa9pkGdsWY3KN+wvS/6H6ZbYIA06QRwmig6ySC6LbeB3WL/I/1ngwJqWX7nfINSbA==", "integrity": "sha512-TkkT1rNc0/hhL4/+zv4gYcA6egNWBH/1Tz+azoTnQIUdZ32fgwFI2pFX2KVJNTt30xnLznxDWtTv7ilmJQ52xw==",
"requires": { "requires": {
"@babel/runtime": "^7.19.0", "@babel/runtime": "^7.19.0",
"@mui/base": "5.0.0-alpha.104", "@mui/base": "5.0.0-alpha.105",
"@mui/core-downloads-tracker": "^5.10.12", "@mui/core-downloads-tracker": "^5.10.13",
"@mui/system": "^5.10.12", "@mui/system": "^5.10.13",
"@mui/types": "^7.2.0", "@mui/types": "^7.2.0",
"@mui/utils": "^5.10.9", "@mui/utils": "^5.10.9",
"@types/react-transition-group": "^4.4.5", "@types/react-transition-group": "^4.4.5",
@@ -19682,9 +19682,9 @@
} }
}, },
"@mui/system": { "@mui/system": {
"version": "5.10.12", "version": "5.10.13",
"resolved": "https://registry.npmjs.org/@mui/system/-/system-5.10.12.tgz", "resolved": "https://registry.npmjs.org/@mui/system/-/system-5.10.13.tgz",
"integrity": "sha512-9DcN3hF2KTTTpZ0K5Tn20B+Tz7tIqDmJLk1M6P0CYoAGUN/xrcF/6dn1zZ829rxE5tmauoDUekTfomrvPsvlSQ==", "integrity": "sha512-Xzx26Asu5fVlm0ucm+gnJmeX4Y1isrpVDvqxX4yJaOT7Fzmd8Lfq9ih3QMfZajns5LMtUiOuCQlVFRtUG5IY7A==",
"requires": { "requires": {
"@babel/runtime": "^7.19.0", "@babel/runtime": "^7.19.0",
"@mui/private-theming": "^5.10.9", "@mui/private-theming": "^5.10.9",
@@ -29064,9 +29064,9 @@
} }
}, },
"typesafe-i18n": { "typesafe-i18n": {
"version": "5.16.2", "version": "5.16.3",
"resolved": "https://registry.npmjs.org/typesafe-i18n/-/typesafe-i18n-5.16.2.tgz", "resolved": "https://registry.npmjs.org/typesafe-i18n/-/typesafe-i18n-5.16.3.tgz",
"integrity": "sha512-s1eVQUhq7e0nbVm5Ntb3fLmA1UNi3yEUZN0VCPGGAzVAyS2IUdtDP1J9DINGgbFmBUkHwEAZ6DPSRl9Ca1cPaA==", "integrity": "sha512-9KxHDFzNW5vA1a4kVPEm9Jslch0H5W2IkPcJjuaqofr86U0EXkrkvF3IbPjzwnWwEf/wC900ZE7RPnePW5KYKg==",
"requires": {} "requires": {}
}, },
"typescript": { "typescript": {

View File

@@ -8,7 +8,7 @@
"@emotion/styled": "^11.10.5", "@emotion/styled": "^11.10.5",
"@msgpack/msgpack": "^2.8.0", "@msgpack/msgpack": "^2.8.0",
"@mui/icons-material": "^5.10.9", "@mui/icons-material": "^5.10.9",
"@mui/material": "^5.10.12", "@mui/material": "^5.10.13",
"@table-library/react-table-library": "4.0.23", "@table-library/react-table-library": "4.0.23",
"@types/lodash": "^4.14.188", "@types/lodash": "^4.14.188",
"@types/node": "^18.11.9", "@types/node": "^18.11.9",
@@ -30,7 +30,7 @@
"react-router-dom": "^6.4.3", "react-router-dom": "^6.4.3",
"react-scripts": "5.0.1", "react-scripts": "5.0.1",
"sockette": "^2.0.6", "sockette": "^2.0.6",
"typesafe-i18n": "^5.16.2", "typesafe-i18n": "^5.16.3",
"typescript": "^4.8.4" "typescript": "^4.8.4"
}, },
"scripts": { "scripts": {

View File

@@ -98,10 +98,10 @@ const en: BaseTranslation = {
NUM_DEVICES: '{num} Device{{s}}', NUM_DEVICES: '{num} Device{{s}}',
NUM_TEMP_SENSORS: '{num} Temperature Sensor{{s}}', NUM_TEMP_SENSORS: '{num} Temperature Sensor{{s}}',
NUM_ANALOG_SENSORS: '{num} Analog Sensor{{s}}', NUM_ANALOG_SENSORS: '{num} Analog Sensor{{s}}',
NUM_DAYS: '{num} Day{{s}}', NUM_DAYS: '{num} day{{s}}',
NUM_SECONDS: '{num} Second{{s}}', NUM_SECONDS: '{num} second{{s}}',
NUM_HOURS: '{num} Hour{{s}}', NUM_HOURS: '{num} hour{{s}}',
NUM_MINUTES: '{num} Minute{{s}}', NUM_MINUTES: '{num} minute{{s}}',
APPLICATION_SETTINGS: 'Application Settings', APPLICATION_SETTINGS: 'Application Settings',
CUSTOMIZATION: 'Customization', CUSTOMIZATION: 'Customization',
APPLICATION_RESTARTING: 'EMS-ESP is restarting', APPLICATION_RESTARTING: 'EMS-ESP is restarting',

View File

@@ -98,10 +98,10 @@ const nl: Translation = {
NUM_DEVICES: '{num} Apparaat{{en}}', NUM_DEVICES: '{num} Apparaat{{en}}',
NUM_TEMP_SENSORS: '{num} Temperatuursensor{{en}}', NUM_TEMP_SENSORS: '{num} Temperatuursensor{{en}}',
NUM_ANALOG_SENSORS: '{num} Analoge sensor{{en}}', NUM_ANALOG_SENSORS: '{num} Analoge sensor{{en}}',
NUM_DAYS: '{num} Dag{{en}}', NUM_DAYS: '{num} dag{{en}}',
NUM_SECONDS: '{num} Second{{en}}', NUM_SECONDS: '{num} second{{en}}',
NUM_HOURS: '{num} Uur{{en}}', NUM_HOURS: '{num} uur{{en}}',
NUM_MINUTES: '{num} Minuut{{en}}', NUM_MINUTES: '{num} minuut{{en}}',
APPLICATION_SETTINGS: 'Applicatieinstellingen', APPLICATION_SETTINGS: 'Applicatieinstellingen',
CUSTOMIZATION: 'Custom aanpassingen', CUSTOMIZATION: 'Custom aanpassingen',
APPLICATION_RESTARTING: 'EMS-ESP herstarten', APPLICATION_RESTARTING: 'EMS-ESP herstarten',

View File

@@ -98,10 +98,10 @@ const no: Translation = {
NUM_DEVICES: '{num} Enhet{{er}}', NUM_DEVICES: '{num} Enhet{{er}}',
NUM_TEMP_SENSORS: '{num} Temperatursensor{{er}}', NUM_TEMP_SENSORS: '{num} Temperatursensor{{er}}',
NUM_ANALOG_SENSORS: '{num} Analogsensor{{er}}', NUM_ANALOG_SENSORS: '{num} Analogsensor{{er}}',
NUM_DAYS: '{num} Dag{{er}}', NUM_DAYS: '{num} sag{{er}}',
NUM_SECONDS: '{num} Sekund{{er}}', NUM_SECONDS: '{num} sekund{{er}}',
NUM_HOURS: '{num} Time{{r}}', NUM_HOURS: '{num} time{{r}}',
NUM_MINUTES: '{num} Minutt{{er}}', NUM_MINUTES: '{num} minutt{{er}}',
APPLICATION_SETTINGS: 'Innstillinger', APPLICATION_SETTINGS: 'Innstillinger',
CUSTOMIZATION: 'Tilpasninger', CUSTOMIZATION: 'Tilpasninger',
APPLICATION_RESTARTING: 'EMS-ESP restarter', APPLICATION_RESTARTING: 'EMS-ESP restarter',

View File

@@ -98,10 +98,10 @@ const se: Translation = {
NUM_DEVICES: '{num} Enhet{{er}}', NUM_DEVICES: '{num} Enhet{{er}}',
NUM_TEMP_SENSORS: '{num} Temperatur-sensor{{er}}', NUM_TEMP_SENSORS: '{num} Temperatur-sensor{{er}}',
NUM_ANALOG_SENSORS: '{num} Analoga Sensor{{er}}', NUM_ANALOG_SENSORS: '{num} Analoga Sensor{{er}}',
NUM_DAYS: '{num} Dag{{ar}}', NUM_DAYS: '{num} dag{{ar}}',
NUM_SECONDS: '{num} Sekund{{er}}', NUM_SECONDS: '{num} sekund{{er}}',
NUM_HOURS: '{num} Timmar', NUM_HOURS: '{num} timmar',
NUM_MINUTES: '{num} Minut{{er}}', NUM_MINUTES: '{num} minut{{er}}',
APPLICATION_SETTINGS: 'Inställningar', APPLICATION_SETTINGS: 'Inställningar',
CUSTOMIZATION: 'Anpassa', CUSTOMIZATION: 'Anpassa',
APPLICATION_RESTARTING: 'EMS-ESP startar om', APPLICATION_RESTARTING: 'EMS-ESP startar om',

View File

@@ -113,7 +113,6 @@ void MqttSettingsService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
if (_state.enabled) { if (_state.enabled) {
// emsesp::EMSESP::logger().info("Network connection dropped, stopping MQTT client"); // emsesp::EMSESP::logger().info("Network connection dropped, stopping MQTT client");
_mqttClient.disconnect(); _mqttClient.disconnect();
// onConfigUpdated();
} }
break; break;

View File

@@ -14,7 +14,7 @@
"express": "^4.18.2", "express": "^4.18.2",
"express-sse": "^0.5.3", "express-sse": "^0.5.3",
"nodemon": "^2.0.20", "nodemon": "^2.0.20",
"ws": "^8.10.0" "ws": "^8.11.0"
} }
}, },
"node_modules/@msgpack/msgpack": { "node_modules/@msgpack/msgpack": {
@@ -1015,9 +1015,9 @@
} }
}, },
"node_modules/ws": { "node_modules/ws": {
"version": "8.10.0", "version": "8.11.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.10.0.tgz", "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz",
"integrity": "sha512-+s49uSmZpvtAsd2h37vIPy1RBusaLawVe8of+GyEPsaJTCMpj/2v8NpeK1SHXjBlQ95lQTmQofOJnFiLoaN3yw==", "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==",
"engines": { "engines": {
"node": ">=10.0.0" "node": ">=10.0.0"
}, },
@@ -1765,9 +1765,9 @@
"integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==" "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg=="
}, },
"ws": { "ws": {
"version": "8.10.0", "version": "8.11.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.10.0.tgz", "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz",
"integrity": "sha512-+s49uSmZpvtAsd2h37vIPy1RBusaLawVe8of+GyEPsaJTCMpj/2v8NpeK1SHXjBlQ95lQTmQofOJnFiLoaN3yw==", "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==",
"requires": {} "requires": {}
} }
} }

View File

@@ -16,6 +16,6 @@
"express": "^4.18.2", "express": "^4.18.2",
"express-sse": "^0.5.3", "express-sse": "^0.5.3",
"nodemon": "^2.0.20", "nodemon": "^2.0.20",
"ws": "^8.10.0" "ws": "^8.11.0"
} }
} }

View File

@@ -261,7 +261,7 @@ 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])); auto decimal = abs((int32_t)((value - whole) * p[format]));
for (int8_t i = 1; i < format; i++) { for (int8_t i = 1; i < format; i++) {
if (decimal < p[i]) { if (decimal < p[i]) {
*result++ = '0'; // add leading zeros *result++ = '0'; // add leading zeros

View File

@@ -537,57 +537,18 @@ bool Mqtt::get_publish_onchange(uint8_t device_type) {
} }
// MQTT onConnect - when an MQTT connect is established // MQTT onConnect - when an MQTT connect is established
// send out some inital MQTT messages
void Mqtt::on_connect() { void Mqtt::on_connect() {
if (connecting_) { // prevent duplicated connections if (connecting_) {
return; return; // prevent duplicated connections
} }
LOG_INFO("MQTT connected"); LOG_INFO("MQTT connected");
connecting_ = true; connecting_ = true;
connectcount_++; connectcount_++; // count # reconnects. not currently used.
load_settings(); // reload MQTT settings - in case they have changes load_settings(); // reload MQTT settings - in case they have changes
// send info topic appended with the version information as JSON
StaticJsonDocument<EMSESP_JSON_SIZE_MEDIUM> 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<JsonObject>()); // topic called "info"
if (ha_enabled_) { if (ha_enabled_) {
queue_unsubscribe_message(discovery_prefix_ + "/+/" + mqtt_basename_ + "/#"); queue_unsubscribe_message(discovery_prefix_ + "/+/" + mqtt_basename_ + "/#");
EMSESP::reset_mqtt_ha(); // re-create all HA devices if there are any 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); ha_climate_reset(true);
} else { } else {
// with disabled HA we subscribe and the broker sends all stored HA-emsesp-configs. // 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): // 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. // disable HA, wait 5 minutes (to allow the broker to send all), than reenable HA again.
queue_subscribe_message(discovery_prefix_ + "/+/" + mqtt_basename_ + "/#"); queue_subscribe_message(discovery_prefix_ + "/+/" + mqtt_basename_ + "/#");

View File

@@ -535,6 +535,40 @@ void System::loop() {
#endif #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<EMSESP_JSON_SIZE_MEDIUM> 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<JsonObject>(), true); // topic called "info" and it's Retained
}
// create the json for heartbeat // create the json for heartbeat
bool System::heartbeat_json(JsonObject & output) { bool System::heartbeat_json(JsonObject & output) {
uint8_t bus_status = EMSESP::bus_status(); uint8_t bus_status = EMSESP::bus_status();

View File

@@ -77,6 +77,7 @@ class System {
bool check_upgrade(); bool check_upgrade();
bool heartbeat_json(JsonObject & output); bool heartbeat_json(JsonObject & output);
void send_heartbeat(); void send_heartbeat();
void send_info_mqtt(const char * event_str);
bool syslog_enabled() { bool syslog_enabled() {
return syslog_enabled_; return syslog_enabled_;

View File

@@ -44,6 +44,7 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
#endif #endif
EMSESP::system_.syslog_init(); EMSESP::system_.syslog_init();
mDNS_start(); mDNS_start();
EMSESP::system_.send_info_mqtt("connected");
break; break;
case ARDUINO_EVENT_ETH_START: case ARDUINO_EVENT_ETH_START:
@@ -69,6 +70,7 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
EMSESP::system_.syslog_init(); EMSESP::system_.syslog_init();
EMSESP::system_.ethernet_connected(true); EMSESP::system_.ethernet_connected(true);
mDNS_start(); mDNS_start();
EMSESP::system_.send_info_mqtt("connected");
} }
break; break;
@@ -106,9 +108,9 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
} else { } else {
EMSESP::logger().info("WiFi connected with IPv6=%s, hostname=%s", WiFi.localIPv6().toString().c_str(), WiFi.getHostname()); 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(); EMSESP::system_.syslog_init();
mDNS_start(); mDNS_start();
EMSESP::system_.send_info_mqtt("connected");
break; break;
#endif #endif