From 6ad1dd1a77a32c88b12f64f752fcf4f3304098e2 Mon Sep 17 00:00:00 2001 From: Proddy Date: Sun, 19 Feb 2023 11:27:49 +0100 Subject: [PATCH 1/5] update packages --- interface/package-lock.json | 196 +++++++++++++++++------------------- interface/package.json | 20 ++-- mock-api/package-lock.json | 8 +- mock-api/package.json | 2 +- 4 files changed, 107 insertions(+), 119 deletions(-) diff --git a/interface/package-lock.json b/interface/package-lock.json index ea6939665..1933cf586 100644 --- a/interface/package-lock.json +++ b/interface/package-lock.json @@ -8,19 +8,19 @@ "name": "EMS-ESP", "version": "3.5.0", "dependencies": { - "@emotion/react": "^11.10.5", - "@emotion/styled": "^11.10.5", + "@emotion/react": "^11.10.6", + "@emotion/styled": "^11.10.6", "@msgpack/msgpack": "^2.8.0", - "@mui/icons-material": "^5.11.0", - "@mui/material": "^5.11.7", - "@table-library/react-table-library": "4.0.24", + "@mui/icons-material": "^5.11.9", + "@mui/material": "^5.11.9", + "@table-library/react-table-library": "4.0.25", "@types/lodash": "^4.14.191", - "@types/node": "^18.11.19", - "@types/react": "^18.0.27", - "@types/react-dom": "^18.0.10", + "@types/node": "^18.14.0", + "@types/react": "^18.0.28", + "@types/react-dom": "^18.0.11", "@types/react-router-dom": "^5.3.3", "async-validator": "^4.2.5", - "axios": "^1.3.2", + "axios": "^1.3.3", "jwt-decode": "^3.1.2", "lodash": "^4.17.21", "notistack": "^2.0.8", @@ -32,7 +32,7 @@ "react-router-dom": "^6.8.1", "react-scripts": "5.0.1", "sockette": "^2.0.6", - "typesafe-i18n": "^5.24.0", + "typesafe-i18n": "^5.24.1", "typescript": "^4.9.5" }, "devDependencies": { @@ -2096,12 +2096,11 @@ } }, "node_modules/@emotion/babel-plugin": { - "version": "11.10.5", - "resolved": "https://registry.npmjs.org/@emotion/babel-plugin/-/babel-plugin-11.10.5.tgz", - "integrity": "sha512-xE7/hyLHJac7D2Ve9dKroBBZqBT7WuPQmWcq7HSGb84sUuP4mlOWoB8dvVfD9yk5DHkU1m6RW7xSoDtnQHNQeA==", + "version": "11.10.6", + "resolved": "https://registry.npmjs.org/@emotion/babel-plugin/-/babel-plugin-11.10.6.tgz", + "integrity": "sha512-p2dAqtVrkhSa7xz1u/m9eHYdLi+en8NowrmXeF/dKtJpU8lCWli8RUAati7NcSl0afsBott48pdnANuD0wh9QQ==", "dependencies": { "@babel/helper-module-imports": "^7.16.7", - "@babel/plugin-syntax-jsx": "^7.17.12", "@babel/runtime": "^7.18.3", "@emotion/hash": "^0.9.0", "@emotion/memoize": "^0.8.0", @@ -2112,9 +2111,6 @@ "find-root": "^1.1.0", "source-map": "^0.5.7", "stylis": "4.1.3" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" } }, "node_modules/@emotion/cache": { @@ -2148,12 +2144,12 @@ "integrity": "sha512-G/YwXTkv7Den9mXDO7AhLWkE3q+I92B+VqAE+dYG4NGPaHZGvt3G8Q0p9vmE+sq7rTGphUbAvmQ9YpbfMQGGlA==" }, "node_modules/@emotion/react": { - "version": "11.10.5", - "resolved": "https://registry.npmjs.org/@emotion/react/-/react-11.10.5.tgz", - "integrity": "sha512-TZs6235tCJ/7iF6/rvTaOH4oxQg2gMAcdHemjwLKIjKz4rRuYe1HJ2TQJKnAcRAfOUDdU8XoDadCe1rl72iv8A==", + "version": "11.10.6", + "resolved": "https://registry.npmjs.org/@emotion/react/-/react-11.10.6.tgz", + "integrity": "sha512-6HT8jBmcSkfzO7mc+N1L9uwvOnlcGoix8Zn7srt+9ga0MjREo6lRpuVX0kzo6Jp6oTqDhREOFsygN6Ew4fEQbw==", "dependencies": { "@babel/runtime": "^7.18.3", - "@emotion/babel-plugin": "^11.10.5", + "@emotion/babel-plugin": "^11.10.6", "@emotion/cache": "^11.10.5", "@emotion/serialize": "^1.1.1", "@emotion/use-insertion-effect-with-fallbacks": "^1.0.0", @@ -2162,13 +2158,9 @@ "hoist-non-react-statics": "^3.3.1" }, "peerDependencies": { - "@babel/core": "^7.0.0", "react": ">=16.8.0" }, "peerDependenciesMeta": { - "@babel/core": { - "optional": true - }, "@types/react": { "optional": true } @@ -2192,26 +2184,22 @@ "integrity": "sha512-zxRBwl93sHMsOj4zs+OslQKg/uhF38MB+OMKoCrVuS0nyTkqnau+BM3WGEoOptg9Oz45T/aIGs1qbVAsEFo3nA==" }, "node_modules/@emotion/styled": { - "version": "11.10.5", - "resolved": "https://registry.npmjs.org/@emotion/styled/-/styled-11.10.5.tgz", - "integrity": "sha512-8EP6dD7dMkdku2foLoruPCNkRevzdcBaY6q0l0OsbyJK+x8D9HWjX27ARiSIKNF634hY9Zdoedh8bJCiva8yZw==", + "version": "11.10.6", + "resolved": "https://registry.npmjs.org/@emotion/styled/-/styled-11.10.6.tgz", + "integrity": "sha512-OXtBzOmDSJo5Q0AFemHCfl+bUueT8BIcPSxu0EGTpGk6DmI5dnhSzQANm1e1ze0YZL7TDyAyy6s/b/zmGOS3Og==", "dependencies": { "@babel/runtime": "^7.18.3", - "@emotion/babel-plugin": "^11.10.5", + "@emotion/babel-plugin": "^11.10.6", "@emotion/is-prop-valid": "^1.2.0", "@emotion/serialize": "^1.1.1", "@emotion/use-insertion-effect-with-fallbacks": "^1.0.0", "@emotion/utils": "^1.2.0" }, "peerDependencies": { - "@babel/core": "^7.0.0", "@emotion/react": "^11.0.0-rc.0", "react": ">=16.8.0" }, "peerDependenciesMeta": { - "@babel/core": { - "optional": true - }, "@types/react": { "optional": true } @@ -3082,14 +3070,14 @@ } }, "node_modules/@mui/base": { - "version": "5.0.0-alpha.116", - "resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-alpha.116.tgz", - "integrity": "sha512-VwhifWdrfHc4/ZdqRZ4Gf+7P39sovNN24By1YVZdvJ9fvp0Sr8sNftGUCjYXXz+xCXVBQDXvhfxMwZrj2MvJvA==", + "version": "5.0.0-alpha.118", + "resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-alpha.118.tgz", + "integrity": "sha512-GAEpqhnuHjRaAZLdxFNuOf2GDTp9sUawM46oHZV4VnYPFjXJDkIYFWfIQLONb0nga92OiqS5DD/scGzVKCL0Mw==", "dependencies": { - "@babel/runtime": "^7.20.7", + "@babel/runtime": "^7.20.13", "@emotion/is-prop-valid": "^1.2.0", "@mui/types": "^7.2.3", - "@mui/utils": "^5.11.7", + "@mui/utils": "^5.11.9", "@popperjs/core": "^2.11.6", "clsx": "^1.2.1", "prop-types": "^15.8.1", @@ -3114,20 +3102,20 @@ } }, "node_modules/@mui/core-downloads-tracker": { - "version": "5.11.7", - "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.11.7.tgz", - "integrity": "sha512-lZgX7XQTk0zVcpwEa80r+T4y09dosnUxWvFPSikU/2Hh5wnyNOek8WfJwGCNsaRiXJHMi5eHY+z8oku4u5lgNw==", + "version": "5.11.9", + "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.11.9.tgz", + "integrity": "sha512-YGEtucQ/Nl91VZkzYaLad47Cdui51n/hW+OQm4210g4N3/nZzBxmGeKfubEalf+ShKH4aYDS86XTO6q/TpZnjQ==", "funding": { "type": "opencollective", "url": "https://opencollective.com/mui" } }, "node_modules/@mui/icons-material": { - "version": "5.11.0", - "resolved": "https://registry.npmjs.org/@mui/icons-material/-/icons-material-5.11.0.tgz", - "integrity": "sha512-I2LaOKqO8a0xcLGtIozC9xoXjZAto5G5gh0FYUMAlbsIHNHIjn4Xrw9rvjY20vZonyiGrZNMAlAXYkY6JvhF6A==", + "version": "5.11.9", + "resolved": "https://registry.npmjs.org/@mui/icons-material/-/icons-material-5.11.9.tgz", + "integrity": "sha512-SPANMk6K757Q1x48nCwPGdSNb8B71d+2hPMJ0V12VWerpSsbjZtvAPi5FAn13l2O5mwWkvI0Kne+0tCgnNxMNw==", "dependencies": { - "@babel/runtime": "^7.20.6" + "@babel/runtime": "^7.20.13" }, "engines": { "node": ">=12.0.0" @@ -3148,16 +3136,16 @@ } }, "node_modules/@mui/material": { - "version": "5.11.7", - "resolved": "https://registry.npmjs.org/@mui/material/-/material-5.11.7.tgz", - "integrity": "sha512-wDv7Pc6kMe9jeWkmCLt4JChd1lPc2u23JQHpB35L2VwQowpNFoDfIwqi0sYCnZTMKlRc7lza8LqwSwHl2G52Rw==", + "version": "5.11.9", + "resolved": "https://registry.npmjs.org/@mui/material/-/material-5.11.9.tgz", + "integrity": "sha512-Wb3WzjzYyi/WKSl/XlF7aC8kk2NE21IoHMF7hNQMkPb0GslbWwR4OUjlBpxtG+RSZn44wMZkEDNB9Hw0TDsd8g==", "dependencies": { - "@babel/runtime": "^7.20.7", - "@mui/base": "5.0.0-alpha.116", - "@mui/core-downloads-tracker": "^5.11.7", - "@mui/system": "^5.11.7", + "@babel/runtime": "^7.20.13", + "@mui/base": "5.0.0-alpha.118", + "@mui/core-downloads-tracker": "^5.11.9", + "@mui/system": "^5.11.9", "@mui/types": "^7.2.3", - "@mui/utils": "^5.11.7", + "@mui/utils": "^5.11.9", "@types/react-transition-group": "^4.4.5", "clsx": "^1.2.1", "csstype": "^3.1.1", @@ -3192,12 +3180,12 @@ } }, "node_modules/@mui/private-theming": { - "version": "5.11.7", - "resolved": "https://registry.npmjs.org/@mui/private-theming/-/private-theming-5.11.7.tgz", - "integrity": "sha512-XzRTSZdc8bhuUdjablTNv3kFkZ/XIMlKkOqqJCU0G8W3tWGXpau2DXkafPd1ddjPhF9zF3qLKNGgKCChYItjgA==", + "version": "5.11.9", + "resolved": "https://registry.npmjs.org/@mui/private-theming/-/private-theming-5.11.9.tgz", + "integrity": "sha512-XMyVIFGomVCmCm92EvYlgq3zrC9K+J6r7IKl/rBJT2/xVYoRY6uM7jeB+Wxh7kXxnW9Dbqsr2yL3cx6wSD1sAg==", "dependencies": { - "@babel/runtime": "^7.20.7", - "@mui/utils": "^5.11.7", + "@babel/runtime": "^7.20.13", + "@mui/utils": "^5.11.9", "prop-types": "^15.8.1" }, "engines": { @@ -3218,11 +3206,11 @@ } }, "node_modules/@mui/styled-engine": { - "version": "5.11.0", - "resolved": "https://registry.npmjs.org/@mui/styled-engine/-/styled-engine-5.11.0.tgz", - "integrity": "sha512-AF06K60Zc58qf0f7X+Y/QjaHaZq16znliLnGc9iVrV/+s8Ln/FCoeNuFvhlCbZZQ5WQcJvcy59zp0nXrklGGPQ==", + "version": "5.11.9", + "resolved": "https://registry.npmjs.org/@mui/styled-engine/-/styled-engine-5.11.9.tgz", + "integrity": "sha512-bkh2CjHKOMy98HyOc8wQXEZvhOmDa/bhxMUekFX5IG0/w4f5HJ8R6+K6nakUUYNEgjOWPYzNPrvGB8EcGbhahQ==", "dependencies": { - "@babel/runtime": "^7.20.6", + "@babel/runtime": "^7.20.13", "@emotion/cache": "^11.10.5", "csstype": "^3.1.1", "prop-types": "^15.8.1" @@ -3249,15 +3237,15 @@ } }, "node_modules/@mui/system": { - "version": "5.11.7", - "resolved": "https://registry.npmjs.org/@mui/system/-/system-5.11.7.tgz", - "integrity": "sha512-uGB6hBxGlAdlmbLdTtUZYNPXkgQGGnKxHdkRATqsu7UlCxNsc/yS5NCEWy/3c4pnelD1LDLD39WrntP9mwhfkQ==", + "version": "5.11.9", + "resolved": "https://registry.npmjs.org/@mui/system/-/system-5.11.9.tgz", + "integrity": "sha512-h6uarf+l3FO6l75Nf7yO+qDGrIoa1DM9nAMCUFZQsNCDKOInRzcptnm8M1w/Z3gVetfeeGoIGAYuYKbft6KZZA==", "dependencies": { - "@babel/runtime": "^7.20.7", - "@mui/private-theming": "^5.11.7", - "@mui/styled-engine": "^5.11.0", + "@babel/runtime": "^7.20.13", + "@mui/private-theming": "^5.11.9", + "@mui/styled-engine": "^5.11.9", "@mui/types": "^7.2.3", - "@mui/utils": "^5.11.7", + "@mui/utils": "^5.11.9", "clsx": "^1.2.1", "csstype": "^3.1.1", "prop-types": "^15.8.1" @@ -3301,11 +3289,11 @@ } }, "node_modules/@mui/utils": { - "version": "5.11.7", - "resolved": "https://registry.npmjs.org/@mui/utils/-/utils-5.11.7.tgz", - "integrity": "sha512-8uyNDeVHZA804Ego20Erv8TpxlbqTe/EbhTI2H1UYr4/RiIbBprat8W4Qqr2UQIsC/b3DLz+0RQ6R/E5BxEcLA==", + "version": "5.11.9", + "resolved": "https://registry.npmjs.org/@mui/utils/-/utils-5.11.9.tgz", + "integrity": "sha512-eOJaqzcEs4qEwolcvFAmXGpln+uvouvOS9FUX6Wkrte+4I8rZbjODOBDVNlK+V6/ziTfD4iNKC0G+KfOTApbqg==", "dependencies": { - "@babel/runtime": "^7.20.7", + "@babel/runtime": "^7.20.13", "@types/prop-types": "^15.7.5", "@types/react-is": "^16.7.1 || ^17.0.0", "prop-types": "^15.8.1", @@ -3775,12 +3763,12 @@ } }, "node_modules/@table-library/react-table-library": { - "version": "4.0.24", - "resolved": "https://registry.npmjs.org/@table-library/react-table-library/-/react-table-library-4.0.24.tgz", - "integrity": "sha512-tOeKermNhSDKGVvzBlF8gtLVWl+lWbCHk0XH/7s1ybZ9XI8TXpogzXavyRfObGFAIyeazr7Qy5bWGWnE4uueUg==", + "version": "4.0.25", + "resolved": "https://registry.npmjs.org/@table-library/react-table-library/-/react-table-library-4.0.25.tgz", + "integrity": "sha512-3XQg+5R+TmVxXwy4knVfqnk9Jv8sCmZVo9M3Lj7cXYsWi3eGsUqXOpio29m1JU1H6QIcZ32C+ZOr+SJXXS+MMA==", "dependencies": { "clsx": "1.1.1", - "react-virtualized-auto-sizer": "1.0.6", + "react-virtualized-auto-sizer": "1.0.7", "react-window": "1.8.7" }, "peerDependencies": { @@ -3797,18 +3785,6 @@ "node": ">=6" } }, - "node_modules/@table-library/react-table-library/node_modules/react-virtualized-auto-sizer": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/react-virtualized-auto-sizer/-/react-virtualized-auto-sizer-1.0.6.tgz", - "integrity": "sha512-7tQ0BmZqfVF6YYEWcIGuoR3OdYe8I/ZFbNclFlGOC3pMqunkYF/oL30NCjSGl9sMEb17AnzixDz98Kqc3N76HQ==", - "engines": { - "node": ">8.0.0" - }, - "peerDependencies": { - "react": "^15.3.0 || ^16.0.0-alpha || ^17.0.0", - "react-dom": "^15.3.0 || ^16.0.0-alpha || ^17.0.0" - } - }, "node_modules/@tootallnate/once": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", @@ -4008,9 +3984,9 @@ "integrity": "sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA==" }, "node_modules/@types/node": { - "version": "18.11.19", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.19.tgz", - "integrity": "sha512-YUgMWAQBWLObABqrvx8qKO1enAvBUdjZOAWQ5grBAkp5LQv45jBvYKZ3oFS9iKRCQyFjqw6iuEa1vmFqtxYLZw==" + "version": "18.14.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.14.0.tgz", + "integrity": "sha512-5EWrvLmglK+imbCJY0+INViFWUHg1AHel1sq4ZVSfdcNqGy9Edv3UB9IIzzg+xPaUcAgZYcfVs2fBcwDeZzU0A==" }, "node_modules/@types/parse-json": { "version": "4.0.0", @@ -4043,9 +4019,9 @@ "integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==" }, "node_modules/@types/react": { - "version": "18.0.27", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.27.tgz", - "integrity": "sha512-3vtRKHgVxu3Jp9t718R9BuzoD4NcQ8YJ5XRzsSKxNDiDonD2MXIT1TmSkenxuCycZJoQT5d2vE8LwWJxBC1gmA==", + "version": "18.0.28", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.28.tgz", + "integrity": "sha512-RD0ivG1kEztNBdoAK7lekI9M+azSnitIn85h4iOiaLjaTrMjzslhaqCGaI4IyCJ1RljWiLCEu4jyrLLgqxBTew==", "dependencies": { "@types/prop-types": "*", "@types/scheduler": "*", @@ -4053,9 +4029,9 @@ } }, "node_modules/@types/react-dom": { - "version": "18.0.10", - "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.0.10.tgz", - "integrity": "sha512-E42GW/JA4Qv15wQdqJq8DL4JhNpB3prJgjgapN3qJT9K2zO5IIAQh4VXvCEDupoqAwnz0cY4RlXeC/ajX5SFHg==", + "version": "18.0.11", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.0.11.tgz", + "integrity": "sha512-O38bPbI2CWtgw/OoQoY+BRelw7uysmXbWvw3nLWO21H1HSh+GOlqPuXshJfjmpNlKiiSDG9cc1JZAaMmVdcTlw==", "dependencies": { "@types/react": "*" } @@ -5077,9 +5053,9 @@ } }, "node_modules/axios": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.3.2.tgz", - "integrity": "sha512-1M3O703bYqYuPhbHeya5bnhpYVsDDRyQSabNja04mZtboLNSuZ4YrltestrLXfHgmzua4TpUqRiVKbiQuo2epw==", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.3.3.tgz", + "integrity": "sha512-eYq77dYIFS77AQlhzEL937yUBSepBfPIe8FcgEDN35vMNZKMrs81pgnyrQpwfy4NF4b4XWX1Zgx7yX+25w8QJA==", "dependencies": { "follow-redirects": "^1.15.0", "form-data": "^4.0.0", @@ -15031,6 +15007,18 @@ "react-dom": ">=16.6.0" } }, + "node_modules/react-virtualized-auto-sizer": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/react-virtualized-auto-sizer/-/react-virtualized-auto-sizer-1.0.7.tgz", + "integrity": "sha512-Mxi6lwOmjwIjC1X4gABXMJcKHsOo0xWl3E3ugOgufB8GJU+MqrtY35aBuvCYv/razQ1Vbp7h1gWJjGjoNN5pmA==", + "engines": { + "node": ">8.0.0" + }, + "peerDependencies": { + "react": "^15.3.0 || ^16.0.0-alpha || ^17.0.0 || ^18.0.0-rc", + "react-dom": "^15.3.0 || ^16.0.0-alpha || ^17.0.0 || ^18.0.0-rc" + } + }, "node_modules/react-window": { "version": "1.8.7", "resolved": "https://registry.npmjs.org/react-window/-/react-window-1.8.7.tgz", @@ -16790,9 +16778,9 @@ } }, "node_modules/typesafe-i18n": { - "version": "5.24.0", - "resolved": "https://registry.npmjs.org/typesafe-i18n/-/typesafe-i18n-5.24.0.tgz", - "integrity": "sha512-GGIV+x+Azs+uVe1940ZX3MtIKSN0eXrO/x1Z7d0B/FO610evlmTEBIIYIHFWvjhZJslty11INedwRkZKSDVwTQ==", + "version": "5.24.1", + "resolved": "https://registry.npmjs.org/typesafe-i18n/-/typesafe-i18n-5.24.1.tgz", + "integrity": "sha512-CN5UcrRoqLZZXzJuhlg02hCCQNdOIprU/NQmT+p0S4tsGyl8330oSygev9RLibxpj4EyqThqG7cX8mNGl41c6g==", "bin": { "typesafe-i18n": "cli/typesafe-i18n.mjs" }, diff --git a/interface/package.json b/interface/package.json index 124c768f0..3ed2c27c3 100644 --- a/interface/package.json +++ b/interface/package.json @@ -4,19 +4,19 @@ "private": true, "proxy": "http://localhost:3080", "dependencies": { - "@emotion/react": "^11.10.5", - "@emotion/styled": "^11.10.5", + "@emotion/react": "^11.10.6", + "@emotion/styled": "^11.10.6", "@msgpack/msgpack": "^2.8.0", - "@mui/icons-material": "^5.11.0", - "@mui/material": "^5.11.7", - "@table-library/react-table-library": "4.0.24", + "@mui/icons-material": "^5.11.9", + "@mui/material": "^5.11.9", + "@table-library/react-table-library": "4.0.25", "@types/lodash": "^4.14.191", - "@types/node": "^18.11.19", - "@types/react": "^18.0.27", - "@types/react-dom": "^18.0.10", + "@types/node": "^18.14.0", + "@types/react": "^18.0.28", + "@types/react-dom": "^18.0.11", "@types/react-router-dom": "^5.3.3", "async-validator": "^4.2.5", - "axios": "^1.3.2", + "axios": "^1.3.3", "jwt-decode": "^3.1.2", "lodash": "^4.17.21", "notistack": "^2.0.8", @@ -28,7 +28,7 @@ "react-router-dom": "^6.8.1", "react-scripts": "5.0.1", "sockette": "^2.0.6", - "typesafe-i18n": "^5.24.0", + "typesafe-i18n": "^5.24.1", "typescript": "^4.9.5" }, "scripts": { diff --git a/mock-api/package-lock.json b/mock-api/package-lock.json index 5eb19c0ba..83c29194c 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.12.0" + "ws": "^8.12.1" } }, "node_modules/@msgpack/msgpack": { @@ -1015,9 +1015,9 @@ } }, "node_modules/ws": { - "version": "8.12.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.12.0.tgz", - "integrity": "sha512-kU62emKIdKVeEIOIKVegvqpXMSTAMLJozpHZaJNDYqBjzlSYXQGviYwN1osDLJ9av68qHd4a2oSjd7yD4pacig==", + "version": "8.12.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.12.1.tgz", + "integrity": "sha512-1qo+M9Ba+xNhPB+YTWUlK6M17brTut5EXbcBaMRN5pH5dFrXz7lzz1ChFSUq3bOUl8yEvSenhHmYUNJxFzdJew==", "engines": { "node": ">=10.0.0" }, diff --git a/mock-api/package.json b/mock-api/package.json index 92ef1aa29..b5f145bcc 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.12.0" + "ws": "^8.12.1" } } From e60048f5fb3cd77cdfedbeae2b7b5a402a9ba75f Mon Sep 17 00:00:00 2001 From: Proddy Date: Sun, 19 Feb 2023 11:27:58 +0100 Subject: [PATCH 2/5] v3.5.1 --- src/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h b/src/version.h index 0c98cd5fc..bebf4cc28 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define EMSESP_APP_VERSION "3.6.0-dev.0" +#define EMSESP_APP_VERSION "3.5.1-dev.0" From 558e48f671f5cb865c40b751c3b1ae61853c25be Mon Sep 17 00:00:00 2001 From: Proddy Date: Sun, 19 Feb 2023 11:28:08 +0100 Subject: [PATCH 3/5] update gh issue template --- .github/ISSUE_TEMPLATE/bug_report.md | 61 ++++++++++++------- .github/ISSUE_TEMPLATE/config.yml | 11 ++++ .github/ISSUE_TEMPLATE/feature_request.md | 26 -------- .../questions---troubleshooting.md | 29 --------- 4 files changed, 49 insertions(+), 78 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/config.yml delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.md delete mode 100644 .github/ISSUE_TEMPLATE/questions---troubleshooting.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 7a62dcb07..b5655ee60 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,35 +1,50 @@ --- -name: Bug report -about: Create a report to help us improve -title: '' -labels: bug -assignees: '' - +name: Problem Report +about: Create a Report to help us improve --- -*Before creating a new issue please check that you have:* + -**Bug description** -*A clear and concise description of what the bug is. Mention which EMS-ESP version you're using.* +### PROBLEM DESCRIPTION -**Steps to reproduce** -*Steps to reproduce the behavior.* +_A clear and concise description of what the problem is._ -**Expected behavior** -*A clear and concise description of what you expected to happen.* +### REQUESTED INFORMATION -**Screenshots** -*If applicable, add screenshots to help explain your problem.* +_Make sure your have performed every step and checked the applicable boxes before submitting your issue. Thank you!_ -**Device information** -*Copy-paste here the information as it is outputted by the device. You can get this information by from http://ems-esp.local/api/system* +- [ ] Searched the problem in [issues](https://github.com/emsesp/EMS-ESP32/issues) +- [ ] Searched the problem in [discussions](https://github.com/emsesp/EMS-ESP32/discussions) +- [ ] Searched the problem in the [docs](https://emsesp.github.io/docs/Troubleshooting/) +- [ ] Searched the problem in the [chat](https://discord.gg/3J3GgnzpyT) +- [ ] Provide the output of http://ems-esp.local/api/system : -**Additional context** -*Add any other context about the problem here.* +```lua + System information output here: + + +``` + +### TO REPRODUCE + +_Steps to reproduce the behavior:_ + +### EXPECTED BEHAVIOUR + +_A clear and concise description of what you expected to happen._ + +### SCREENSHOTS + +_If applicable, add screenshots to help explain your problem._ + +### ADDITIONAL CONTEXT + +_Add any other context about the problem here._ + +**(Please, remember to close the issue when the problem has been addressed)** diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 000000000..5058ab586 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,11 @@ +blank_issues_enabled: false +contact_links: + - name: EMS-ESP Docs + url: https://emsesp.github.io/docs/ + about: All the information related to EMS-ESP. + - name: EMS-ESP Discussions and Support + url: https://github.com/emsesp/EMS-ESP32/discussions + about: EMS-ESP usage Questions, Feature Requests and Projects. + - name: EMS-ESP Users Chat + url: https://discord.gg/3J3GgnzpyT + about: Chat for feedback, questions and troubleshooting. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index 696d63d8c..000000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: '' -labels: enhancement -assignees: '' - ---- - -*Before creating a new feature request please check that you have searched the existing [issues](https://github.com/emsesp/EMS-ESP32/issues) (both open and closed)* - -*Completing this template will help developers and contributors evaluating the feature. If the information provided is not enough the issue will likely be closed.* - -*You can now remove this line and the above ones. Text in italic is meant to be replaced by your own words. If any of the sections below are not relevant to the request then you can delete them.* - -**Is your feature request related to a problem? Please describe.** -*A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]* - -**Describe the solution you'd like** -*A clear and concise description of what you want to happen.* - -**Describe alternatives you've considered** -*A clear and concise description of any alternative solutions or features you've considered.* - -**Additional context** -*Add any other context or screenshots about the feature request here.* diff --git a/.github/ISSUE_TEMPLATE/questions---troubleshooting.md b/.github/ISSUE_TEMPLATE/questions---troubleshooting.md deleted file mode 100644 index 0e8175477..000000000 --- a/.github/ISSUE_TEMPLATE/questions---troubleshooting.md +++ /dev/null @@ -1,29 +0,0 @@ ---- -name: Questions & Troubleshooting -about: Anything not a bug or feature request -title: '' -labels: question -assignees: '' - ---- - -*Before creating a new issue please check that you have:* - -* *searched the existing [issues](https://github.com/emsesp/EMS-ESP32/issues) (both open and closed)* -* *searched the [documentation help section](https://emsesp.github.io/docs)* - -*Completing this template will help developers and contributors help you. Try to be as specific and extensive as possible. If the information provided is not enough the issue will likely be closed.* - -*You can now remove this line and the above ones. Text in italic is meant to be replaced by your own words. If any of the sections below are not relevant to the issue (for instance, the screenshots) then you can delete them.* - -**Question** -*A clear and concise description of what the problem/doubt is.* - -**Screenshots** -*If applicable, add screenshots to help explain your problem.* - -**Device information** -*Copy-paste here the information as it is outputted by the device. You can get this information from http://ems-esp.local/api/system* - -**Additional context** -*Add any other context about the problem here.* From 2f44beccc264866553e37020abff50b8785d3aa7 Mon Sep 17 00:00:00 2001 From: Proddy Date: Sun, 19 Feb 2023 11:29:03 +0100 Subject: [PATCH 4/5] typesafe-i18@5.24.1 --- interface/.typesafe-i18n.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/interface/.typesafe-i18n.json b/interface/.typesafe-i18n.json index fd00af250..e90733f75 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.24.0/schema/typesafe-i18n.json" -} + "adapter": "react", + "baseLocale": "pl", + "$schema": "https://unpkg.com/typesafe-i18n@5.24.1/schema/typesafe-i18n.json" +} \ No newline at end of file From 971df73f130f845aedd1942e9ec4bf6a734f19e9 Mon Sep 17 00:00:00 2001 From: pswid <78219494+pswid@users.noreply.github.com> Date: Wed, 22 Feb 2023 13:16:05 +0100 Subject: [PATCH 5/5] added "availability" section in HA Discovery This will allow to not remove discovery topics during each ems-esp restart (MQTT init), so it can solve issue #910. After applying this fix (and removing from the code commands that delete discovery topics) HA no longer reports errors/warnings in the log. I'm testing if for over a week. Now it is enough to delete discovery topics only when it is really needed (e.g. the entity has been removed by customization, discovery prefix has been changed or the HA option has been disabled in the configuration). --- interface/src/i18n/pl/index.ts | 4 +- src/analogsensor.cpp | 19 ++++--- src/dallassensor.cpp | 19 ++++--- src/mqtt.cpp | 94 ++++++++++++++++++++++++++-------- src/mqtt.h | 3 ++ src/shower.cpp | 7 ++- 6 files changed, 109 insertions(+), 37 deletions(-) diff --git a/interface/src/i18n/pl/index.ts b/interface/src/i18n/pl/index.ts index 081b759b1..2689e77bb 100644 --- a/interface/src/i18n/pl/index.ts +++ b/interface/src/i18n/pl/index.ts @@ -157,7 +157,7 @@ const pl: BaseTranslation = { CUSTOMIZATIONS_HELP_3: 'zablokuj akcje zapisu', CUSTOMIZATIONS_HELP_4: 'wyklucz z MQTT i API', CUSTOMIZATIONS_HELP_5: 'ukryj na pulpicie', - CUSTOMIZATIONS_HELP_6: 'remove from memory', + CUSTOMIZATIONS_HELP_6: 'usuń z pamięci', SELECT_DEVICE: 'wybierz urządzenie', SET_ALL: 'Ustaw wszystko jako', OPTIONS: 'Opcje', @@ -202,7 +202,7 @@ const pl: BaseTranslation = { CPU_FREQ: 'Taktowanie CPU', HEAP: 'HEAP (wolne / maksymalny przydział)', PSRAM: 'PSRAM (rozmiar / wolne)', - FLASH: 'Flash (rozmiar / taktowanie)', + FLASH: 'FLASH (rozmiar / taktowanie)', APPSIZE: 'Aplikacja (wykorzystane / wolne)', FILESYSTEM: 'System plików (wykorzystane / wolne)', BUFFER_SIZE: 'Maksymalna pojemność bufora (ilość wpisów)', diff --git a/src/analogsensor.cpp b/src/analogsensor.cpp index 4ca24d81f..18dd9e9ea 100644 --- a/src/analogsensor.cpp +++ b/src/analogsensor.cpp @@ -447,13 +447,16 @@ void AnalogSensor::publish_values(const bool force) { snprintf(stat_t, sizeof(stat_t), "%s/analogsensor_data", Mqtt::base().c_str()); // use base path config["stat_t"] = stat_t; - char str[50]; + char val_obj[50]; + char val_cond[65]; if (Mqtt::is_nested()) { - snprintf(str, sizeof(str), "{{value_json['%02d'].value}}", sensor.gpio()); + snprintf(val_obj, sizeof(val_obj), "value_json['%02d'].value", sensor.gpio()); + snprintf(val_cond, sizeof(val_cond), "value_json['%02d'] is defined", sensor.gpio()); } else { - snprintf(str, sizeof(str), "{{value_json['%s']}", sensor.name().c_str()); + snprintf(val_obj, sizeof(val_obj), "value_json['%s']", sensor.name().c_str()); + snprintf(val_cond, sizeof(val_cond), "%s is defined", val_obj); } - config["val_tpl"] = str; + config["val_tpl"] = (std::string) "{{" + val_obj + " if " + val_cond + "}}"; char uniq_s[70]; if (Mqtt::entity_format() == 2) { @@ -465,8 +468,9 @@ void AnalogSensor::publish_values(const bool force) { config["object_id"] = uniq_s; config["uniq_id"] = uniq_s; // same as object_id - snprintf(str, sizeof(str), "%s", sensor.name().c_str()); - config["name"] = str; + char name[50]; + snprintf(name, sizeof(name), "%s", sensor.name().c_str()); + config["name"] = name; if (sensor.uom() != DeviceValueUOM::NONE) { config["unit_of_meas"] = EMSdevice::uom_to_string(sensor.uom()); @@ -476,6 +480,9 @@ void AnalogSensor::publish_values(const bool force) { JsonArray ids = dev.createNestedArray("ids"); ids.add("ems-esp"); + // add "availability" section + Mqtt::add_avty_to_doc(stat_t, config.as(), val_cond); + char topic[Mqtt::MQTT_TOPIC_MAX_SIZE]; snprintf(topic, sizeof(topic), "sensor/%s/analogsensor_%02d/config", Mqtt::basename().c_str(), sensor.gpio()); diff --git a/src/dallassensor.cpp b/src/dallassensor.cpp index 60fbd1468..92cf74097 100644 --- a/src/dallassensor.cpp +++ b/src/dallassensor.cpp @@ -514,13 +514,16 @@ void DallasSensor::publish_values(const bool force) { config["unit_of_meas"] = EMSdevice::uom_to_string(DeviceValueUOM::DEGREES); - char str[50]; + char val_obj[50]; + char val_cond[65]; if (Mqtt::is_nested()) { - snprintf(str, sizeof(str), "{{value_json['%s'].temp}}", sensor.id().c_str()); + snprintf(val_obj, sizeof(val_obj), "value_json['%s'].temp", sensor.id().c_str()); + snprintf(val_cond, sizeof(val_cond), "value_json['%s'] is defined", sensor.id().c_str()); } else { - snprintf(str, sizeof(str), "{{value_json['%s']}}", sensor.name().c_str()); + snprintf(val_obj, sizeof(val_obj), "value_json['%s']", sensor.name().c_str()); + snprintf(val_cond, sizeof(val_cond), "%s is defined", val_obj); } - config["val_tpl"] = str; + config["val_tpl"] = (std::string) "{{" + val_obj + " if " + val_cond + "}}"; char uniq_s[70]; if (Mqtt::entity_format() == 2) { @@ -532,13 +535,17 @@ void DallasSensor::publish_values(const bool force) { config["object_id"] = uniq_s; config["uniq_id"] = uniq_s; // same as object_id - snprintf(str, sizeof(str), "%s", sensor.name().c_str()); - config["name"] = str; + char name[50]; + snprintf(name, sizeof(name), "%s", sensor.name().c_str()); + config["name"] = name; JsonObject dev = config.createNestedObject("dev"); JsonArray ids = dev.createNestedArray("ids"); ids.add("ems-esp"); + // add "availability" section + Mqtt::add_avty_to_doc(stat_t, config.as(), val_cond); + char topic[Mqtt::MQTT_TOPIC_MAX_SIZE]; // use '_' as HA doesn't like '-' in the topic name std::string sensorid = sensor.id(); diff --git a/src/mqtt.cpp b/src/mqtt.cpp index 9afa18c29..19b1734c5 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -1074,6 +1074,8 @@ void Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev const char * sc_ha = "stat_cla"; // state class const char * uom_ha = "unit_of_meas"; // unit of measure + char sample_val[30] = "0"; // sample, correct(!) entity value, used only to prevent warning/error in HA if real value is not published yet + // handle commands, which are device entities that are writable // we add the command topic parameter // note: there is no way to handle strings in HA so datetimes (e.g. set_datetime, set_holiday, set_wwswitchtime etc) are excluded @@ -1093,6 +1095,7 @@ void Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev for (uint8_t i = 0; i < options_size; i++) { option_list.add(Helpers::translated_word(options[i])); } + snprintf(sample_val, sizeof(sample_val), "'%s'", Helpers::translated_word(options[0])); } else if (type != DeviceValueType::STRING && type != DeviceValueType::BOOL) { // Must be Numeric.... doc["mode"] = "box"; // auto, slider or box @@ -1109,6 +1112,7 @@ void Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev if (dv_set_min != 0 || dv_set_max != 0) { doc["min"] = dv_set_min; doc["max"] = dv_set_max; + snprintf(sample_val, sizeof(sample_val), "%i", dv_set_min); } // set icons @@ -1146,17 +1150,15 @@ void Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev // value template // if its nested mqtt format then use the appended entity name, otherwise take the original name - char val_tpl[75]; - if (is_nested()) { - if (tag >= DeviceValueTAG::TAG_HC1) { - snprintf(val_tpl, sizeof(val_tpl), "{{value_json.%s.%s}}", EMSdevice::tag_to_mqtt(tag).c_str(), entity); - } else { - snprintf(val_tpl, sizeof(val_tpl), "{{value_json.%s}}", entity); - } + char val_obj[100]; + char val_cond[200]; + if (is_nested() && tag >= DeviceValueTAG::TAG_HC1) { + snprintf(val_obj, sizeof(val_obj), "value_json.%s.%s", EMSdevice::tag_to_mqtt(tag).c_str(), entity); + snprintf(val_cond, sizeof(val_cond), "value_json.%s is defined and %s is defined", EMSdevice::tag_to_mqtt(tag).c_str(), val_obj); } else { - snprintf(val_tpl, sizeof(val_tpl), "{{value_json.%s}}", entity); + snprintf(val_obj, sizeof(val_obj), "value_json.%s", entity); + snprintf(val_cond, sizeof(val_cond), "%s is defined", val_obj); } - doc["val_tpl"] = val_tpl; // special case to handle booleans // applies to both Binary Sensor (read only) and a Switch (for a command) @@ -1165,6 +1167,7 @@ void Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev if (EMSESP::system_.bool_format() == BOOL_FORMAT_TRUEFALSE) { doc["pl_on"] = true; doc["pl_off"] = false; + snprintf(sample_val, sizeof(sample_val), "false"); } else if (EMSESP::system_.bool_format() == BOOL_FORMAT_10) { doc["pl_on"] = 1; doc["pl_off"] = 0; @@ -1172,6 +1175,7 @@ void Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev char result[12]; doc["pl_on"] = Helpers::render_boolean(result, true); doc["pl_off"] = Helpers::render_boolean(result, false); + snprintf(sample_val, sizeof(sample_val), "'%s'", Helpers::render_boolean(result, false)); } doc[sc_ha] = F_(measurement); //do we want this??? } else { @@ -1189,6 +1193,8 @@ void Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev } } + doc["val_tpl"] = (std::string) "{{" + val_obj + " if " + val_cond + " else " + sample_val + "}}"; + // this next section is adding the state class, device class and sometimes the icon // used for Sensor and Binary Sensor Entities in HA if (set_ha_classes) { @@ -1284,6 +1290,9 @@ void Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev // add the dev json object to the end doc["dev"] = dev_json; + // add "availability" section + add_avty_to_doc(stat_t, doc.as(), val_cond); + publish_ha(topic, doc.as()); } @@ -1295,6 +1304,9 @@ void Mqtt::publish_ha_climate_config(const uint8_t tag, const bool has_roomtemp, char hc_mode_s[30]; char seltemp_s[30]; char currtemp_s[30]; + char hc_mode_cond[70]; + char seltemp_cond[70]; + char currtemp_cond[170]; char mode_str_tpl[400]; char name_s[10]; char uniq_id_s[60]; @@ -1312,24 +1324,31 @@ void Mqtt::publish_ha_climate_config(const uint8_t tag, const bool has_roomtemp, if (Mqtt::is_nested()) { // nested format snprintf(hc_mode_s, sizeof(hc_mode_s), "value_json.hc%d.mode", hc_num); - snprintf(seltemp_s, sizeof(seltemp_s), "{{value_json.hc%d.seltemp}}", hc_num); + snprintf(hc_mode_cond, sizeof(hc_mode_cond), "value_json.hc%d is undefined or %s is undefined", hc_num, hc_mode_s); + snprintf(seltemp_s, sizeof(seltemp_s), "value_json.hc%d.seltemp", hc_num); + snprintf(seltemp_cond, sizeof(seltemp_cond), "value_json.hc%d is defined and %s is defined", hc_num, seltemp_s); if (has_roomtemp) { - snprintf(currtemp_s, sizeof(currtemp_s), "{{value_json.hc%d.currtemp}}", hc_num); + snprintf(currtemp_s, sizeof(currtemp_s), "value_json.hc%d.currtemp", hc_num); + snprintf(currtemp_cond, sizeof(currtemp_cond), "value_json.hc%d is defined and %s is defined", hc_num, currtemp_s); } snprintf(topic_t, sizeof(topic_t), "~/%s", Mqtt::tag_to_topic(EMSdevice::DeviceType::THERMOSTAT, DeviceValueTAG::TAG_NONE).c_str()); } else { // single format snprintf(hc_mode_s, sizeof(hc_mode_s), "value_json.mode"); - snprintf(seltemp_s, sizeof(seltemp_s), "{{value_json.seltemp}}"); + snprintf(hc_mode_cond, sizeof(hc_mode_cond), "%s is undefined", hc_mode_s); + snprintf(seltemp_s, sizeof(seltemp_s), "value_json.seltemp"); + snprintf(seltemp_cond, sizeof(seltemp_cond), "%s is defined", seltemp_s); if (has_roomtemp) { - snprintf(currtemp_s, sizeof(currtemp_s), "{{value_json.currtemp}}"); + snprintf(currtemp_s, sizeof(currtemp_s), "value_json.currtemp"); + snprintf(currtemp_cond, sizeof(currtemp_cond), "%s is defined", currtemp_s); } snprintf(topic_t, sizeof(topic_t), "~/%s", Mqtt::tag_to_topic(EMSdevice::DeviceType::THERMOSTAT, DeviceValueTAG::TAG_HC1 + hc_num - 1).c_str()); } snprintf(mode_str_tpl, sizeof(mode_str_tpl), - "{%%if %s=='manual'%%}heat{%%elif %s=='day'%%}heat{%%elif %s=='night'%%}off{%%elif %s=='off'%%}off{%%else%%}auto{%%endif%%}", + "{%%if %s%%}off{%%elif %s=='manual'%%}heat{%%elif %s=='day'%%}heat{%%elif %s=='night'%%}off{%%elif %s=='off'%%}off{%%else%%}auto{%%endif%%}", + hc_mode_cond, hc_mode_s, hc_mode_s, hc_mode_s, @@ -1346,7 +1365,7 @@ void Mqtt::publish_ha_climate_config(const uint8_t tag, const bool has_roomtemp, snprintf(temp_cmd_s, sizeof(temp_cmd_s), "~/thermostat/hc%d/seltemp", hc_num); snprintf(mode_cmd_s, sizeof(temp_cmd_s), "~/thermostat/hc%d/mode", hc_num); - StaticJsonDocument doc; + StaticJsonDocument doc; doc["~"] = mqtt_base_; doc["uniq_id"] = uniq_id_s; @@ -1356,12 +1375,10 @@ void Mqtt::publish_ha_climate_config(const uint8_t tag, const bool has_roomtemp, doc["mode_stat_tpl"] = mode_str_tpl; doc["temp_cmd_t"] = temp_cmd_s; doc["temp_stat_t"] = topic_t; - doc["temp_stat_tpl"] = seltemp_s; - doc["mode_cmd_t"] = mode_cmd_s; - + doc["temp_stat_tpl"] = (std::string) "{{" + seltemp_s + " if " + seltemp_cond + " else 0}}"; if (has_roomtemp) { doc["curr_temp_t"] = topic_t; - doc["curr_temp_tpl"] = currtemp_s; + doc["curr_temp_tpl"] = (std::string) "{{" + currtemp_s + " if " + currtemp_cond + " else 0}}"; } doc["min_temp"] = Helpers::render_value(min_s, min, 0, EMSESP::system_.fahrenheit() ? 2 : 0); @@ -1369,8 +1386,8 @@ void Mqtt::publish_ha_climate_config(const uint8_t tag, const bool has_roomtemp, doc["temp_step"] = "0.5"; // the HA climate component only responds to auto, heat and off - JsonArray modes = doc.createNestedArray("modes"); - + doc["mode_cmd_t"] = mode_cmd_s; + JsonArray modes = doc.createNestedArray("modes"); modes.add("auto"); modes.add("heat"); modes.add("off"); @@ -1379,6 +1396,9 @@ void Mqtt::publish_ha_climate_config(const uint8_t tag, const bool has_roomtemp, JsonArray ids = dev.createNestedArray("ids"); ids.add("ems-esp-thermostat"); + // add "availability" section + add_avty_to_doc(topic_t, doc.as(), seltemp_cond, has_roomtemp ? currtemp_cond : nullptr, hc_mode_cond); + publish_ha(topic, doc.as()); // publish the config payload with retain flag } @@ -1401,4 +1421,36 @@ std::string Mqtt::tag_to_topic(uint8_t device_type, uint8_t tag) { } } +// adds "availability" section to HA Discovery config +void Mqtt::add_avty_to_doc(const char * state_t, const JsonObject & doc, const char * cond1, const char * cond2, const char * negcond) { + const char * tpl_draft = "{{'online' if %s else 'offline'}}"; + char tpl[150]; + JsonArray avty = doc.createNestedArray("avty"); + + StaticJsonDocument<512> avty_json; + + snprintf(tpl, sizeof(tpl), "%s/status", mqtt_base_.c_str()); + avty_json["t"] = tpl; + snprintf(tpl, sizeof(tpl), tpl_draft, "value == 'online'"); + avty_json["val_tpl"] = tpl; + avty.add(avty_json); + + avty_json["t"] = state_t; + snprintf(tpl, sizeof(tpl), tpl_draft, cond1 == nullptr ? "value is defined" : cond1); + avty_json["val_tpl"] = tpl; + avty.add(avty_json); + if (cond2 != nullptr) { + snprintf(tpl, sizeof(tpl), tpl_draft, cond2); + avty_json["val_tpl"] = tpl; + avty.add(avty_json); + } + if (negcond != nullptr) { + snprintf(tpl, sizeof(tpl), "{{'offline' if %s else 'online'}}", negcond); + avty_json["val_tpl"] = tpl; + avty.add(avty_json); + } + + doc["avty_mode"] = "all"; +} + } // namespace emsesp diff --git a/src/mqtt.h b/src/mqtt.h index 1bc46f390..a3a1405fb 100644 --- a/src/mqtt.h +++ b/src/mqtt.h @@ -240,6 +240,9 @@ class Mqtt { static std::string tag_to_topic(uint8_t device_type, uint8_t tag); + static void + add_avty_to_doc(const char * state_t, const JsonObject & doc, const char * cond1 = nullptr, const char * cond2 = nullptr, const char * negcond = nullptr); + struct QueuedMqttMessage { const uint32_t id_; const std::shared_ptr content_; diff --git a/src/shower.cpp b/src/shower.cpp index 4f3d1fa5e..3bfc417fe 100644 --- a/src/shower.cpp +++ b/src/shower.cpp @@ -168,8 +168,8 @@ void Shower::set_shower_state(bool state, bool force) { doc["stat_t"] = stat_t; if (EMSESP::system_.bool_format() == BOOL_FORMAT_TRUEFALSE) { - doc["pl_on"] = true; - doc["pl_off"] = false; + doc["pl_on"] = "true"; + doc["pl_off"] = "false"; } else if (EMSESP::system_.bool_format() == BOOL_FORMAT_10) { doc["pl_on"] = 1; doc["pl_off"] = 0; @@ -183,6 +183,9 @@ void Shower::set_shower_state(bool state, bool force) { JsonArray ids = dev.createNestedArray("ids"); ids.add("ems-esp"); + // add "availability" section + Mqtt::add_avty_to_doc(stat_t, doc.as()); + char topic[Mqtt::MQTT_TOPIC_MAX_SIZE]; snprintf(topic, sizeof(topic), "binary_sensor/%s/shower_active/config", Mqtt::basename().c_str()); Mqtt::publish_ha(topic, doc.as()); // publish the config payload with retain flag