From 3c91ac27dc6d3cf6a9781123db4568f5dd014c75 Mon Sep 17 00:00:00 2001 From: Proddy Date: Fri, 23 Dec 2022 13:42:59 +0100 Subject: [PATCH 1/5] Set device_class to duration in HA sensor definitions #822 --- CHANGELOG_LATEST.md | 3 +- interface/.typesafe-i18n.json | 8 +- interface/package-lock.json | 184 +++++++++++++++++----------------- interface/package.json | 8 +- src/emsdevicevalue.h | 30 +++--- src/locale_common.h | 6 +- src/mqtt.cpp | 24 +++-- 7 files changed, 133 insertions(+), 130 deletions(-) diff --git a/CHANGELOG_LATEST.md b/CHANGELOG_LATEST.md index 52eb1dab4..d7186d8a0 100644 --- a/CHANGELOG_LATEST.md +++ b/CHANGELOG_LATEST.md @@ -40,4 +40,5 @@ - reload page after restart button is pressed - analog/dallas values command as list like ems-devices - analog/dallas HA-entities based on id -- MQTT Base is a mandatory field. Removed MQTT topic length from settings. +- MQTT Base is a mandatory field. Removed MQTT topic length from settings +- HA duration class for time entities [[#822](https://github.com/emsesp/EMS-ESP32/issues/822 diff --git a/interface/.typesafe-i18n.json b/interface/.typesafe-i18n.json index e53e4b991..ec7e7c401 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.17.2/schema/typesafe-i18n.json" -} + "adapter": "react", + "baseLocale": "pl", + "$schema": "https://unpkg.com/typesafe-i18n@5.18.0/schema/typesafe-i18n.json" +} \ No newline at end of file diff --git a/interface/package-lock.json b/interface/package-lock.json index 585bbc16c..f43be3cb6 100644 --- a/interface/package-lock.json +++ b/interface/package-lock.json @@ -12,12 +12,12 @@ "@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", "@types/react": "^18.0.26", - "@types/react-dom": "^18.0.9", + "@types/react-dom": "^18.0.10", "@types/react-router-dom": "^5.3.3", "async-validator": "^4.2.5", "axios": "^1.2.1", @@ -31,10 +31,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" }, "devDependencies": { @@ -3091,14 +3091,14 @@ } }, "node_modules/@mui/base": { - "version": "5.0.0-alpha.110", - "resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-alpha.110.tgz", - "integrity": "sha512-q4TH9T3sTBknTXXTEf2zO8F3nbHg5iGgiaRx9XErTbXvHrmLrQXbQ4hmrLERocSTBFCFWkKyne/qZj0diWlPtA==", + "version": "5.0.0-alpha.111", + "resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-alpha.111.tgz", + "integrity": "sha512-2wfIPpl97S4dPzD0QOM3UIzQ/EuXCYQvHmXxTpfKxev/cfkzOe7Ik/McoYUBbtM1bSOqH3W276R/L2LF9cyXqQ==", "dependencies": { "@babel/runtime": "^7.20.6", "@emotion/is-prop-valid": "^1.2.0", "@mui/types": "^7.2.3", - "@mui/utils": "^5.11.0", + "@mui/utils": "^5.11.1", "@popperjs/core": "^2.11.6", "clsx": "^1.2.1", "prop-types": "^15.8.1", @@ -3123,9 +3123,9 @@ } }, "node_modules/@mui/core-downloads-tracker": { - "version": "5.11.0", - "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.11.0.tgz", - "integrity": "sha512-Bmogung451ezVv2YI1RvweOIVsTj2RQ4Fk61+e/+8LFPLTFEwVGbL0YhNy1VB5tri8pzGNV228kxtWVTFooQkg==", + "version": "5.11.1", + "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.11.1.tgz", + "integrity": "sha512-QVqVNlZ2K+LqUDE5kFgYd0r4KekR/dv2cNYbAutQWbfOA8VPVUVrDz0ELrEcoe8TjM/CwnsmGvaDh/YSNl/ALA==", "funding": { "type": "opencollective", "url": "https://opencollective.com/mui" @@ -3157,16 +3157,16 @@ } }, "node_modules/@mui/material": { - "version": "5.11.0", - "resolved": "https://registry.npmjs.org/@mui/material/-/material-5.11.0.tgz", - "integrity": "sha512-8Zl34lb89rLKTTi50Kakki675/LLHMKKnkp8Ee3rAZ2qmisQlRODsGh1MBjENKp0vwhQnNSvlsCfJteVTfotPQ==", + "version": "5.11.1", + "resolved": "https://registry.npmjs.org/@mui/material/-/material-5.11.1.tgz", + "integrity": "sha512-yaZiXvcrl2vgUK+VO24780BWRgwdAMmAyuMVZnRTts1Yu0tWd6PjIYq2ZtaOlpj6/LbaSS+Q2kSfxYnDQ20CEQ==", "dependencies": { "@babel/runtime": "^7.20.6", - "@mui/base": "5.0.0-alpha.110", - "@mui/core-downloads-tracker": "^5.11.0", - "@mui/system": "^5.11.0", + "@mui/base": "5.0.0-alpha.111", + "@mui/core-downloads-tracker": "^5.11.1", + "@mui/system": "^5.11.1", "@mui/types": "^7.2.3", - "@mui/utils": "^5.11.0", + "@mui/utils": "^5.11.1", "@types/react-transition-group": "^4.4.5", "clsx": "^1.2.1", "csstype": "^3.1.1", @@ -3201,12 +3201,12 @@ } }, "node_modules/@mui/private-theming": { - "version": "5.11.0", - "resolved": "https://registry.npmjs.org/@mui/private-theming/-/private-theming-5.11.0.tgz", - "integrity": "sha512-UFQLb9x5Sj4pg2GhhCGw3Ls/y1Hw/tz9RsBrULvUF0Vgps1z19o7XTq2xqUvp7pN7fJTW7eVIT2gwVg2xlk8PQ==", + "version": "5.11.1", + "resolved": "https://registry.npmjs.org/@mui/private-theming/-/private-theming-5.11.1.tgz", + "integrity": "sha512-nnHg7kA5RwFRhy0wiDYe59sLCVGORpPypL1JcEdhv0+N0Zbmc2E/y4z2zqMRZ62MAEscpro7cQbvv244ThA84A==", "dependencies": { "@babel/runtime": "^7.20.6", - "@mui/utils": "^5.11.0", + "@mui/utils": "^5.11.1", "prop-types": "^15.8.1" }, "engines": { @@ -3258,15 +3258,15 @@ } }, "node_modules/@mui/system": { - "version": "5.11.0", - "resolved": "https://registry.npmjs.org/@mui/system/-/system-5.11.0.tgz", - "integrity": "sha512-HFUT7Dlmyq6Wfuxsw8QBXZxXDYIQQaJ4YHaZd7s+nDMcjerLnILxjh2g3a6umtOUM+jEcRaFJAtvLZvlGfa5fw==", + "version": "5.11.1", + "resolved": "https://registry.npmjs.org/@mui/system/-/system-5.11.1.tgz", + "integrity": "sha512-BEA2S0hay8n8CcZftkeAVsi0nsb5ZjdnZRCahv5lX7QJYwDjO4ucJ6lnvxHe2v/9Te1LLjTO7ojxu/qM6CE5Cg==", "dependencies": { "@babel/runtime": "^7.20.6", - "@mui/private-theming": "^5.11.0", + "@mui/private-theming": "^5.11.1", "@mui/styled-engine": "^5.11.0", "@mui/types": "^7.2.3", - "@mui/utils": "^5.11.0", + "@mui/utils": "^5.11.1", "clsx": "^1.2.1", "csstype": "^3.1.1", "prop-types": "^15.8.1" @@ -3310,9 +3310,9 @@ } }, "node_modules/@mui/utils": { - "version": "5.11.0", - "resolved": "https://registry.npmjs.org/@mui/utils/-/utils-5.11.0.tgz", - "integrity": "sha512-DP/YDaVVCVzJpZ5FFPLKNmaJkeaYRviTyIZkL/D5/FmPXQiA6ecd6z0/+VwoNQtp7aXAQWaRhvz4FM25yqFlHA==", + "version": "5.11.1", + "resolved": "https://registry.npmjs.org/@mui/utils/-/utils-5.11.1.tgz", + "integrity": "sha512-lMAPgIJoil8V9ZxsMbEflMsvZmWcHbRVMc4JDY9jPO9V4welpF43h/O267b1RqlcRnC5MEbVQV605GYkTZY29Q==", "dependencies": { "@babel/runtime": "^7.20.6", "@types/prop-types": "^15.7.5", @@ -3458,9 +3458,9 @@ } }, "node_modules/@remix-run/router": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.1.0.tgz", - "integrity": "sha512-rGl+jH/7x1KBCQScz9p54p0dtPLNeKGb3e0wD2H5/oZj41bwQUnXdzbj2TbUAFhvD7cp9EyEQA4dEgpUFa1O7Q==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.2.0.tgz", + "integrity": "sha512-GO82KYYTWPRCgdNtnheaZG3LcViUlxRFlHM7ykh7N+ufoXi6PVIHoP+9RUG/vuzl2hr9i/h6EA1Eq+2HpqJ0gQ==", "engines": { "node": ">=14" } @@ -4062,9 +4062,9 @@ } }, "node_modules/@types/react-dom": { - "version": "18.0.9", - "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.0.9.tgz", - "integrity": "sha512-qnVvHxASt/H7i+XG1U1xMiY5t+IHcPGUK7TDMDzom08xa7e86eCeKOiLZezwCKVxJn6NEiiy2ekgX8aQssjIKg==", + "version": "18.0.10", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.0.10.tgz", + "integrity": "sha512-E42GW/JA4Qv15wQdqJq8DL4JhNpB3prJgjgapN3qJT9K2zO5IIAQh4VXvCEDupoqAwnz0cY4RlXeC/ajX5SFHg==", "dependencies": { "@types/react": "*" } @@ -14576,11 +14576,11 @@ } }, "node_modules/react-router": { - "version": "6.5.0", - "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.5.0.tgz", - "integrity": "sha512-fqqUSU0NC0tSX0sZbyuxzuAzvGqbjiZItBQnyicWlOUmzhAU8YuLgRbaCL2hf3sJdtRy4LP/WBrWtARkMvdGPQ==", + "version": "6.6.0", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.6.0.tgz", + "integrity": "sha512-+VPfCIaFbkW7BAiB/2oeprxKAt1KLbl+zXZ10CXOYezKWgBmTKyh8XjI53eLqY5kd7uY+V4rh3UW44FclwUU+Q==", "dependencies": { - "@remix-run/router": "1.1.0" + "@remix-run/router": "1.2.0" }, "engines": { "node": ">=14" @@ -14590,12 +14590,12 @@ } }, "node_modules/react-router-dom": { - "version": "6.5.0", - "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.5.0.tgz", - "integrity": "sha512-/XzRc5fq80gW1ctiIGilyKFZC/j4kfe75uivMsTChFbkvrK4ZrF3P3cGIc1f/SSkQ4JiJozPrf+AwUHHWVehVg==", + "version": "6.6.0", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.6.0.tgz", + "integrity": "sha512-qC4jnvpfCPKVle1mKLD75IvZLcbVJyFMlSn16WY9ZiOed3dgSmqhslCf/u3tmSccWOujkdsT/OwGq12bELmvjg==", "dependencies": { - "@remix-run/router": "1.1.0", - "react-router": "6.5.0" + "@remix-run/router": "1.2.0", + "react-router": "6.6.0" }, "engines": { "node": ">=14" @@ -16441,9 +16441,9 @@ } }, "node_modules/typesafe-i18n": { - "version": "5.17.2", - "resolved": "https://registry.npmjs.org/typesafe-i18n/-/typesafe-i18n-5.17.2.tgz", - "integrity": "sha512-G5LCXLDugzvG0GtkBS1+0f+ctQzQNPqwPElvrOMQ8LAG/mwwtW84H42sGfNJ9Dfqlh+t7250N/8TQ7Vta98cKQ==", + "version": "5.18.0", + "resolved": "https://registry.npmjs.org/typesafe-i18n/-/typesafe-i18n-5.18.0.tgz", + "integrity": "sha512-4uzmbSwBOYQ5Upuam1btGf8/fKhBR19b8fg1auILRs9tHlaWtvIYORU7MJsoNee/rmQfIAv6pkiXrIEuMCoW7Q==", "bin": { "typesafe-i18n": "cli/typesafe-i18n.mjs" }, @@ -19657,14 +19657,14 @@ "integrity": "sha512-h9u4u/jiIRKbq25PM+zymTyW6bhTzELvOoUd+AvYriWOAKpLGnIamaET3pnHYoI5iYphAHBI4ayx0MehR+VVPQ==" }, "@mui/base": { - "version": "5.0.0-alpha.110", - "resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-alpha.110.tgz", - "integrity": "sha512-q4TH9T3sTBknTXXTEf2zO8F3nbHg5iGgiaRx9XErTbXvHrmLrQXbQ4hmrLERocSTBFCFWkKyne/qZj0diWlPtA==", + "version": "5.0.0-alpha.111", + "resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-alpha.111.tgz", + "integrity": "sha512-2wfIPpl97S4dPzD0QOM3UIzQ/EuXCYQvHmXxTpfKxev/cfkzOe7Ik/McoYUBbtM1bSOqH3W276R/L2LF9cyXqQ==", "requires": { "@babel/runtime": "^7.20.6", "@emotion/is-prop-valid": "^1.2.0", "@mui/types": "^7.2.3", - "@mui/utils": "^5.11.0", + "@mui/utils": "^5.11.1", "@popperjs/core": "^2.11.6", "clsx": "^1.2.1", "prop-types": "^15.8.1", @@ -19672,9 +19672,9 @@ } }, "@mui/core-downloads-tracker": { - "version": "5.11.0", - "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.11.0.tgz", - "integrity": "sha512-Bmogung451ezVv2YI1RvweOIVsTj2RQ4Fk61+e/+8LFPLTFEwVGbL0YhNy1VB5tri8pzGNV228kxtWVTFooQkg==" + "version": "5.11.1", + "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.11.1.tgz", + "integrity": "sha512-QVqVNlZ2K+LqUDE5kFgYd0r4KekR/dv2cNYbAutQWbfOA8VPVUVrDz0ELrEcoe8TjM/CwnsmGvaDh/YSNl/ALA==" }, "@mui/icons-material": { "version": "5.11.0", @@ -19685,16 +19685,16 @@ } }, "@mui/material": { - "version": "5.11.0", - "resolved": "https://registry.npmjs.org/@mui/material/-/material-5.11.0.tgz", - "integrity": "sha512-8Zl34lb89rLKTTi50Kakki675/LLHMKKnkp8Ee3rAZ2qmisQlRODsGh1MBjENKp0vwhQnNSvlsCfJteVTfotPQ==", + "version": "5.11.1", + "resolved": "https://registry.npmjs.org/@mui/material/-/material-5.11.1.tgz", + "integrity": "sha512-yaZiXvcrl2vgUK+VO24780BWRgwdAMmAyuMVZnRTts1Yu0tWd6PjIYq2ZtaOlpj6/LbaSS+Q2kSfxYnDQ20CEQ==", "requires": { "@babel/runtime": "^7.20.6", - "@mui/base": "5.0.0-alpha.110", - "@mui/core-downloads-tracker": "^5.11.0", - "@mui/system": "^5.11.0", + "@mui/base": "5.0.0-alpha.111", + "@mui/core-downloads-tracker": "^5.11.1", + "@mui/system": "^5.11.1", "@mui/types": "^7.2.3", - "@mui/utils": "^5.11.0", + "@mui/utils": "^5.11.1", "@types/react-transition-group": "^4.4.5", "clsx": "^1.2.1", "csstype": "^3.1.1", @@ -19704,12 +19704,12 @@ } }, "@mui/private-theming": { - "version": "5.11.0", - "resolved": "https://registry.npmjs.org/@mui/private-theming/-/private-theming-5.11.0.tgz", - "integrity": "sha512-UFQLb9x5Sj4pg2GhhCGw3Ls/y1Hw/tz9RsBrULvUF0Vgps1z19o7XTq2xqUvp7pN7fJTW7eVIT2gwVg2xlk8PQ==", + "version": "5.11.1", + "resolved": "https://registry.npmjs.org/@mui/private-theming/-/private-theming-5.11.1.tgz", + "integrity": "sha512-nnHg7kA5RwFRhy0wiDYe59sLCVGORpPypL1JcEdhv0+N0Zbmc2E/y4z2zqMRZ62MAEscpro7cQbvv244ThA84A==", "requires": { "@babel/runtime": "^7.20.6", - "@mui/utils": "^5.11.0", + "@mui/utils": "^5.11.1", "prop-types": "^15.8.1" } }, @@ -19725,15 +19725,15 @@ } }, "@mui/system": { - "version": "5.11.0", - "resolved": "https://registry.npmjs.org/@mui/system/-/system-5.11.0.tgz", - "integrity": "sha512-HFUT7Dlmyq6Wfuxsw8QBXZxXDYIQQaJ4YHaZd7s+nDMcjerLnILxjh2g3a6umtOUM+jEcRaFJAtvLZvlGfa5fw==", + "version": "5.11.1", + "resolved": "https://registry.npmjs.org/@mui/system/-/system-5.11.1.tgz", + "integrity": "sha512-BEA2S0hay8n8CcZftkeAVsi0nsb5ZjdnZRCahv5lX7QJYwDjO4ucJ6lnvxHe2v/9Te1LLjTO7ojxu/qM6CE5Cg==", "requires": { "@babel/runtime": "^7.20.6", - "@mui/private-theming": "^5.11.0", + "@mui/private-theming": "^5.11.1", "@mui/styled-engine": "^5.11.0", "@mui/types": "^7.2.3", - "@mui/utils": "^5.11.0", + "@mui/utils": "^5.11.1", "clsx": "^1.2.1", "csstype": "^3.1.1", "prop-types": "^15.8.1" @@ -19746,9 +19746,9 @@ "requires": {} }, "@mui/utils": { - "version": "5.11.0", - "resolved": "https://registry.npmjs.org/@mui/utils/-/utils-5.11.0.tgz", - "integrity": "sha512-DP/YDaVVCVzJpZ5FFPLKNmaJkeaYRviTyIZkL/D5/FmPXQiA6ecd6z0/+VwoNQtp7aXAQWaRhvz4FM25yqFlHA==", + "version": "5.11.1", + "resolved": "https://registry.npmjs.org/@mui/utils/-/utils-5.11.1.tgz", + "integrity": "sha512-lMAPgIJoil8V9ZxsMbEflMsvZmWcHbRVMc4JDY9jPO9V4welpF43h/O267b1RqlcRnC5MEbVQV605GYkTZY29Q==", "requires": { "@babel/runtime": "^7.20.6", "@types/prop-types": "^15.7.5", @@ -19833,9 +19833,9 @@ "integrity": "sha512-50/17A98tWUfQ176raKiOGXuYpLyyVMkxxG6oylzL3BPOlA6ADGdK7EYunSa4I064xerltq9TGXs8HmOk5E+vw==" }, "@remix-run/router": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.1.0.tgz", - "integrity": "sha512-rGl+jH/7x1KBCQScz9p54p0dtPLNeKGb3e0wD2H5/oZj41bwQUnXdzbj2TbUAFhvD7cp9EyEQA4dEgpUFa1O7Q==" + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.2.0.tgz", + "integrity": "sha512-GO82KYYTWPRCgdNtnheaZG3LcViUlxRFlHM7ykh7N+ufoXi6PVIHoP+9RUG/vuzl2hr9i/h6EA1Eq+2HpqJ0gQ==" }, "@rollup/plugin-babel": { "version": "5.3.1", @@ -20292,9 +20292,9 @@ } }, "@types/react-dom": { - "version": "18.0.9", - "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.0.9.tgz", - "integrity": "sha512-qnVvHxASt/H7i+XG1U1xMiY5t+IHcPGUK7TDMDzom08xa7e86eCeKOiLZezwCKVxJn6NEiiy2ekgX8aQssjIKg==", + "version": "18.0.10", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.0.10.tgz", + "integrity": "sha512-E42GW/JA4Qv15wQdqJq8DL4JhNpB3prJgjgapN3qJT9K2zO5IIAQh4VXvCEDupoqAwnz0cY4RlXeC/ajX5SFHg==", "requires": { "@types/react": "*" } @@ -27748,20 +27748,20 @@ "integrity": "sha512-F27qZr8uUqwhWZboondsPx8tnC3Ct3SxZA3V5WyEvujRyyNv0VYPhoBg1gZ8/MV5tubQp76Trw8lTv9hzRBa+A==" }, "react-router": { - "version": "6.5.0", - "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.5.0.tgz", - "integrity": "sha512-fqqUSU0NC0tSX0sZbyuxzuAzvGqbjiZItBQnyicWlOUmzhAU8YuLgRbaCL2hf3sJdtRy4LP/WBrWtARkMvdGPQ==", + "version": "6.6.0", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.6.0.tgz", + "integrity": "sha512-+VPfCIaFbkW7BAiB/2oeprxKAt1KLbl+zXZ10CXOYezKWgBmTKyh8XjI53eLqY5kd7uY+V4rh3UW44FclwUU+Q==", "requires": { - "@remix-run/router": "1.1.0" + "@remix-run/router": "1.2.0" } }, "react-router-dom": { - "version": "6.5.0", - "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.5.0.tgz", - "integrity": "sha512-/XzRc5fq80gW1ctiIGilyKFZC/j4kfe75uivMsTChFbkvrK4ZrF3P3cGIc1f/SSkQ4JiJozPrf+AwUHHWVehVg==", + "version": "6.6.0", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.6.0.tgz", + "integrity": "sha512-qC4jnvpfCPKVle1mKLD75IvZLcbVJyFMlSn16WY9ZiOed3dgSmqhslCf/u3tmSccWOujkdsT/OwGq12bELmvjg==", "requires": { - "@remix-run/router": "1.1.0", - "react-router": "6.5.0" + "@remix-run/router": "1.2.0", + "react-router": "6.6.0" } }, "react-scripts": { @@ -29136,9 +29136,9 @@ } }, "typesafe-i18n": { - "version": "5.17.2", - "resolved": "https://registry.npmjs.org/typesafe-i18n/-/typesafe-i18n-5.17.2.tgz", - "integrity": "sha512-G5LCXLDugzvG0GtkBS1+0f+ctQzQNPqwPElvrOMQ8LAG/mwwtW84H42sGfNJ9Dfqlh+t7250N/8TQ7Vta98cKQ==", + "version": "5.18.0", + "resolved": "https://registry.npmjs.org/typesafe-i18n/-/typesafe-i18n-5.18.0.tgz", + "integrity": "sha512-4uzmbSwBOYQ5Upuam1btGf8/fKhBR19b8fg1auILRs9tHlaWtvIYORU7MJsoNee/rmQfIAv6pkiXrIEuMCoW7Q==", "requires": {} }, "typescript": { diff --git a/interface/package.json b/interface/package.json index 7b9609c09..03b79d463 100644 --- a/interface/package.json +++ b/interface/package.json @@ -8,12 +8,12 @@ "@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", "@types/react": "^18.0.26", - "@types/react-dom": "^18.0.9", + "@types/react-dom": "^18.0.10", "@types/react-router-dom": "^5.3.3", "async-validator": "^4.2.5", "axios": "^1.2.1", @@ -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": { diff --git a/src/emsdevicevalue.h b/src/emsdevicevalue.h index 42e93e2ee..918570a8a 100644 --- a/src/emsdevicevalue.h +++ b/src/emsdevicevalue.h @@ -48,28 +48,28 @@ class DeviceValue { // also used with HA as uom enum DeviceValueUOM : uint8_t { NONE = 0, // 0 - DEGREES, // 1 - DEGREES_R, // 2 - relative temperature - PERCENT, // 3 + DEGREES, // 1 - °C + DEGREES_R, // 2 - °C (relative temperature) + PERCENT, // 3 - % LMIN, // 4 - l/min KWH, // 5 - kWh WH, // 6 - Wh - HOURS, // 7 - MINUTES, // 8 + HOURS, // 7 - h + MINUTES, // 8 - m UA, // 9 - µA - BAR, // 10 + BAR, // 10 - bar KW, // 11 - kW - W, // 12 - KB, // 13 - SECONDS, // 14 + W, // 12 - W + KB, // 13 - kB + SECONDS, // 14 - s DBM, // 15 - dBm - FAHRENHEIT, // 16 + FAHRENHEIT, // 16 - °F MV, // 17 - mV - SQM, // 18 - square meter - M3, // 19 - cubic meter - L, // 20 - liter - KMIN, // 21 - Kelvin * minutes - K, // 22 - Kelvin + SQM, // 18 - m² + M3, // 19 - m³ + L, // 20 - L + KMIN, // 21 - K*min + K, // 22 - K CONNECTIVITY // 23 - used in HA }; diff --git a/src/locale_common.h b/src/locale_common.h index ce4d79603..4279345d6 100644 --- a/src/locale_common.h +++ b/src/locale_common.h @@ -197,7 +197,7 @@ MAKE_PSTR_LIST(tpl_input, "Format: [[]") // Unit Of Measurement mapping - maps to DeviceValueUOM_s in emsdevice.cpp -// Translating hours/minute/seconds in emsdevice.cpp +// Translating hours/minute/seconds are done in emsdevice.cpp (uom_to_string()) MAKE_PSTR(uom_blank, " ") MAKE_PSTR(uom_percent, "%") MAKE_PSTR(uom_degrees, "°C") @@ -208,13 +208,13 @@ MAKE_PSTR(uom_ua, "µA") MAKE_PSTR(uom_lmin, "l/min") MAKE_PSTR(uom_kw, "kW") MAKE_PSTR(uom_w, "W") -MAKE_PSTR(uom_kb, "KB") +MAKE_PSTR(uom_kb, "kB") MAKE_PSTR(uom_dbm, "dBm") MAKE_PSTR(uom_fahrenheit, "°F") MAKE_PSTR(uom_mv, "mV") MAKE_PSTR(uom_sqm, "m²") MAKE_PSTR(uom_m3, "m³") -MAKE_PSTR(uom_l, "l") +MAKE_PSTR(uom_l, "L") MAKE_PSTR(uom_kmin, "K*min") MAKE_PSTR(uom_k, "K") diff --git a/src/mqtt.cpp b/src/mqtt.cpp index bfb350a6c..c034f7a74 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -66,16 +66,10 @@ MAKE_PSTR_WORD(measurement) MAKE_PSTR_WORD(total_increasing) MAKE_PSTR(icondegrees, "mdi:coolant-temperature") // DeviceValueUOM::DEGREES MAKE_PSTR(iconpercent, "mdi:percent-outline") // DeviceValueUOM::PERCENT -MAKE_PSTR(icontime, "mdi:clock-outline") // DeviceValueUOM::SECONDS MINUTES & HOURS MAKE_PSTR(iconkb, "mdi:memory") // DeviceValueUOM::KB MAKE_PSTR(iconlmin, "mdi:water-boiler") // DeviceValueUOM::LMIN -// MAKE_PSTR(iconkwh, "mdi:transmission-tower") // DeviceValueUOM::KWH & WH -MAKE_PSTR(iconua, "mdi:lightning-bolt-circle") // DeviceValueUOM::UA -// MAKE_PSTR(iconbar, "mdi:gauge") // DeviceValueUOM::BAR -// MAKE_PSTR(iconkw, "mdi:omega") // DeviceValueUOM::KW & W -// MAKE_PSTR(icondbm, "mdi:wifi-strength-2") // DeviceValueUOM::DBM -MAKE_PSTR(iconnum, "mdi:counter") // DeviceValueUOM::NONE -// MAKE_PSTR(icondevice, "mdi:home-automation") // for devices in HA +MAKE_PSTR(iconua, "mdi:lightning-bolt-circle") // DeviceValueUOM::UA +MAKE_PSTR(iconnum, "mdi:counter") // DeviceValueUOM::NONE uuid::log::Logger Mqtt::logger_{F_(mqtt), uuid::log::Facility::DAEMON}; @@ -1171,8 +1165,16 @@ void Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev doc["payload_off"] = Helpers::render_boolean(result, false); doc[sc_ha] = F_(measurement); } else { - // always set the uom - if (uom != DeviceValueUOM::NONE) { + // always set the uom, using the standards except for hours/minutes/seconds + // using HA specific codes from https://github.com/home-assistant/core/blob/dev/homeassistant/const.py + if (uom == DeviceValueUOM::HOURS) { + doc[uom_ha] = "h"; + } else if (uom == DeviceValueUOM::MINUTES) { + doc[uom_ha] = "min"; + } else if (uom == DeviceValueUOM::SECONDS) { + doc[uom_ha] = "s"; + } else if (uom != DeviceValueUOM::NONE) { + // default doc[uom_ha] = EMSdevice::uom_to_string(uom); } } @@ -1196,12 +1198,12 @@ void Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev case DeviceValueUOM::SECONDS: case DeviceValueUOM::MINUTES: case DeviceValueUOM::HOURS: - doc[ic_ha] = F_(icontime); if (type == DeviceValueType::TIME) { doc[sc_ha] = F_(total_increasing); } else { doc[sc_ha] = F_(measurement); } + doc[dc_ha] = "duration"; // https://github.com/emsesp/EMS-ESP32/issues/822 break; case DeviceValueUOM::KB: doc[ic_ha] = F_(iconkb); From ca871f654b85c0f0260832a3a1a267749d36f05e Mon Sep 17 00:00:00 2001 From: Proddy Date: Fri, 23 Dec 2022 14:40:24 +0100 Subject: [PATCH 2/5] Remove the test.mosquitto.org URL in the MQTT settings #829 --- CHANGELOG_LATEST.md | 5 +-- factory_settings.ini | 6 ++-- .../src/framework/mqtt/MqttSettingsForm.tsx | 4 +-- interface/src/validators/mqtt.ts | 36 ++++++++++--------- lib/framework/MqttSettingsService.cpp | 6 ++-- lib/framework/MqttSettingsService.h | 2 +- 6 files changed, 32 insertions(+), 27 deletions(-) diff --git a/CHANGELOG_LATEST.md b/CHANGELOG_LATEST.md index d7186d8a0..3bbfd9ef4 100644 --- a/CHANGELOG_LATEST.md +++ b/CHANGELOG_LATEST.md @@ -24,8 +24,9 @@ - Add more bus-ids [#673](https://github.com/emsesp/EMS-ESP32/issues/673) - Use HA connectivity device class for Status, added boot time [#751](https://github.com/emsesp/EMS-ESP32/issues/751) - Add commands for analog sensors outputs -- Support for multiple EMS-ESPs with MQTT and HA [[#759](https://github.com/emsesp/EMS-ESP32/issues/759)] -- Settings for heatpump silent mode and additional heater [[#802](https://github.com/emsesp/EMS-ESP32/issues/802)] [[#803](https://github.com/emsesp/EMS-ESP32/issues/803)] +- Support for multiple EMS-ESPs with MQTT and HA [#759](https://github.com/emsesp/EMS-ESP32/issues/759) +- Settings for heatpump silent mode and additional heater [#802](https://github.com/emsesp/EMS-ESP32/issues/802)] [[#803](https://github.com/emsesp/EMS-ESP32/issues/803) +- Default MQTT hostname is blank [#829](https://github.com/emsesp/EMS-ESP32/issues/829) ## Fixed diff --git a/factory_settings.ini b/factory_settings.ini index 12a99b948..106c29c62 100644 --- a/factory_settings.ini +++ b/factory_settings.ini @@ -7,8 +7,8 @@ build_flags = ; Access point settings -D FACTORY_AP_PROVISION_MODE=AP_MODE_DISCONNECTED - -D FACTORY_AP_SSID=\"ems-esp\" ; 1-64 characters - -D FACTORY_AP_PASSWORD=\"ems-esp-neo\" ; 8-64 characters + -D FACTORY_AP_SSID=\"ems-esp\" + -D FACTORY_AP_PASSWORD=\"ems-esp-neo\" -D FACTORY_AP_LOCAL_IP=\"192.168.4.1\" -D FACTORY_AP_GATEWAY_IP=\"192.168.4.1\" -D FACTORY_AP_SUBNET_MASK=\"255.255.255.0\" @@ -32,7 +32,7 @@ build_flags = ; MQTT settings -D FACTORY_MQTT_ENABLED=false - -D FACTORY_MQTT_HOST=\"test.mosquitto.org\" + -D FACTORY_MQTT_HOST=\"\" -D FACTORY_MQTT_PORT=1883 -D FACTORY_MQTT_USERNAME=\"\" -D FACTORY_MQTT_PASSWORD=\"\" diff --git a/interface/src/framework/mqtt/MqttSettingsForm.tsx b/interface/src/framework/mqtt/MqttSettingsForm.tsx index ebe7151f8..7c79251a7 100644 --- a/interface/src/framework/mqtt/MqttSettingsForm.tsx +++ b/interface/src/framework/mqtt/MqttSettingsForm.tsx @@ -4,7 +4,7 @@ import { ValidateFieldsError } from 'async-validator'; import { Button, Checkbox, MenuItem, Grid, Typography, InputAdornment } from '@mui/material'; import SaveIcon from '@mui/icons-material/Save'; -import { MQTT_SETTINGS_VALIDATOR, validate } from '../../validators'; +import { createMqttSettingsValidator, validate } from '../../validators'; import { BlockFormControlLabel, ButtonRow, @@ -39,7 +39,7 @@ const MqttSettingsForm: FC = () => { const validateAndSubmit = async () => { try { setFieldErrors(undefined); - await validate(MQTT_SETTINGS_VALIDATOR, data); + await validate(createMqttSettingsValidator(data), data); saveData(); } catch (errors: any) { setFieldErrors(errors); diff --git a/interface/src/validators/mqtt.ts b/interface/src/validators/mqtt.ts index a38e2d8a0..817c9b610 100644 --- a/interface/src/validators/mqtt.ts +++ b/interface/src/validators/mqtt.ts @@ -1,19 +1,23 @@ import Schema from 'async-validator'; +import { MqttSettings } from '../types'; import { IP_OR_HOSTNAME_VALIDATOR } from './shared'; -export const MQTT_SETTINGS_VALIDATOR = new Schema({ - host: [{ required: true, message: 'Host is required' }, IP_OR_HOSTNAME_VALIDATOR], - base: { required: true, message: 'Base is required' }, - port: [ - { required: true, message: 'Port is required' }, - { type: 'number', min: 0, max: 65535, message: 'Invalid Port' } - ], - keep_alive: [ - { required: true, message: 'Keep alive is required' }, - { type: 'number', min: 1, max: 86400, message: 'Keep alive must be between 1 and 86400' } - ], - publish_time_heartbeat: [ - { required: true, message: 'Heartbeat is required' }, - { type: 'number', min: 10, max: 86400, message: 'Heartbeat must be between 10 and 86400' } - ] -}); +export const createMqttSettingsValidator = (mqttSettings: MqttSettings) => + new Schema({ + ...(mqttSettings.enabled && { + host: [{ required: true, message: 'Host is required' }, IP_OR_HOSTNAME_VALIDATOR], + base: { required: true, message: 'Base is required' }, + port: [ + { required: true, message: 'Port is required' }, + { type: 'number', min: 0, max: 65535, message: 'Invalid Port' } + ], + keep_alive: [ + { required: true, message: 'Keep alive is required' }, + { type: 'number', min: 1, max: 86400, message: 'Keep alive must be between 1 and 86400' } + ], + publish_time_heartbeat: [ + { required: true, message: 'Heartbeat is required' }, + { type: 'number', min: 10, max: 86400, message: 'Heartbeat must be between 10 and 86400' } + ] + }) + }); diff --git a/lib/framework/MqttSettingsService.cpp b/lib/framework/MqttSettingsService.cpp index f54372578..7491691c5 100644 --- a/lib/framework/MqttSettingsService.cpp +++ b/lib/framework/MqttSettingsService.cpp @@ -125,8 +125,8 @@ void MqttSettingsService::configureMqtt() { // disconnect if connected _mqttClient.disconnect(); // only connect if WiFi is connected and MQTT is enabled - if (_state.enabled && emsesp::EMSESP::system_.network_connected()) { - // emsesp::EMSESP::logger().info("Configuring Mqtt client"); + if (_state.enabled && emsesp::EMSESP::system_.network_connected() && !_state.host.isEmpty()) { + // emsesp::EMSESP::logger().info("Configuring MQTT client"); _mqttClient.setServer(retainCstr(_state.host.c_str(), &_retainedHost), _state.port); if (_state.username.length() > 0) { _mqttClient.setCredentials(retainCstr(_state.username.c_str(), &_retainedUsername), @@ -140,7 +140,7 @@ void MqttSettingsService::configureMqtt() { _mqttClient.setMaxTopicLength(FACTORY_MQTT_MAX_TOPIC_LENGTH); // hardcode. We don't take this from the settings anymore. _mqttClient.connect(); // } else { - // emsesp::EMSESP::logger().info("Error configuring Mqtt client"); + // emsesp::EMSESP::logger().info("Error configuring MQTT client"); } } diff --git a/lib/framework/MqttSettingsService.h b/lib/framework/MqttSettingsService.h index ab6766b35..d4ec575cc 100644 --- a/lib/framework/MqttSettingsService.h +++ b/lib/framework/MqttSettingsService.h @@ -19,7 +19,7 @@ #endif #ifndef FACTORY_MQTT_HOST -#define FACTORY_MQTT_HOST "test.mosquitto.org" +#define FACTORY_MQTT_HOST "" // is blank #endif #ifndef FACTORY_MQTT_PORT From 5f9ba2e04bb047a40f8d092f50edf618d5ad5991 Mon Sep 17 00:00:00 2001 From: Proddy Date: Fri, 23 Dec 2022 14:58:15 +0100 Subject: [PATCH 3/5] add TODO for missing translations --- interface/src/i18n/de/index.ts | 2 +- interface/src/i18n/fr/index.ts | 12 ++++++------ interface/src/i18n/nl/index.ts | 12 ++++++------ interface/src/i18n/no/index.ts | 12 ++++++------ interface/src/i18n/se/index.ts | 12 ++++++------ 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/interface/src/i18n/de/index.ts b/interface/src/i18n/de/index.ts index 6095ccea3..666903c4c 100644 --- a/interface/src/i18n/de/index.ts +++ b/interface/src/i18n/de/index.ts @@ -71,7 +71,7 @@ const de: Translation = { TEMP_SENSOR: 'Temperatursensor', TEMP_SENSORS: 'Temperatursensoren', WRITE_CMD_SENT: 'Befehl schreiben wurde gesendet', - WRITE_CMD_FAILED: 'Befehl schreiben failed', + WRITE_CMD_FAILED: 'Befehl schreiben failed', // TODO EMS_BUS_WARNING: 'EMS-Bus getrennt. Wenn diese Warnung nach einigen Sekunden immer noch besteht, überprüfen Sie bitte die Einstellungen und das Board-Profil', EMS_BUS_SCANNING: 'Suche nach EMS Geräten...', CONNECTED: 'Verbunden', diff --git a/interface/src/i18n/fr/index.ts b/interface/src/i18n/fr/index.ts index 9954e43a9..ee40738bc 100644 --- a/interface/src/i18n/fr/index.ts +++ b/interface/src/i18n/fr/index.ts @@ -69,8 +69,8 @@ const fr: Translation = { SENSOR: 'Capteur', TEMP_SENSOR: 'Capteur de température', TEMP_SENSORS: 'Capteurs de température', - WRITE_CMD_SENT: 'Envoyer la commande sent', - WRITE_CMD_FAILED: 'Envoyer la commande failed', + WRITE_CMD_SENT: 'Envoyer la commande sent', // TODO + WRITE_CMD_FAILED: 'Envoyer la commande failed', // TODO EMS_BUS_WARNING: 'Bus EMS déconnecté. Si ce message persiste après quelques secondes, vérifiez les paramètres et la configuration de la carte.', EMS_BUS_SCANNING: 'Scan des appareils EMS...', CONNECTED: 'Connecté', @@ -249,10 +249,10 @@ const fr: Translation = { MQTT_INT_HEARTBEAT: 'Battements', MQTT_QUEUE: 'Queue MQTT', DEFAULT: 'Défaut', - MQTT_ENTITY_FORMAT: 'Entity ID format', - MQTT_ENTITY_FORMAT_0: 'Single instance, long name (v3.4)', - MQTT_ENTITY_FORMAT_1: 'Single instance, short name', - MQTT_ENTITY_FORMAT_2: 'Multiple instances, short name', + MQTT_ENTITY_FORMAT: 'Entity ID format', // TODO + MQTT_ENTITY_FORMAT_0: 'Single instance, long name (v3.4)',// TODO + MQTT_ENTITY_FORMAT_1: 'Single instance, short name', // TODO + MQTT_ENTITY_FORMAT_2: 'Multiple instances, short name', // TODO MQTT_CLEAN_SESSION: 'Flag Clean Session', MQTT_RETAIN_FLAG: 'Toujours activer le Retain Flag', INACTIVE: 'Inactif', diff --git a/interface/src/i18n/nl/index.ts b/interface/src/i18n/nl/index.ts index c75472a9d..7fe681fd2 100644 --- a/interface/src/i18n/nl/index.ts +++ b/interface/src/i18n/nl/index.ts @@ -69,8 +69,8 @@ const nl: Translation = { SENSOR: 'Sensor', TEMP_SENSOR: 'Temperatuur sensor', TEMP_SENSORS: 'Temperatuur Sensoren', - WRITE_CMD_SENT: 'Schrijf commando sent', - WRITE_CMD_FAILED: 'Schrijf commando failed', + WRITE_CMD_SENT: 'Schrijf commando sent', // TODO + WRITE_CMD_FAILED: 'Schrijf commando failed', // TODO EMS_BUS_WARNING: 'EMS bus niet gevonden. Als deze waarschuwing blijft staan na een paar seconden dan loop de instellingen na en in het bijzonder het apparaat type profiel na.', EMS_BUS_SCANNING: 'Scannen naar EMS apparaten...', CONNECTED: 'Verbonden', @@ -249,10 +249,10 @@ const nl: Translation = { MQTT_INT_HEARTBEAT: 'Heartbeat', MQTT_QUEUE: 'MQTT Queue', DEFAULT: 'Default', - MQTT_ENTITY_FORMAT: 'Entity ID format', - MQTT_ENTITY_FORMAT_0: 'Single instance, long name (v3.4)', - MQTT_ENTITY_FORMAT_1: 'Single instance, short name', - MQTT_ENTITY_FORMAT_2: 'Multiple instances, short name', + MQTT_ENTITY_FORMAT: 'Entity ID format', // TODO + MQTT_ENTITY_FORMAT_0: 'Single instance, long name (v3.4)', // TODO + MQTT_ENTITY_FORMAT_1: 'Single instance, short name', // TODO + MQTT_ENTITY_FORMAT_2: 'Multiple instances, short name', // TODO MQTT_CLEAN_SESSION: 'Clean Session aan', MQTT_RETAIN_FLAG: 'Retain flag aan', INACTIVE: 'Inactief', diff --git a/interface/src/i18n/no/index.ts b/interface/src/i18n/no/index.ts index 796b6ee0d..d46dfe540 100644 --- a/interface/src/i18n/no/index.ts +++ b/interface/src/i18n/no/index.ts @@ -69,8 +69,8 @@ const no: Translation = { SENSOR: 'Sensor', TEMP_SENSOR: 'Temperatursensor', TEMP_SENSORS: 'Temperaturesensorer', - WRITE_CMD_SENT: 'Skriv kommando sent', - WRITE_CMD_FAILED: 'Skriv kommandofailed', + WRITE_CMD_SENT: 'Skriv kommando sent', // TODO + WRITE_CMD_FAILED: 'Skriv kommando failed', // TODO EMS_BUS_WARNING: 'EMS bussen koblet ned. Hvis denne advarselen fortsetter etter noen f¨sekunder sjekk instillinger og prosessorkort', EMS_BUS_SCANNING: 'Søker etter EMS enheter...', CONNECTED: 'Tilkoblet', @@ -249,10 +249,10 @@ const no: Translation = { MQTT_INT_HEARTBEAT: 'Heartbeat', MQTT_QUEUE: 'MQTT Queue', DEFAULT: 'Standard', - MQTT_ENTITY_FORMAT: 'Entity ID format', - MQTT_ENTITY_FORMAT_0: 'Single instance, long name (v3.4)', - MQTT_ENTITY_FORMAT_1: 'Single instance, short name', - MQTT_ENTITY_FORMAT_2: 'Multiple instances, short name', + MQTT_ENTITY_FORMAT: 'Entity ID format', // TODO + MQTT_ENTITY_FORMAT_0: 'Single instance, long name (v3.4)', // TODO + MQTT_ENTITY_FORMAT_1: 'Single instance, short name', // TODO + MQTT_ENTITY_FORMAT_2: 'Multiple instances, short name', // TODO MQTT_CLEAN_SESSION: 'Benytt Clean Session', MQTT_RETAIN_FLAG: 'Alltid sett Retain flag', INACTIVE: 'Innaktiv', diff --git a/interface/src/i18n/se/index.ts b/interface/src/i18n/se/index.ts index d822e1e5c..5b17395d0 100644 --- a/interface/src/i18n/se/index.ts +++ b/interface/src/i18n/se/index.ts @@ -69,8 +69,8 @@ const se: Translation = { SENSOR: 'Sensor', TEMP_SENSOR: 'Temperatursensor', TEMP_SENSORS: 'Temperatursensorer', - WRITE_CMD_SENT: 'Skrivkommando sent', - WRITE_CMD_FAILED: 'Skrivkommando failed', + WRITE_CMD_SENT: 'Skrivkommando sent', // TODO + WRITE_CMD_FAILED: 'Skrivkommando failed', // TODO EMS_BUS_WARNING: 'EMS-buss nedkopplad. Om denna varning kvarstår efter några sekunder, kontrollera inställningar och enhets-profil.', EMS_BUS_SCANNING: 'Söker efter EMS-enheter...', CONNECTED: 'Ansluten', @@ -249,10 +249,10 @@ const se: Translation = { MQTT_INT_HEARTBEAT: 'Heartbeat', MQTT_QUEUE: 'MQTT Queue', DEFAULT: 'Standard', - MQTT_ENTITY_FORMAT: 'Entity ID format', - MQTT_ENTITY_FORMAT_0: 'Single instance, long name (v3.4)', - MQTT_ENTITY_FORMAT_1: 'Single instance, short name', - MQTT_ENTITY_FORMAT_2: 'Multiple instances, short name', + MQTT_ENTITY_FORMAT: 'Entity ID format', // TODO + MQTT_ENTITY_FORMAT_0: 'Single instance, long name (v3.4)', // TODO + MQTT_ENTITY_FORMAT_1: 'Single instance, short name', // TODO + MQTT_ENTITY_FORMAT_2: 'Multiple instances, short name', // TODO MQTT_CLEAN_SESSION: 'Använd "Clean Session"-flaggan', MQTT_RETAIN_FLAG: 'Använd "Always Retain"-flaggan', INACTIVE: 'Inaktiv', From 2151905d467d14f60c82e5e7fc3f573c161af5fb Mon Sep 17 00:00:00 2001 From: Proddy Date: Fri, 23 Dec 2022 18:28:09 +0100 Subject: [PATCH 4/5] test upgrade --- lib_standalone/ESP8266React.h | 73 +++++++++++++++++----------------- lib_standalone/FSPersistence.h | 1 + src/emsesp.cpp | 15 +++++-- src/locale_common.h | 2 +- src/system.cpp | 52 ++++++++++++++++++++++-- src/system.h | 2 + src/web/WebSettingsService.cpp | 4 ++ src/web/WebSettingsService.h | 69 ++++++++++++++++---------------- 8 files changed, 139 insertions(+), 79 deletions(-) diff --git a/lib_standalone/ESP8266React.h b/lib_standalone/ESP8266React.h index b8c599862..e469cc380 100644 --- a/lib_standalone/ESP8266React.h +++ b/lib_standalone/ESP8266React.h @@ -26,42 +26,43 @@ class DummySettings { public: - String locale = "en"; - uint8_t tx_mode = 1; - uint8_t ems_bus_id = 0x0B; - bool syslog_enabled = false; - int8_t syslog_level = 3; // uuid::log::Level - uint32_t syslog_mark_interval = 0; - String syslog_host = "192.168.1.4"; - uint16_t syslog_port = 514; - bool shower_timer = true; - bool shower_alert = false; - uint8_t shower_alert_coldshot = 10; - uint8_t shower_alert_trigger = 7; - bool hide_led = false; - bool notoken_api = false; - bool readonly_mode = false; - uint8_t bool_format = 1; // using "on" and "off" - uint8_t bool_dashboard = 1; - uint8_t enum_format = 1; - bool nosleep = false; - bool fahrenheit = false; - bool bandwidth20 = false; - bool telnet_enabled = false; - String board_profile = "CUSTOM"; - bool trace_raw = false; - bool analog_enabled = true; // analog is enabled - int8_t weblog_level = 1; - uint8_t weblog_buffer = 50; - bool weblog_compact = true; - uint8_t rx_gpio = 0; - uint8_t tx_gpio = 0; - uint8_t dallas_gpio = 16; // to ensure its enabled - bool dallas_parasite = false; - uint8_t led_gpio = 0; - bool low_clock = false; - uint8_t pbutton_gpio = false; - uint8_t solar_maxflow = 30; + std::string version{"poerp"}; + String locale = "en"; + uint8_t tx_mode = 1; + uint8_t ems_bus_id = 0x0B; + bool syslog_enabled = false; + int8_t syslog_level = 3; // uuid::log::Level + uint32_t syslog_mark_interval = 0; + String syslog_host = "192.168.1.4"; + uint16_t syslog_port = 514; + bool shower_timer = true; + bool shower_alert = false; + uint8_t shower_alert_coldshot = 10; + uint8_t shower_alert_trigger = 7; + bool hide_led = false; + bool notoken_api = false; + bool readonly_mode = false; + uint8_t bool_format = 1; // using "on" and "off" + uint8_t bool_dashboard = 1; + uint8_t enum_format = 1; + bool nosleep = false; + bool fahrenheit = false; + bool bandwidth20 = false; + bool telnet_enabled = false; + String board_profile = "CUSTOM"; + bool trace_raw = false; + bool analog_enabled = true; // analog is enabled + int8_t weblog_level = 1; + uint8_t weblog_buffer = 50; + bool weblog_compact = true; + uint8_t rx_gpio = 0; + uint8_t tx_gpio = 0; + uint8_t dallas_gpio = 16; // to ensure its enabled + bool dallas_parasite = false; + uint8_t led_gpio = 0; + bool low_clock = false; + uint8_t pbutton_gpio = false; + uint8_t solar_maxflow = 30; // MQTT uint16_t publish_time = 10; diff --git a/lib_standalone/FSPersistence.h b/lib_standalone/FSPersistence.h index 345e9b8ae..a547b26f8 100644 --- a/lib_standalone/FSPersistence.h +++ b/lib_standalone/FSPersistence.h @@ -24,6 +24,7 @@ class FSPersistence { } void readFromFS() { + Serial.println(); Serial.print("Fake reading file "); Serial.println(_filePath); applyDefaults(); diff --git a/src/emsesp.cpp b/src/emsesp.cpp index 5ee409283..31ed9f790 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -1293,13 +1293,20 @@ void EMSESP::start() { LOG_INFO("Last system reset reason Core0: %s, Core1: %s", system_.reset_reason(0).c_str(), system_.reset_reason(1).c_str()); - // do any system upgrades - if (system_.check_upgrade()) { - LOG_INFO("System needs a restart to apply new settings. Please wait."); + // see if we're restoring a settings file + if (system_.check_restore()) { + LOG_WARNING("System needs a restart to apply new settings. Please wait."); + system_.system_restart(); + }; + + webSettingsService.begin(); // load EMS-ESP Application settings... + + // do any system upgrades + if (system_.check_upgrade()) { + LOG_WARNING("System needs a restart to apply new settings. Please wait."); system_.system_restart(); }; - webSettingsService.begin(); // load EMS-ESP Application settings... system_.reload_settings(); // ... and store some of the settings locally webCustomizationService.begin(); // load the customizations diff --git a/src/locale_common.h b/src/locale_common.h index 4279345d6..20a0c9931 100644 --- a/src/locale_common.h +++ b/src/locale_common.h @@ -208,7 +208,7 @@ MAKE_PSTR(uom_ua, "µA") MAKE_PSTR(uom_lmin, "l/min") MAKE_PSTR(uom_kw, "kW") MAKE_PSTR(uom_w, "W") -MAKE_PSTR(uom_kb, "kB") +MAKE_PSTR(uom_kb, "KB") MAKE_PSTR(uom_dbm, "dBm") MAKE_PSTR(uom_fahrenheit, "°F") MAKE_PSTR(uom_mv, "mV") diff --git a/src/system.cpp b/src/system.cpp index bfba78c6e..469645388 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -290,6 +290,8 @@ void System::syslog_init() { // read some specific system settings to store locally for faster access void System::reload_settings() { EMSESP::webSettingsService.read([&](WebSettings & settings) { + version_ = settings.version; + pbutton_gpio_ = settings.pbutton_gpio; analog_enabled_ = settings.analog_enabled; low_clock_ = settings.low_clock; @@ -969,10 +971,8 @@ void System::show_system(uuid::console::Shell & shell) { #endif } -// handle upgrades from previous versions -// or managing an uploaded files to replace settings files -// returns true if we need a reboot -bool System::check_upgrade() { +// see if there is a restore of an older settings file that needs to be applied +bool System::check_restore() { bool reboot_required = false; #ifndef EMSESP_STANDALONE @@ -1012,6 +1012,50 @@ bool System::check_upgrade() { return reboot_required; } +// handle upgrades from previous versions +// returns true if we need a reboot +bool System::check_upgrade() { + std::string old_version; + + // TODO fix + + if (version_ != EMSESP_APP_VERSION) { + if (version_.empty()) { + LOG_DEBUG("No version, presuming fresh install. Setting to %s", EMSESP_APP_VERSION); + old_version = EMSESP_APP_VERSION; + } else { + LOG_DEBUG("Going from version %s to %s", version_, EMSESP_APP_VERSION); + old_version = version_; + } + // save the new version + version_ = EMSESP_APP_VERSION; + EMSESP::webSettingsService.update( + [&](WebSettings & settings) { + settings.version = EMSESP_APP_VERSION; + return StateUpdateResult::CHANGED; + }, + "local"); + } + + if (old_version == EMSESP_APP_VERSION) { + return false; // no upgrades or reboot needed. we're on the latest + } + + LOG_DEBUG("Doing upgrade..."); // TODO remove + + + // check variations between versions + // get major version + + // get minor version + + // get patch version (ignore alphanumerics) + + bool reboot_required = false; + + return reboot_required; +} + // list commands bool System::command_commands(const char * value, const int8_t id, JsonObject & output) { return Command::list(EMSdevice::DeviceType::SYSTEM, output); diff --git a/src/system.h b/src/system.h index 3f4169306..789de9018 100644 --- a/src/system.h +++ b/src/system.h @@ -75,6 +75,7 @@ class System { void wifi_tweak(); void syslog_init(); bool check_upgrade(); + bool check_restore(); bool heartbeat_json(JsonObject & output); void send_heartbeat(); void send_info_mqtt(const char * event_str, bool send_ntp = false); @@ -294,6 +295,7 @@ class System { uint8_t bool_format_; uint8_t enum_format_; bool readonly_mode_; + std::string version_; // ethernet uint8_t phy_type_; diff --git a/src/web/WebSettingsService.cpp b/src/web/WebSettingsService.cpp index b17963680..5923a0a97 100644 --- a/src/web/WebSettingsService.cpp +++ b/src/web/WebSettingsService.cpp @@ -80,6 +80,10 @@ void WebSettings::read(WebSettings & settings, JsonObject & root) { // call on initialization and also when settings are updated via web or console StateUpdateResult WebSettings::update(JsonObject & root, WebSettings & settings) { + // load the version of the settings + // will be picked up in System::check_upgrade() + settings.version = root["version"] || ""; + // load default GPIO configuration based on board profile std::vector data; // // led, dallas, rx, tx, button, phy_type, eth_power, eth_phy_addr, eth_clock_mode #if CONFIG_IDF_TARGET_ESP32C3 diff --git a/src/web/WebSettingsService.h b/src/web/WebSettingsService.h index a20e10c9a..2addbb4cb 100644 --- a/src/web/WebSettingsService.h +++ b/src/web/WebSettingsService.h @@ -29,40 +29,41 @@ namespace emsesp { class WebSettings { public: - String locale; - uint8_t tx_mode; - uint8_t ems_bus_id; - bool shower_timer; - bool shower_alert; - uint8_t shower_alert_trigger; - uint8_t shower_alert_coldshot; - bool syslog_enabled; - int8_t syslog_level; // uuid::log::Level - uint32_t syslog_mark_interval; - String syslog_host; - uint16_t syslog_port; - bool trace_raw; - uint8_t rx_gpio; - uint8_t tx_gpio; - uint8_t dallas_gpio; - bool dallas_parasite; - uint8_t led_gpio; - bool hide_led; - bool low_clock; - bool telnet_enabled; - bool notoken_api; - bool readonly_mode; - bool analog_enabled; - uint8_t pbutton_gpio; - uint8_t solar_maxflow; - String board_profile; - uint8_t bool_format; - uint8_t bool_dashboard; - uint8_t enum_format; - int8_t weblog_level; - uint8_t weblog_buffer; - bool weblog_compact; - bool fahrenheit; + std::string version; + String locale; + uint8_t tx_mode; + uint8_t ems_bus_id; + bool shower_timer; + bool shower_alert; + uint8_t shower_alert_trigger; + uint8_t shower_alert_coldshot; + bool syslog_enabled; + int8_t syslog_level; // uuid::log::Level + uint32_t syslog_mark_interval; + String syslog_host; + uint16_t syslog_port; + bool trace_raw; + uint8_t rx_gpio; + uint8_t tx_gpio; + uint8_t dallas_gpio; + bool dallas_parasite; + uint8_t led_gpio; + bool hide_led; + bool low_clock; + bool telnet_enabled; + bool notoken_api; + bool readonly_mode; + bool analog_enabled; + uint8_t pbutton_gpio; + uint8_t solar_maxflow; + String board_profile; + uint8_t bool_format; + uint8_t bool_dashboard; + uint8_t enum_format; + int8_t weblog_level; + uint8_t weblog_buffer; + bool weblog_compact; + bool fahrenheit; uint8_t phy_type; int8_t eth_power; // -1 means disabled From b7bfd803eb293278963f0a046e684a16b756fe17 Mon Sep 17 00:00:00 2001 From: proddy Date: Sat, 24 Dec 2022 08:09:11 +0100 Subject: [PATCH 5/5] kB back to KB, L back to l --- src/locale_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/locale_common.h b/src/locale_common.h index 20a0c9931..2b757d513 100644 --- a/src/locale_common.h +++ b/src/locale_common.h @@ -214,7 +214,7 @@ MAKE_PSTR(uom_fahrenheit, "°F") MAKE_PSTR(uom_mv, "mV") MAKE_PSTR(uom_sqm, "m²") MAKE_PSTR(uom_m3, "m³") -MAKE_PSTR(uom_l, "L") +MAKE_PSTR(uom_l, "l") MAKE_PSTR(uom_kmin, "K*min") MAKE_PSTR(uom_k, "K")