From ab58a3dfd32f3536bb07f06ceca6b984bc0a8a48 Mon Sep 17 00:00:00 2001 From: Proddy Date: Wed, 3 Jan 2024 22:55:44 +0100 Subject: [PATCH 01/22] add spacing --- interface/src/framework/system/UploadFileForm.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/interface/src/framework/system/UploadFileForm.tsx b/interface/src/framework/system/UploadFileForm.tsx index c33019df3..e0df328ed 100644 --- a/interface/src/framework/system/UploadFileForm.tsx +++ b/interface/src/framework/system/UploadFileForm.tsx @@ -136,6 +136,7 @@ const UploadFileForm: FC = () => { {LL.UPLOAD_TEXT()}
+
{LL.RESTART_TEXT(1)}.
From 5fcad37fb9e88dfd35a15b2a2002af7e0fb5cd0a Mon Sep 17 00:00:00 2001 From: Proddy Date: Wed, 3 Jan 2024 22:56:03 +0100 Subject: [PATCH 02/22] ok to show devices if no ems connection --- interface/src/project/DashboardDevices.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/project/DashboardDevices.tsx b/interface/src/project/DashboardDevices.tsx index abbb07b18..4fb862693 100644 --- a/interface/src/project/DashboardDevices.tsx +++ b/interface/src/project/DashboardDevices.tsx @@ -420,7 +420,7 @@ const DashboardDevices: FC = () => { )} - {coreData.connected && ( + {coreData.devices.length && ( {(tableList: any) => ( <> From d6856e8a236fd3c68418ffbda7df222cd0bd66f5 Mon Sep 17 00:00:00 2001 From: Proddy Date: Wed, 3 Jan 2024 22:56:16 +0100 Subject: [PATCH 03/22] optimized chunking --- interface/vite.config.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/interface/vite.config.ts b/interface/vite.config.ts index bb76b59ab..b5b69c560 100644 --- a/interface/vite.config.ts +++ b/interface/vite.config.ts @@ -1,4 +1,4 @@ -import { defineConfig } from 'vite'; +import { defineConfig, splitVendorChunkPlugin } from 'vite'; import viteTsconfigPaths from 'vite-tsconfig-paths'; import preact from '@preact/preset-vite'; import viteImagemin from 'vite-plugin-imagemin'; @@ -44,6 +44,7 @@ export default defineConfig(({ command, mode }) => { plugins: [ preact(), viteTsconfigPaths(), + splitVendorChunkPlugin(), { ...viteImagemin({ verbose: false, @@ -112,6 +113,20 @@ export default defineConfig(({ command, mode }) => { nameCache: null, safari10: false, toplevel: false + }, + + rollupOptions: { + output: { + manualChunks(id: string) { + if (id.includes('node_modules')) { + // creating a chunk to react routes deps. Reducing the vendor chunk size + if (id.includes('react-router-dom') || id.includes('@remix-run') || id.includes('react-router')) { + return '@react-router'; + } + return 'vendor'; + } + } + } } } }; From c45fd232272953a6114fc522bccfc0bc616a9adb Mon Sep 17 00:00:00 2001 From: Proddy Date: Wed, 3 Jan 2024 22:56:26 +0100 Subject: [PATCH 04/22] package update --- interface/package.json | 18 +- interface/yarn.lock | 363 +++++++++++++++++++++++++---------------- 2 files changed, 231 insertions(+), 150 deletions(-) diff --git a/interface/package.json b/interface/package.json index 5489c4e60..15f79bc2c 100644 --- a/interface/package.json +++ b/interface/package.json @@ -21,16 +21,16 @@ }, "dependencies": { "@alova/adapter-xhr": "^1.0.2", - "@babel/core": "^7.23.6", + "@babel/core": "^7.23.7", "@emotion/react": "^11.11.3", "@emotion/styled": "^11.11.0", - "@mui/icons-material": "^5.15.2", - "@mui/material": "^5.15.2", + "@mui/icons-material": "^5.15.3", + "@mui/material": "^5.15.3", "@table-library/react-table-library": "4.1.7", "@types/imagemin": "^8.0.5", "@types/lodash-es": "^4.17.12", - "@types/node": "^20.10.5", - "@types/react": "^18.2.45", + "@types/node": "^20.10.6", + "@types/react": "^18.2.46", "@types/react-dom": "^18.2.18", "@types/react-router-dom": "^5.3.3", "alova": "^2.16.2", @@ -51,9 +51,9 @@ }, "devDependencies": { "@preact/compat": "^17.1.2", - "@preact/preset-vite": "^2.7.0", - "@typescript-eslint/eslint-plugin": "^6.16.0", - "@typescript-eslint/parser": "^6.16.0", + "@preact/preset-vite": "^2.8.1", + "@typescript-eslint/eslint-plugin": "^6.17.0", + "@typescript-eslint/parser": "^6.17.0", "concurrently": "^8.2.2", "eslint": "^8.56.0", "eslint-config-airbnb": "^19.0.4", @@ -72,7 +72,7 @@ "terser": "^5.26.0", "vite": "^5.0.10", "vite-plugin-imagemin": "^0.6.1", - "vite-tsconfig-paths": "^4.2.2" + "vite-tsconfig-paths": "^4.2.3" }, "packageManager": "yarn@4.0.2" } diff --git a/interface/yarn.lock b/interface/yarn.lock index 2164fce85..edde8f336 100644 --- a/interface/yarn.lock +++ b/interface/yarn.lock @@ -86,26 +86,26 @@ __metadata: languageName: node linkType: hard -"@babel/core@npm:^7.23.6": - version: 7.23.6 - resolution: "@babel/core@npm:7.23.6" +"@babel/core@npm:^7.23.7": + version: 7.23.7 + resolution: "@babel/core@npm:7.23.7" dependencies: "@ampproject/remapping": "npm:^2.2.0" "@babel/code-frame": "npm:^7.23.5" "@babel/generator": "npm:^7.23.6" "@babel/helper-compilation-targets": "npm:^7.23.6" "@babel/helper-module-transforms": "npm:^7.23.3" - "@babel/helpers": "npm:^7.23.6" + "@babel/helpers": "npm:^7.23.7" "@babel/parser": "npm:^7.23.6" "@babel/template": "npm:^7.22.15" - "@babel/traverse": "npm:^7.23.6" + "@babel/traverse": "npm:^7.23.7" "@babel/types": "npm:^7.23.6" convert-source-map: "npm:^2.0.0" debug: "npm:^4.1.0" gensync: "npm:^1.0.0-beta.2" json5: "npm:^2.2.3" semver: "npm:^6.3.1" - checksum: a72ba71d2f557d09ff58a5f0846344b9cea9dfcbd7418729a3a74d5b0f37a5ca024942fef4d19f248de751928a1be3d5cb0488746dd8896009dd55b974bb552e + checksum: 956841695ea801c8b4196d01072e6c1062335960715a6fcfd4009831003b526b00627c78b373ed49b1658c3622c71142f7ff04235fe839cac4a1a25ed51b90aa languageName: node linkType: hard @@ -304,14 +304,14 @@ __metadata: languageName: node linkType: hard -"@babel/helpers@npm:^7.23.6": - version: 7.23.6 - resolution: "@babel/helpers@npm:7.23.6" +"@babel/helpers@npm:^7.23.7": + version: 7.23.7 + resolution: "@babel/helpers@npm:7.23.7" dependencies: "@babel/template": "npm:^7.22.15" - "@babel/traverse": "npm:^7.23.6" + "@babel/traverse": "npm:^7.23.7" "@babel/types": "npm:^7.23.6" - checksum: 2a85fd2bcbc15a6c94dbe7b9e94d8920f9de76d164179d6895fee89c4339079d9e3e56f572bf19b5e7d1e6f1997d7fbaeaa686b47d35136852631dfd09e85c2f + checksum: ec07061dc871d406ed82c8757c4d7a510aaf15145799fb0a2c3bd3c72ca101fe82a02dd5f83ca604fbbba5de5408dd731bb1452150562bed4f3b0a2846f81f61 languageName: node linkType: hard @@ -439,9 +439,9 @@ __metadata: languageName: node linkType: hard -"@babel/traverse@npm:^7.23.6": - version: 7.23.6 - resolution: "@babel/traverse@npm:7.23.6" +"@babel/traverse@npm:^7.23.7": + version: 7.23.7 + resolution: "@babel/traverse@npm:7.23.7" dependencies: "@babel/code-frame": "npm:^7.23.5" "@babel/generator": "npm:^7.23.6" @@ -453,7 +453,7 @@ __metadata: "@babel/types": "npm:^7.23.6" debug: "npm:^4.3.1" globals: "npm:^11.1.0" - checksum: ee4434a3ce792ee8956b64d76843caa1dda4779bb621ed9f951dd3551965bf1f292f097011c9730ecbc0b57f02434b1fa5a771610a2ef570726b0df0fc3332d9 + checksum: 3215e59429963c8dac85c26933372cdd322952aa9930e4bc5ef2d0e4bd7a1510d1ecf8f8fd860ace5d4d9fe496d23805a1ea019a86410aee4111de5f63ee84f9 languageName: node linkType: hard @@ -953,7 +953,7 @@ __metadata: languageName: node linkType: hard -"@jridgewell/sourcemap-codec@npm:^1.4.10, @jridgewell/sourcemap-codec@npm:^1.4.14": +"@jridgewell/sourcemap-codec@npm:^1.4.10, @jridgewell/sourcemap-codec@npm:^1.4.14, @jridgewell/sourcemap-codec@npm:^1.4.15": version: 1.4.15 resolution: "@jridgewell/sourcemap-codec@npm:1.4.15" checksum: 89960ac087781b961ad918978975bcdf2051cd1741880469783c42de64239703eab9db5230d776d8e6a09d73bb5e4cb964e07d93ee6e2e7aea5a7d726e865c09 @@ -970,14 +970,14 @@ __metadata: languageName: node linkType: hard -"@mui/base@npm:5.0.0-beta.29": - version: 5.0.0-beta.29 - resolution: "@mui/base@npm:5.0.0-beta.29" +"@mui/base@npm:5.0.0-beta.30": + version: 5.0.0-beta.30 + resolution: "@mui/base@npm:5.0.0-beta.30" dependencies: "@babel/runtime": "npm:^7.23.6" "@floating-ui/react-dom": "npm:^2.0.4" - "@mui/types": "npm:^7.2.11" - "@mui/utils": "npm:^5.15.2" + "@mui/types": "npm:^7.2.12" + "@mui/utils": "npm:^5.15.3" "@popperjs/core": "npm:^2.11.8" clsx: "npm:^2.0.0" prop-types: "npm:^15.8.1" @@ -988,20 +988,20 @@ __metadata: peerDependenciesMeta: "@types/react": optional: true - checksum: a651464968af6ebb775c24d2b9badc735b1d595e526ff7f8181186e6eed0735b14af8324db22a8744039ad79ce6dbb7c62920bb92a57959a66cf8e72d68af9aa + checksum: 55e18d59ac96f5bbfbfdadd907751f5e6a4f74f611b5e99fe5f8002c76fa117b62c159f52ea0f12574a66460d62734082438cff19cb73e3fca9dc22f82f6eaf2 languageName: node linkType: hard -"@mui/core-downloads-tracker@npm:^5.15.2": - version: 5.15.2 - resolution: "@mui/core-downloads-tracker@npm:5.15.2" - checksum: 8c88ac73a1d87c8ce565f6295dcd084c643580848e8f59159402e9db89975263da06305a0e605d3744479e917c2d297319496534bca9df8338e203162f1e7c33 +"@mui/core-downloads-tracker@npm:^5.15.3": + version: 5.15.3 + resolution: "@mui/core-downloads-tracker@npm:5.15.3" + checksum: 002451af1aa555c0163c0ffacde5c15062e0ae0f30b81945e1a0befe7b6c5d14924a2b068b7b5f713c177ee3eecca4fc250d590d11206a6b5465700c399a34d1 languageName: node linkType: hard -"@mui/icons-material@npm:^5.15.2": - version: 5.15.2 - resolution: "@mui/icons-material@npm:5.15.2" +"@mui/icons-material@npm:^5.15.3": + version: 5.15.3 + resolution: "@mui/icons-material@npm:5.15.3" dependencies: "@babel/runtime": "npm:^7.23.6" peerDependencies: @@ -1011,20 +1011,20 @@ __metadata: peerDependenciesMeta: "@types/react": optional: true - checksum: 6dad9fa436889ab89217d428f38b1f7868eb5db0b8aa2b16086f6e81666763767a29db8897e76d078919df7349a149c6e16da1aea1b3ae48ca0b7ee1e0d9d458 + checksum: 2393a9dcd0834cdda728b8ebca5d8f6acbfc34316346aaea257e32961abf7cf578419df196b50223b89b3e2556098aea283786ca4eeedaf58be3d204f499f6bc languageName: node linkType: hard -"@mui/material@npm:^5.15.2": - version: 5.15.2 - resolution: "@mui/material@npm:5.15.2" +"@mui/material@npm:^5.15.3": + version: 5.15.3 + resolution: "@mui/material@npm:5.15.3" dependencies: "@babel/runtime": "npm:^7.23.6" - "@mui/base": "npm:5.0.0-beta.29" - "@mui/core-downloads-tracker": "npm:^5.15.2" - "@mui/system": "npm:^5.15.2" - "@mui/types": "npm:^7.2.11" - "@mui/utils": "npm:^5.15.2" + "@mui/base": "npm:5.0.0-beta.30" + "@mui/core-downloads-tracker": "npm:^5.15.3" + "@mui/system": "npm:^5.15.3" + "@mui/types": "npm:^7.2.12" + "@mui/utils": "npm:^5.15.3" "@types/react-transition-group": "npm:^4.4.10" clsx: "npm:^2.0.0" csstype: "npm:^3.1.2" @@ -1044,16 +1044,16 @@ __metadata: optional: true "@types/react": optional: true - checksum: 1ce902070022c40009e01208e95d0d61205ffdbcf4fadd16e6337acdfccfb1c66004525ffe277691c7f3fbdfcebb998f1544c054a31164d580cb040e8a7d2d80 + checksum: fe8d318aed036b649a82e4833254f833ece028b6a25cec001991e6864d9e520752df6a746b6ca856c0310cc9aae16697aa77ddf53a85c889bb5d04c5aa5c1dcb languageName: node linkType: hard -"@mui/private-theming@npm:^5.15.2": - version: 5.15.2 - resolution: "@mui/private-theming@npm:5.15.2" +"@mui/private-theming@npm:^5.15.3": + version: 5.15.3 + resolution: "@mui/private-theming@npm:5.15.3" dependencies: "@babel/runtime": "npm:^7.23.6" - "@mui/utils": "npm:^5.15.2" + "@mui/utils": "npm:^5.15.3" prop-types: "npm:^15.8.1" peerDependencies: "@types/react": ^17.0.0 || ^18.0.0 @@ -1061,13 +1061,13 @@ __metadata: peerDependenciesMeta: "@types/react": optional: true - checksum: 2b1665044fd77286068100bd5c67ba3a31320084b442788e1c0224359b6e8e3213505676fa1db451c970b2e432811b12cbcf2f882c9063d37497dbfcfcd8811e + checksum: 4404a7d9545974631b329f391df72fa54edb5aefa6d32d9656b200284613e8ea1bdd3d0add2abe7278f1343dd5cf7552c7e4d2aaf5593f292c7db3cd63ddff21 languageName: node linkType: hard -"@mui/styled-engine@npm:^5.15.2": - version: 5.15.2 - resolution: "@mui/styled-engine@npm:5.15.2" +"@mui/styled-engine@npm:^5.15.3": + version: 5.15.3 + resolution: "@mui/styled-engine@npm:5.15.3" dependencies: "@babel/runtime": "npm:^7.23.6" "@emotion/cache": "npm:^11.11.0" @@ -1082,19 +1082,19 @@ __metadata: optional: true "@emotion/styled": optional: true - checksum: c004a37f4343139896059a706e96175a0f8975cc8807bcea96c099a68a94cf24d7869e685b06511389c9a6e4412acac5ef07614659983a7782f203012b78315b + checksum: 6775f92cda9f17428baf5b95e5849f31eead92485e332902ff29bd49bd03fbe2f5e762ebcdd122f7f31e102ec42cda29cbb5fdef79f5d03f416705d119b69e75 languageName: node linkType: hard -"@mui/system@npm:^5.15.2": - version: 5.15.2 - resolution: "@mui/system@npm:5.15.2" +"@mui/system@npm:^5.15.3": + version: 5.15.3 + resolution: "@mui/system@npm:5.15.3" dependencies: "@babel/runtime": "npm:^7.23.6" - "@mui/private-theming": "npm:^5.15.2" - "@mui/styled-engine": "npm:^5.15.2" - "@mui/types": "npm:^7.2.11" - "@mui/utils": "npm:^5.15.2" + "@mui/private-theming": "npm:^5.15.3" + "@mui/styled-engine": "npm:^5.15.3" + "@mui/types": "npm:^7.2.12" + "@mui/utils": "npm:^5.15.3" clsx: "npm:^2.0.0" csstype: "npm:^3.1.2" prop-types: "npm:^15.8.1" @@ -1110,25 +1110,25 @@ __metadata: optional: true "@types/react": optional: true - checksum: 05335cc7856750a930e5eef4eaf3e935c1d6dd78add48e86d1d976736adea71c5f37f3c329fd0a8f5fd9d11e40775ab5a62192dc056d240cb365416ad4db5568 + checksum: 7b71cad3c3b4f8136cf51a9e7040440073201618eaa5d0fcbd8830e3c3f35eb8a38303bb2bc9da84e0c95844193fdb4238af50e1f1d74a8e9fa79500a49c31db languageName: node linkType: hard -"@mui/types@npm:^7.2.11": - version: 7.2.11 - resolution: "@mui/types@npm:7.2.11" +"@mui/types@npm:^7.2.12": + version: 7.2.12 + resolution: "@mui/types@npm:7.2.12" peerDependencies: "@types/react": ^17.0.0 || ^18.0.0 peerDependenciesMeta: "@types/react": optional: true - checksum: 57d47e455aeef066c38260ddededbb41b3a3830acc013a597e8434cb5291fc4fc85e76cf354c6d5ecee3894bb13c7723423b58e753485d7e6d06ca54f7d76cf7 + checksum: 7d3ef53fee7eddc063d2083dc129f7d6d38b472a9196c3522fc5a75e66849fbf2b824be3f6aee11dc02c4475864e544026e6051ffb9d33f5dc1fc2a2279a8b72 languageName: node linkType: hard -"@mui/utils@npm:^5.15.2": - version: 5.15.2 - resolution: "@mui/utils@npm:5.15.2" +"@mui/utils@npm:^5.15.3": + version: 5.15.3 + resolution: "@mui/utils@npm:5.15.3" dependencies: "@babel/runtime": "npm:^7.23.6" "@types/prop-types": "npm:^15.7.11" @@ -1140,7 +1140,7 @@ __metadata: peerDependenciesMeta: "@types/react": optional: true - checksum: 9ede26d8e2b456a5ecf088d4e2d6903613be57eae97fcd30a9f31ff2c35a0e4329c728bd20c94c6f3468038935c3101a040c2cfb7dd6ff7a490811af0675d90a + checksum: c4d66e34332f448527c6dea66a7011f95dc230ccaf5a3ee898a6fd69b77a3584af1fd644d095dc7edb2d480e5c050db06f9b9ec9dea3bc5091a80cf8b676f709 languageName: node linkType: hard @@ -1217,9 +1217,9 @@ __metadata: languageName: node linkType: hard -"@preact/preset-vite@npm:^2.7.0": - version: 2.7.0 - resolution: "@preact/preset-vite@npm:2.7.0" +"@preact/preset-vite@npm:^2.8.1": + version: 2.8.1 + resolution: "@preact/preset-vite@npm:2.8.1" dependencies: "@babel/plugin-transform-react-jsx": "npm:^7.22.15" "@babel/plugin-transform-react-jsx-development": "npm:^7.22.5" @@ -1228,11 +1228,13 @@ __metadata: babel-plugin-transform-hook-names: "npm:^1.0.2" debug: "npm:^4.3.4" kolorist: "npm:^1.8.0" + magic-string: "npm:0.30.5" + node-html-parser: "npm:^6.1.10" resolve: "npm:^1.22.8" peerDependencies: "@babel/core": 7.x vite: 2.x || 3.x || 4.x || 5.x - checksum: dc0420ea1b6718fbf02d395e44642bd74736dcc23236e645bc390bae3371f359dec65ec1aa9358e77d73354d9d2d7af0ae71eec11e99aac335fe85b49dcd9d54 + checksum: ac91fc701e078d2910b386b9e793f5429f9db04e3c56ea0f41f5f777fb21f5610acd9091def7bb2da9aaadbb9e687e1c276ff0d636fe3427ebd452dce5f98838 languageName: node linkType: hard @@ -1566,12 +1568,12 @@ __metadata: languageName: node linkType: hard -"@types/node@npm:^20.10.5": - version: 20.10.5 - resolution: "@types/node@npm:20.10.5" +"@types/node@npm:^20.10.6": + version: 20.10.6 + resolution: "@types/node@npm:20.10.6" dependencies: undici-types: "npm:~5.26.4" - checksum: 4a378428d2c9f692b19801a5a3d20dc4c0ad5d4a3d103350f8b401af439941a9aa5efeadc8eb9db13c66c620318bc7f336abfc8934f82fd32c4a689d85068c6f + checksum: 08471220d3cbbb6669835c4b78541edf5eface8f2c2e36c550cfa4ff73da73071c90e200a06359fac25d6564127597c23e178128058fb676824ec23d5178a017 languageName: node linkType: hard @@ -1646,14 +1648,14 @@ __metadata: languageName: node linkType: hard -"@types/react@npm:^18.2.45": - version: 18.2.45 - resolution: "@types/react@npm:18.2.45" +"@types/react@npm:^18.2.46": + version: 18.2.46 + resolution: "@types/react@npm:18.2.46" dependencies: "@types/prop-types": "npm:*" "@types/scheduler": "npm:*" csstype: "npm:^3.0.2" - checksum: bd27fd8a959fa776965997af89cb04e43e7868416850fdff421b5539f389efa35acae3d55915c9f32d7b00fb388550302bf8a7f06010abf9ad431e5bf58cb774 + checksum: 10fb28a5b8504106512ce3b154c45d1ac045c31633786773a29f003b3079b434060368bb56f95ef6c39510835ceec4fb8fdc271d6ca2b9cdd979379cf53f126b languageName: node linkType: hard @@ -1689,15 +1691,15 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/eslint-plugin@npm:^6.16.0": - version: 6.16.0 - resolution: "@typescript-eslint/eslint-plugin@npm:6.16.0" +"@typescript-eslint/eslint-plugin@npm:^6.17.0": + version: 6.17.0 + resolution: "@typescript-eslint/eslint-plugin@npm:6.17.0" dependencies: "@eslint-community/regexpp": "npm:^4.5.1" - "@typescript-eslint/scope-manager": "npm:6.16.0" - "@typescript-eslint/type-utils": "npm:6.16.0" - "@typescript-eslint/utils": "npm:6.16.0" - "@typescript-eslint/visitor-keys": "npm:6.16.0" + "@typescript-eslint/scope-manager": "npm:6.17.0" + "@typescript-eslint/type-utils": "npm:6.17.0" + "@typescript-eslint/utils": "npm:6.17.0" + "@typescript-eslint/visitor-keys": "npm:6.17.0" debug: "npm:^4.3.4" graphemer: "npm:^1.4.0" ignore: "npm:^5.2.4" @@ -1710,44 +1712,44 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: 4bedce948ac3c20492a59813ee5d4f1f2306310857864dfaac2736f6c38e18785002c36844fd64c9fbdf3059fc390b29412be105fd7a118177f1eeeb1eb533f7 + checksum: f2a5774e9cc03e491a5a488501e5622c7eebd766f5a4fc2c30642864a3b89b0807946bde33a678f326ba7032f3f6a51aa0bf9c2d10adc823804fc9fb47db55a6 languageName: node linkType: hard -"@typescript-eslint/parser@npm:^6.16.0": - version: 6.16.0 - resolution: "@typescript-eslint/parser@npm:6.16.0" +"@typescript-eslint/parser@npm:^6.17.0": + version: 6.17.0 + resolution: "@typescript-eslint/parser@npm:6.17.0" dependencies: - "@typescript-eslint/scope-manager": "npm:6.16.0" - "@typescript-eslint/types": "npm:6.16.0" - "@typescript-eslint/typescript-estree": "npm:6.16.0" - "@typescript-eslint/visitor-keys": "npm:6.16.0" + "@typescript-eslint/scope-manager": "npm:6.17.0" + "@typescript-eslint/types": "npm:6.17.0" + "@typescript-eslint/typescript-estree": "npm:6.17.0" + "@typescript-eslint/visitor-keys": "npm:6.17.0" debug: "npm:^4.3.4" peerDependencies: eslint: ^7.0.0 || ^8.0.0 peerDependenciesMeta: typescript: optional: true - checksum: 3d941ce345dc2ce29957e2110957662873d514b094b8939923c3281d858c11cd1f9058db862644afe14f68d087770f39a0a1f9e523a2013ed5d2fdf3421b34d0 + checksum: 2ed0ed4a5b30e953430ce3279df3655af09fa1caed2abf11804d239717daefc32a22864f6620ef57bb9c684c74a99a13241384fea5096e961385e3678fc2e920 languageName: node linkType: hard -"@typescript-eslint/scope-manager@npm:6.16.0": - version: 6.16.0 - resolution: "@typescript-eslint/scope-manager@npm:6.16.0" +"@typescript-eslint/scope-manager@npm:6.17.0": + version: 6.17.0 + resolution: "@typescript-eslint/scope-manager@npm:6.17.0" dependencies: - "@typescript-eslint/types": "npm:6.16.0" - "@typescript-eslint/visitor-keys": "npm:6.16.0" - checksum: 3360aae4b85f5c31d20ad48d771cc09a6f8f6b1811b00d94f06e55b5a09c610ac75631b1c4edecb3bec682d41351b87e7d14d42bee84aa032064d0e13463035b + "@typescript-eslint/types": "npm:6.17.0" + "@typescript-eslint/visitor-keys": "npm:6.17.0" + checksum: fe09c628553c9336e6a36d32c1d34e78ebd20aa02130a6bf535329621ba5a98aaac171f607bc6e4d17b3478c42e7de6476376636897ce3f227c754eb99acd07e languageName: node linkType: hard -"@typescript-eslint/type-utils@npm:6.16.0": - version: 6.16.0 - resolution: "@typescript-eslint/type-utils@npm:6.16.0" +"@typescript-eslint/type-utils@npm:6.17.0": + version: 6.17.0 + resolution: "@typescript-eslint/type-utils@npm:6.17.0" dependencies: - "@typescript-eslint/typescript-estree": "npm:6.16.0" - "@typescript-eslint/utils": "npm:6.16.0" + "@typescript-eslint/typescript-estree": "npm:6.17.0" + "@typescript-eslint/utils": "npm:6.17.0" debug: "npm:^4.3.4" ts-api-utils: "npm:^1.0.1" peerDependencies: @@ -1755,23 +1757,23 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: 5964b87a87252bed278a248eb568902babd7c34defd3af8c3df371926d96aec716f33f1dc14bde170e93f73ed1b0af6e591e647853d0f33f378e2c7b3b73fc5b + checksum: dc7938429193acfda61b7282197ec046039e2c4da41cdcddf4daaf300d10229e4e23bb0fcf0503b19c0b99a874849c8a9f5bb35ce106260f56a14106d2b41d8c languageName: node linkType: hard -"@typescript-eslint/types@npm:6.16.0": - version: 6.16.0 - resolution: "@typescript-eslint/types@npm:6.16.0" - checksum: 236ca318c2440c95068e5d4d147e2bfed62447775e18695e21c8ca04a341a74d01c37ed2b417629b7bf2fb91ad4fd5e2a6570215d16fc24dd1507ce6973b4e22 +"@typescript-eslint/types@npm:6.17.0": + version: 6.17.0 + resolution: "@typescript-eslint/types@npm:6.17.0" + checksum: 87ab1b5a3270ab34b917c22a2fb90a9ad7d9f3b19d73a337bc9efbe65f924da13482c97e8ccbe3bd3d081aa96039eeff50de41c1da2a2128066429b931cdb21d languageName: node linkType: hard -"@typescript-eslint/typescript-estree@npm:6.16.0": - version: 6.16.0 - resolution: "@typescript-eslint/typescript-estree@npm:6.16.0" +"@typescript-eslint/typescript-estree@npm:6.17.0": + version: 6.17.0 + resolution: "@typescript-eslint/typescript-estree@npm:6.17.0" dependencies: - "@typescript-eslint/types": "npm:6.16.0" - "@typescript-eslint/visitor-keys": "npm:6.16.0" + "@typescript-eslint/types": "npm:6.17.0" + "@typescript-eslint/visitor-keys": "npm:6.17.0" debug: "npm:^4.3.4" globby: "npm:^11.1.0" is-glob: "npm:^4.0.3" @@ -1781,34 +1783,34 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: 8e1ef03ecabaf3791b11240a51217836dbb74850e458258db77ac5eab5508cd9c63fb671924993d1e7654718c0c857c3550d51ecba0845fe489d143bb858e1b1 + checksum: 1671b0d2f2fdf07074fb1e2524d61935cec173bd8db6e482cc5b2dcc77aed3ffa831396736ffa0ee2fdbddd8585ae9ca8d6c97bcaea1385b23907a1ec0508f83 languageName: node linkType: hard -"@typescript-eslint/utils@npm:6.16.0": - version: 6.16.0 - resolution: "@typescript-eslint/utils@npm:6.16.0" +"@typescript-eslint/utils@npm:6.17.0": + version: 6.17.0 + resolution: "@typescript-eslint/utils@npm:6.17.0" dependencies: "@eslint-community/eslint-utils": "npm:^4.4.0" "@types/json-schema": "npm:^7.0.12" "@types/semver": "npm:^7.5.0" - "@typescript-eslint/scope-manager": "npm:6.16.0" - "@typescript-eslint/types": "npm:6.16.0" - "@typescript-eslint/typescript-estree": "npm:6.16.0" + "@typescript-eslint/scope-manager": "npm:6.17.0" + "@typescript-eslint/types": "npm:6.17.0" + "@typescript-eslint/typescript-estree": "npm:6.17.0" semver: "npm:^7.5.4" peerDependencies: eslint: ^7.0.0 || ^8.0.0 - checksum: 84dd02f7c8e47fae699cc222da5cbea08b28c6e1cc7827860430bc86c2a17ee3f86e198a4356902b95930f85785aa662266ea9c476f69bf80c6a5f648e55f9f4 + checksum: 37c63afcf66124bf84808699997953b8c84a378aa2c490a771b611d82cdac8499c58fac8eeb8378528e97660b59563d99297bfec4b982cd68760b0ffe54aa714 languageName: node linkType: hard -"@typescript-eslint/visitor-keys@npm:6.16.0": - version: 6.16.0 - resolution: "@typescript-eslint/visitor-keys@npm:6.16.0" +"@typescript-eslint/visitor-keys@npm:6.17.0": + version: 6.17.0 + resolution: "@typescript-eslint/visitor-keys@npm:6.17.0" dependencies: - "@typescript-eslint/types": "npm:6.16.0" + "@typescript-eslint/types": "npm:6.17.0" eslint-visitor-keys: "npm:^3.4.1" - checksum: 19e559f14ea0092585a374b8c5f1aca9b6b271fc23909d9857de9cf71a1e1d3abc0afd237e9c02d7a5fbdfe8e3be7853cf9fedf40a6f16bac3495cb7f4e67982 + checksum: a2aed0e1437fdab8858ab9c7c8e355f8b72a5fa4b0adc54f28b8a2bbc29d4bb93214968ee940f83d013d0a4b83d00cd4eeeb05fb4c2c7d0ead324c6793f7d6d4 languageName: node linkType: hard @@ -1824,22 +1826,22 @@ __metadata: resolution: "EMS-ESP@workspace:." dependencies: "@alova/adapter-xhr": "npm:^1.0.2" - "@babel/core": "npm:^7.23.6" + "@babel/core": "npm:^7.23.7" "@emotion/react": "npm:^11.11.3" "@emotion/styled": "npm:^11.11.0" - "@mui/icons-material": "npm:^5.15.2" - "@mui/material": "npm:^5.15.2" + "@mui/icons-material": "npm:^5.15.3" + "@mui/material": "npm:^5.15.3" "@preact/compat": "npm:^17.1.2" - "@preact/preset-vite": "npm:^2.7.0" + "@preact/preset-vite": "npm:^2.8.1" "@table-library/react-table-library": "npm:4.1.7" "@types/imagemin": "npm:^8.0.5" "@types/lodash-es": "npm:^4.17.12" - "@types/node": "npm:^20.10.5" - "@types/react": "npm:^18.2.45" + "@types/node": "npm:^20.10.6" + "@types/react": "npm:^18.2.46" "@types/react-dom": "npm:^18.2.18" "@types/react-router-dom": "npm:^5.3.3" - "@typescript-eslint/eslint-plugin": "npm:^6.16.0" - "@typescript-eslint/parser": "npm:^6.16.0" + "@typescript-eslint/eslint-plugin": "npm:^6.17.0" + "@typescript-eslint/parser": "npm:^6.17.0" alova: "npm:^2.16.2" async-validator: "npm:^4.2.5" concurrently: "npm:^8.2.2" @@ -1873,7 +1875,7 @@ __metadata: typescript: "npm:^5.3.3" vite: "npm:^5.0.10" vite-plugin-imagemin: "npm:^0.6.1" - vite-tsconfig-paths: "npm:^4.2.2" + vite-tsconfig-paths: "npm:^4.2.3" languageName: unknown linkType: soft @@ -2833,6 +2835,19 @@ __metadata: languageName: node linkType: hard +"css-select@npm:^5.1.0": + version: 5.1.0 + resolution: "css-select@npm:5.1.0" + dependencies: + boolbase: "npm:^1.0.0" + css-what: "npm:^6.1.0" + domhandler: "npm:^5.0.2" + domutils: "npm:^3.0.1" + nth-check: "npm:^2.0.1" + checksum: d486b1e7eb140468218a5ab5af53257e01f937d2173ac46981f6b7de9c5283d55427a36715dc8decfc0c079cf89259ac5b41ef58f6e1a422eee44ab8bfdc78da + languageName: node + linkType: hard + "css-tree@npm:^1.1.2, css-tree@npm:^1.1.3": version: 1.1.3 resolution: "css-tree@npm:1.1.3" @@ -2843,7 +2858,7 @@ __metadata: languageName: node linkType: hard -"css-what@npm:^6.0.1": +"css-what@npm:^6.0.1, css-what@npm:^6.1.0": version: 6.1.0 resolution: "css-what@npm:6.1.0" checksum: c67a3a2d0d81843af87f8bf0a4d0845b0f952377714abbb2884e48942409d57a2110eabee003609d02ee487b054614bdfcfc59ee265728ff105bd5aa221c1d0e @@ -3137,7 +3152,18 @@ __metadata: languageName: node linkType: hard -"domelementtype@npm:^2.0.1, domelementtype@npm:^2.2.0": +"dom-serializer@npm:^2.0.0": + version: 2.0.0 + resolution: "dom-serializer@npm:2.0.0" + dependencies: + domelementtype: "npm:^2.3.0" + domhandler: "npm:^5.0.2" + entities: "npm:^4.2.0" + checksum: e3bf9027a64450bca0a72297ecdc1e3abb7a2912268a9f3f5d33a2e29c1e2c3502c6e9f860fc6625940bfe0cfb57a44953262b9e94df76872fdfb8151097eeb3 + languageName: node + linkType: hard + +"domelementtype@npm:^2.0.1, domelementtype@npm:^2.2.0, domelementtype@npm:^2.3.0": version: 2.3.0 resolution: "domelementtype@npm:2.3.0" checksum: ee837a318ff702622f383409d1f5b25dd1024b692ef64d3096ff702e26339f8e345820f29a68bcdcea8cfee3531776b3382651232fbeae95612d6f0a75efb4f6 @@ -3153,6 +3179,15 @@ __metadata: languageName: node linkType: hard +"domhandler@npm:^5.0.2, domhandler@npm:^5.0.3": + version: 5.0.3 + resolution: "domhandler@npm:5.0.3" + dependencies: + domelementtype: "npm:^2.3.0" + checksum: 809b805a50a9c6884a29f38aec0a4e1b4537f40e1c861950ed47d10b049febe6b79ab72adaeeebb3cc8fc1cd33f34e97048a72a9265103426d93efafa78d3e96 + languageName: node + linkType: hard + "domutils@npm:^2.8.0": version: 2.8.0 resolution: "domutils@npm:2.8.0" @@ -3164,6 +3199,17 @@ __metadata: languageName: node linkType: hard +"domutils@npm:^3.0.1": + version: 3.1.0 + resolution: "domutils@npm:3.1.0" + dependencies: + dom-serializer: "npm:^2.0.0" + domelementtype: "npm:^2.3.0" + domhandler: "npm:^5.0.3" + checksum: 9a169a6e57ac4c738269a73ab4caf785114ed70e46254139c1bbc8144ac3102aacb28a6149508395ae34aa5d6a40081f4fa5313855dc8319c6d8359866b6dfea + languageName: node + linkType: hard + "download@npm:^6.2.2": version: 6.2.5 resolution: "download@npm:6.2.5" @@ -3280,6 +3326,13 @@ __metadata: languageName: node linkType: hard +"entities@npm:^4.2.0": + version: 4.5.0 + resolution: "entities@npm:4.5.0" + checksum: ede2a35c9bce1aeccd055a1b445d41c75a14a2bb1cd22e242f20cf04d236cdcd7f9c859eb83f76885327bfae0c25bf03303665ee1ce3d47c5927b98b0e3e3d48 + languageName: node + linkType: hard + "env-paths@npm:^2.2.0": version: 2.2.1 resolution: "env-paths@npm:2.2.1" @@ -4950,6 +5003,15 @@ __metadata: languageName: node linkType: hard +"he@npm:1.2.0": + version: 1.2.0 + resolution: "he@npm:1.2.0" + bin: + he: bin/he + checksum: d09b2243da4e23f53336e8de3093e5c43d2c39f8d0d18817abfa32ce3e9355391b2edb4bb5edc376aea5d4b0b59d6a0482aab4c52bc02ef95751e4b818e847f1 + languageName: node + linkType: hard + "history@npm:^5.3.0": version: 5.3.0 resolution: "history@npm:5.3.0" @@ -6037,6 +6099,15 @@ __metadata: languageName: node linkType: hard +"magic-string@npm:0.30.5": + version: 0.30.5 + resolution: "magic-string@npm:0.30.5" + dependencies: + "@jridgewell/sourcemap-codec": "npm:^1.4.15" + checksum: c8a6b25f813215ca9db526f3a407d6dc0bf35429c2b8111d6f1c2cf6cf6afd5e2d9f9cd189416a0e3959e20ecd635f73639f9825c73de1074b29331fe36ace59 + languageName: node + linkType: hard + "make-dir@npm:^1.0.0, make-dir@npm:^1.2.0": version: 1.3.0 resolution: "make-dir@npm:1.3.0" @@ -6373,6 +6444,16 @@ __metadata: languageName: node linkType: hard +"node-html-parser@npm:^6.1.10": + version: 6.1.12 + resolution: "node-html-parser@npm:6.1.12" + dependencies: + css-select: "npm:^5.1.0" + he: "npm:1.2.0" + checksum: 83e6b8bc2921522ca0eba7f2bdaad6d4a182cb3e578444504e2603fb35604a95a5787430be04066799669a27c6d3886a89c792b1848307bfad9028b9483752a0 + languageName: node + linkType: hard + "node-releases@npm:^2.0.13": version: 2.0.13 resolution: "node-releases@npm:2.0.13" @@ -8674,9 +8755,9 @@ __metadata: languageName: node linkType: hard -"vite-tsconfig-paths@npm:^4.2.2": - version: 4.2.2 - resolution: "vite-tsconfig-paths@npm:4.2.2" +"vite-tsconfig-paths@npm:^4.2.3": + version: 4.2.3 + resolution: "vite-tsconfig-paths@npm:4.2.3" dependencies: debug: "npm:^4.1.1" globrex: "npm:^0.1.2" @@ -8686,7 +8767,7 @@ __metadata: peerDependenciesMeta: vite: optional: true - checksum: 790b9a48dd69b6e93bc41455ef0cc63fc8149b40a6d344784067fc2487b0a02f2d6a6d71396214dab7537a52c5e1ddfc88c363232fa707377db161d05e8f68cd + checksum: ba6abe5d18fc1c1e494e1f1d8a7db56445c2a40e15aadb5d47a9c66cc5372d6f69b94ff0b1e47b67659d6ecaeddebab0a9d11e40b1c3c36c0115800736a6c760 languageName: node linkType: hard From 1316fe950951ea0b23460c931af7f2204bf9ea1b Mon Sep 17 00:00:00 2001 From: Proddy Date: Wed, 3 Jan 2024 22:57:13 +0100 Subject: [PATCH 05/22] 3.6.5-dev.8 --- CHANGELOG_LATEST.md | 4 +++- src/version.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG_LATEST.md b/CHANGELOG_LATEST.md index 97513fc8f..802232884 100644 --- a/CHANGELOG_LATEST.md +++ b/CHANGELOG_LATEST.md @@ -10,7 +10,7 @@ - heatpump energy meters [#1463](https://github.com/emsesp/EMS-ESP32/issues/1463) - heatpump max power [#1475](https://github.com/emsesp/EMS-ESP32/issues/1475) - checkbox for MQTT-TLS enable [#1474](https://github.com/emsesp/EMS-ESP32/issues/1474) -- added SK (Slovencina) language. Thanks @misa1515 +- added SK (Slovenian) language. Thanks @misa1515 - CPU info [#1497](https://github.com/emsesp/EMS-ESP32/pull/1497) ## Fixed @@ -18,6 +18,8 @@ - exhaust temperature for some boilers - add back boil2hyst [#1477](https://github.com/emsesp/EMS-ESP32/issues/1477) - subscribed MQTT topics not detecting changes by EMS-ESP [#1494](https://github.com/emsesp/EMS-ESP32/issues/1494) +- changed HA name and grouping to be consistent [#1528](https://github.com/emsesp/EMS-ESP32/issues/1528) +- MQTT autodiscovery in Domoticz not working [#1360](https://github.com/emsesp/EMS-ESP32/issues/1528) ## Changed diff --git a/src/version.h b/src/version.h index 2ccdaa2ab..3b890a031 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define EMSESP_APP_VERSION "3.6.5-dev.7" +#define EMSESP_APP_VERSION "3.6.5-dev.8" From 78bd0a1b76b1821ec627f9b982294be13d4c51d8 Mon Sep 17 00:00:00 2001 From: Proddy Date: Wed, 3 Jan 2024 22:57:59 +0100 Subject: [PATCH 06/22] espressif 6.5.0 --- platformio.ini | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/platformio.ini b/platformio.ini index e708d80b7..be35b8abb 100644 --- a/platformio.ini +++ b/platformio.ini @@ -2,8 +2,8 @@ ; override any settings with your own local ones in pio_local.ini [platformio] -default_envs = esp32_4M -; default_envs = lolin_s3 +; default_envs = esp32_4M +default_envs = lolin_s3 ; default_envs = esp32_16M ; default_envs = standalone @@ -13,8 +13,6 @@ extra_configs = [common] core_build_flags = - -D CORE_DEBUG_LEVEL=0 - -D NDEBUG -D ARDUINO_ARCH_ESP32=1 -D ESP32=1 ; -std=gnu++17 @@ -33,13 +31,14 @@ build_flags = -D NO_GLOBAL_ARDUINOOTA -D ARDUINOJSON_ENABLE_STD_STRING=1 -D ARDUINOJSON_USE_DOUBLE=0 - ; -D CONFIG_UART_ISR_IN_IRAM + -D ARDUINOTRACE_ENABLE=0 + -D CONFIG_ETH_ENABLED unbuild_flags = ${common.core_unbuild_flags} [espressi32_base] -platform = espressif32@6.4.0 +platform = espressif32@6.5.0 framework = arduino board_build.filesystem = littlefs build_flags = ${common.build_flags} @@ -69,7 +68,7 @@ extra_scripts = [env] monitor_speed = 115200 -monitor_raw = yes +monitor_filters = esp32_exception_decoder upload_speed = 921600 build_type = release lib_ldf_mode = chain+ @@ -178,7 +177,8 @@ build_flags = -lpthread -std=gnu++11 -Og -ggdb build_src_flags = - -Wall -Wextra -Werror -Wswitch-enum -Wno-unused-parameter -Wno-inconsistent-missing-override -Wno-unused-lambda-capture -Wno-sign-compare + ; -Wall -Wextra -Werror -Wswitch-enum -Wno-unused-parameter -Wno-inconsistent-missing-override -Wno-unused-lambda-capture -Wno-sign-compare + ; -Wall -Wextra -Werror -Wno-missing-braces -I./lib_standalone -I./lib/ArduinoJson/src @@ -201,4 +201,4 @@ build_src_filter = +<../lib/espMqttClient/src> +<../lib/espMqttClient/src/Transport> lib_compat_mode = off -lib_ldf_mode = off \ No newline at end of file +lib_ldf_mode = off From e525552e10bac2da72e9120645417582d9989aa4 Mon Sep 17 00:00:00 2001 From: Proddy Date: Wed, 3 Jan 2024 22:58:21 +0100 Subject: [PATCH 07/22] wifi console help text --- src/console.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/console.cpp b/src/console.cpp index 06fd98aba..1902561b2 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -237,7 +237,7 @@ static void setup_commands(std::shared_ptr & commands) { networkSettings.password = password2.c_str(); return StateUpdateResult::CHANGED; }); - shell.println("Use `wifi reconnect` to save and apply the new settings"); + shell.println("WiFi password updated"); } else { shell.println("Passwords do not match"); } @@ -272,7 +272,7 @@ static void setup_commands(std::shared_ptr & commands) { networkSettings.ssid = arguments.front().c_str(); return StateUpdateResult::CHANGED; }); - shell.println("Use `wifi reconnect` to save and apply the new settings"); + shell.println("WiFi ssid updated"); }); From cb5f707b2d5e7e27374bf7e599efae9ca3c2bcfb Mon Sep 17 00:00:00 2001 From: Proddy Date: Wed, 3 Jan 2024 23:00:07 +0100 Subject: [PATCH 08/22] use add_ha_sections_to_doc(), add via_device, add check for domoticz --- src/analogsensor.cpp | 8 +-- src/mqtt.cpp | 105 +++++++++++++++++------------ src/mqtt.h | 9 ++- src/shower.cpp | 21 +----- src/temperaturesensor.cpp | 17 ++--- src/web/WebCustomEntityService.cpp | 7 +- src/web/WebSchedulerService.cpp | 7 +- 7 files changed, 83 insertions(+), 91 deletions(-) diff --git a/src/analogsensor.cpp b/src/analogsensor.cpp index 61f6cca7f..045dbbdae 100644 --- a/src/analogsensor.cpp +++ b/src/analogsensor.cpp @@ -615,13 +615,7 @@ void AnalogSensor::publish_values(const bool force) { config["stat_cla"] = "measurement"; } - JsonObject dev = config.createNestedObject("dev"); - dev["name"] = Mqtt::basename() + " Analog"; - JsonArray ids = dev.createNestedArray("ids"); - ids.add(Mqtt::basename() + "-analog"); - - // add "availability" section - Mqtt::add_avty_to_doc(stat_t, config.as(), val_cond); + Mqtt::add_ha_sections_to_doc("analog", stat_t, config.as(), true, val_cond); sensor.ha_registered = Mqtt::queue_ha(topic, config.as()); } diff --git a/src/mqtt.cpp b/src/mqtt.cpp index 3b0745405..0a96f0cea 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -542,7 +542,7 @@ void Mqtt::ha_status() { JsonObject dev = doc.createNestedObject("dev"); dev["name"] = Mqtt::basename(); dev["sw"] = "v" + std::string(EMSESP_APP_VERSION); - dev["mf"] = "proddy"; + dev["mf"] = "EMS-ESP"; dev["mdl"] = "EMS-ESP"; #ifndef EMSESP_STANDALONE dev["cu"] = "http://" + (EMSESP::system_.ethernet_connected() ? ETH.localIP().toString() : WiFi.localIP().toString()); @@ -739,10 +739,11 @@ bool Mqtt::publish_ha_sensor_config(DeviceValue & dv, const char * model, const dev_json["name"] = Mqtt::basename() + " " + cap_name; free(cap_name); + // create only once per category if (create_device_config) { dev_json["mf"] = brand; dev_json["mdl"] = model; - dev_json["via_device"] = "ems-esp"; + dev_json["via_device"] = Mqtt::basename(); } // calculate the min and max @@ -1136,8 +1137,8 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev } } - doc["dev"] = dev_json; // add the dev json object to the end - add_avty_to_doc(stat_t, doc.as(), val_cond); // add "availability" section + doc["dev"] = dev_json; // add the dev json object to the end + add_ha_sections_to_doc("", stat_t, doc.as(), false, val_cond); // no name, since the "dev" has already been added return queue_ha(topic, doc.as()); } @@ -1245,18 +1246,8 @@ bool Mqtt::publish_ha_climate_config(const uint8_t tag, const bool has_roomtemp, modes.add("heat"); modes.add("off"); - JsonObject dev = doc.createNestedObject("dev"); - JsonArray ids = dev.createNestedArray("ids"); - - char ha_device[40]; - snprintf(ha_device, sizeof(ha_device), "%s-thermostat", Mqtt::basename().c_str()); - ids.add(ha_device); - // device name must be different to the entity name, take the ids value we just created - dev["name"] = ha_device; - - // add "availability" section - add_avty_to_doc(topic_t, doc.as(), seltemp_cond, has_roomtemp ? currtemp_cond : nullptr, hc_mode_cond); + add_ha_sections_to_doc("thermostat", topic_t, doc.as(), false, seltemp_cond, has_roomtemp ? currtemp_cond : nullptr, hc_mode_cond); return queue_ha(topic, doc.as()); // publish the config payload with retain flag } @@ -1280,42 +1271,68 @@ 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.clear(); - 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) { - avty_json.clear(); - avty_json["t"] = state_t; - snprintf(tpl, sizeof(tpl), tpl_draft, cond2); - avty_json["val_tpl"] = tpl; - avty.add(avty_json); +// adds availability, dev, ids to the config section to HA Discovery config +void Mqtt::add_ha_sections_to_doc(const std::string & name, + const char * state_t, + const JsonObject & config, + const bool is_first, + const char * cond1, + const char * cond2, + const char * negcond) { + // adds dev section to HA Discovery config + if (!name.empty()) { + JsonObject dev = config.createNestedObject("dev"); + auto cap_name = name; + cap_name[0] = toupper(name[0]); // capitalize first letter + dev["name"] = Mqtt::basename() + " " + cap_name; + // if it's the first in the category, attach the group to the main HA device + if (is_first) { + dev["mf"] = "EMS-ESP"; + dev["mdl"] = cap_name; + dev["via_device"] = Mqtt::basename(); + } + JsonArray ids = dev.createNestedArray("ids"); + ids.add(Mqtt::basename() + "-" + Helpers::toLower(name)); } - if (negcond != nullptr) { + // adds "availability" section to HA Discovery config + // but not for Domoticz + if (discovery_type() == discoveryType::HOMEASSISTANT) { + const char * tpl_draft = "{{'online' if %s else 'offline'}}"; + char tpl[150]; + JsonArray avty = config.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.clear(); avty_json["t"] = state_t; - snprintf(tpl, sizeof(tpl), "{{'offline' if %s else 'online'}}", negcond); + snprintf(tpl, sizeof(tpl), tpl_draft, cond1 == nullptr ? "value is defined" : cond1); avty_json["val_tpl"] = tpl; avty.add(avty_json); - } - doc["avty_mode"] = "all"; + if (cond2 != nullptr) { + avty_json.clear(); + avty_json["t"] = state_t; + snprintf(tpl, sizeof(tpl), tpl_draft, cond2); + avty_json["val_tpl"] = tpl; + avty.add(avty_json); + } + + if (negcond != nullptr) { + avty_json.clear(); + avty_json["t"] = state_t; + snprintf(tpl, sizeof(tpl), "{{'offline' if %s else 'online'}}", negcond); + avty_json["val_tpl"] = tpl; + avty.add(avty_json); + } + + config["avty_mode"] = "all"; + } } } // namespace emsesp \ No newline at end of file diff --git a/src/mqtt.h b/src/mqtt.h index 53f4b631f..6854cc334 100644 --- a/src/mqtt.h +++ b/src/mqtt.h @@ -217,8 +217,13 @@ 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); + static void add_ha_sections_to_doc(const std::string & name, + const char * state_t, + const JsonObject & doc, + const bool is_first = false, + const char * cond1 = nullptr, + const char * cond2 = nullptr, + const char * negcond = nullptr); private: static uuid::log::Logger logger_; diff --git a/src/shower.cpp b/src/shower.cpp index 3da18df2d..aba136de1 100644 --- a/src/shower.cpp +++ b/src/shower.cpp @@ -210,12 +210,7 @@ void Shower::set_shower_state(bool state, bool force) { doc["pl_off"] = Helpers::render_boolean(result, false); } - JsonObject dev = doc.createNestedObject("dev"); - dev["name"] = "EMS-ESP Shower"; - JsonArray ids = dev.createNestedArray("ids"); - ids.add(Mqtt::basename() + "-shower"); - - Mqtt::add_avty_to_doc(stat_t, doc.as()); // add "availability" section + Mqtt::add_ha_sections_to_doc("shower", stat_t, doc.as(), true); snprintf(topic, sizeof(topic), "binary_sensor/%s/shower_active/config", Mqtt::basename().c_str()); ha_configdone_ = Mqtt::queue_ha(topic, doc.as()); // publish the config payload with retain flag @@ -240,12 +235,7 @@ void Shower::set_shower_state(bool state, bool force) { doc["dev_cla"] = "duration"; // doc["ent_cat"] = "diagnostic"; - JsonObject dev2 = doc.createNestedObject("dev"); - dev2["name"] = "EMS-ESP Shower"; - JsonArray ids2 = dev2.createNestedArray("ids"); - ids2.add(Mqtt::basename() + "-shower"); - - Mqtt::add_avty_to_doc(stat_t, doc.as(), "value_json.duration is defined"); // add "availability" section + Mqtt::add_ha_sections_to_doc("shower", stat_t, doc.as(), "value_json.duration is defined"); snprintf(topic, sizeof(topic), "sensor/%s/shower_duration/config", Mqtt::basename().c_str()); Mqtt::queue_ha(topic, doc.as()); // publish the config payload with retain flag @@ -267,12 +257,7 @@ void Shower::set_shower_state(bool state, bool force) { doc["val_tpl"] = "{{value_json.timestamp if value_json.timestamp is defined else 0}}"; // doc["ent_cat"] = "diagnostic"; - JsonObject dev3 = doc.createNestedObject("dev"); - dev3["name"] = "EMS-ESP Shower"; - JsonArray ids3 = dev3.createNestedArray("ids"); - ids3.add(Mqtt::basename() + "-shower"); - - Mqtt::add_avty_to_doc(stat_t, doc.as(), "value_json.timestamp is defined"); // add "availability" section + Mqtt::add_ha_sections_to_doc("shower", stat_t, doc.as(), "value_json.timestamp is defined"); snprintf(topic, sizeof(topic), "sensor/%s/shower_timestamp/config", Mqtt::basename().c_str()); Mqtt::queue_ha(topic, doc.as()); // publish the config payload with retain flag diff --git a/src/temperaturesensor.cpp b/src/temperaturesensor.cpp index 31c50599b..504853eb3 100644 --- a/src/temperaturesensor.cpp +++ b/src/temperaturesensor.cpp @@ -527,7 +527,14 @@ void TemperatureSensor::publish_values(const bool force) { 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"] = (std::string) "{{" + val_obj + " if " + val_cond + " else -55}}"; + + // for the value template, there's a problem still with Domoticz probably due to the special characters. + // See https://github.com/emsesp/EMS-ESP32/issues/1360 + if (Mqtt::discovery_type() == Mqtt::discoveryType::DOMOTICZ) { + config["val_tpl"] = (std::string) "{{" + val_obj + "}}"; + } else { + config["val_tpl"] = (std::string) "{{" + val_obj + " if " + val_cond + " else -55}}"; + } char uniq_s[70]; if (Mqtt::entity_format() == Mqtt::entityFormat::MULTI_SHORT) { @@ -543,13 +550,7 @@ void TemperatureSensor::publish_values(const bool force) { snprintf(name, sizeof(name), "%s", sensor.name().c_str()); config["name"] = name; - JsonObject dev = config.createNestedObject("dev"); - dev["name"] = Mqtt::basename() + " Temperature"; - JsonArray ids = dev.createNestedArray("ids"); - ids.add(Mqtt::basename() + "-temperature"); - - // add "availability" section - Mqtt::add_avty_to_doc(stat_t, config.as(), val_cond); + Mqtt::add_ha_sections_to_doc("temperature", stat_t, config.as(), true, val_cond); char topic[Mqtt::MQTT_TOPIC_MAX_SIZE]; // use '_' as HA doesn't like '-' in the topic name diff --git a/src/web/WebCustomEntityService.cpp b/src/web/WebCustomEntityService.cpp index 5400fcf6a..4f318a07f 100644 --- a/src/web/WebCustomEntityService.cpp +++ b/src/web/WebCustomEntityService.cpp @@ -426,13 +426,8 @@ void WebCustomEntityService::publish(const bool force) { config["pl_off"] = Helpers::render_boolean(result, false); } } - JsonObject dev = config.createNestedObject("dev"); - dev["name"] = Mqtt::basename() + " Custom"; - JsonArray ids = dev.createNestedArray("ids"); - ids.add(Mqtt::basename() + "-custom"); + Mqtt::add_ha_sections_to_doc("custom", stat_t, config.as(), true, val_cond); - // add "availability" section - Mqtt::add_avty_to_doc(stat_t, config.as(), val_cond); ha_created |= Mqtt::queue_ha(topic, config.as()); } } diff --git a/src/web/WebSchedulerService.cpp b/src/web/WebSchedulerService.cpp index bb2b91c52..2036fde97 100644 --- a/src/web/WebSchedulerService.cpp +++ b/src/web/WebSchedulerService.cpp @@ -287,13 +287,8 @@ void WebSchedulerService::publish(const bool force) { config["pl_off"] = Helpers::render_boolean(result, false); } - JsonObject dev = config.createNestedObject("dev"); - dev["name"] = Mqtt::basename() + " Scheduler"; - JsonArray ids = dev.createNestedArray("ids"); - ids.add(Mqtt::basename() + "-scheduler"); + Mqtt::add_ha_sections_to_doc("scheduler", stat_t, config.as(), true, val_cond); - // add "availability" section - Mqtt::add_avty_to_doc(stat_t, config.as(), val_cond); ha_created |= Mqtt::queue_ha(topic, config.as()); } } From 8384344c5a9f60140aba6e3215d6afb132e353ec Mon Sep 17 00:00:00 2001 From: Proddy Date: Wed, 3 Jan 2024 23:03:41 +0100 Subject: [PATCH 09/22] no need to pretty json output --- src/web/WebAPIService.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/web/WebAPIService.cpp b/src/web/WebAPIService.cpp index 5c340038c..74d33df29 100644 --- a/src/web/WebAPIService.cpp +++ b/src/web/WebAPIService.cpp @@ -106,13 +106,16 @@ void WebAPIService::parse(AsyncWebServerRequest * request, JsonObject & input) { emsesp::EMSESP::system_.refreshHeapMem(); // output json buffer - size_t buffer = EMSESP_JSON_SIZE_XXXLARGE; - auto * response = new PrettyAsyncJsonResponse(false, buffer); + size_t buffer = EMSESP_JSON_SIZE_XXXLARGE; + AsyncJsonResponse * response = new AsyncJsonResponse(false, buffer); + + // add more mem if needed - won't be needed in ArduinoJson 7 while (!response->getSize()) { delete response; buffer -= 1024; - response = new PrettyAsyncJsonResponse(false, buffer); + response = new AsyncJsonResponse(false, buffer); } + JsonObject output = response->getRoot(); // call command From c9efd095e74ce483bfc236338e3363da18adde8f Mon Sep 17 00:00:00 2001 From: Proddy Date: Wed, 3 Jan 2024 23:56:23 +0100 Subject: [PATCH 10/22] show network hostname in webui --- CHANGELOG_LATEST.md | 1 + interface/src/framework/network/NetworkStatusForm.tsx | 10 ++++++++++ lib/framework/NetworkStatus.cpp | 6 ++++-- mock-api/Handler.ts | 9 +++++---- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/CHANGELOG_LATEST.md b/CHANGELOG_LATEST.md index 802232884..f47f97d78 100644 --- a/CHANGELOG_LATEST.md +++ b/CHANGELOG_LATEST.md @@ -12,6 +12,7 @@ - checkbox for MQTT-TLS enable [#1474](https://github.com/emsesp/EMS-ESP32/issues/1474) - added SK (Slovenian) language. Thanks @misa1515 - CPU info [#1497](https://github.com/emsesp/EMS-ESP32/pull/1497) +- Show network hostname in Web UI under Network Status ## Fixed diff --git a/interface/src/framework/network/NetworkStatusForm.tsx b/interface/src/framework/network/NetworkStatusForm.tsx index 9d94d2490..3a731c4ca 100644 --- a/interface/src/framework/network/NetworkStatusForm.tsx +++ b/interface/src/framework/network/NetworkStatusForm.tsx @@ -1,5 +1,6 @@ import DeviceHubIcon from '@mui/icons-material/DeviceHub'; import DnsIcon from '@mui/icons-material/Dns'; +import GiteIcon from '@mui/icons-material/Gite'; import RefreshIcon from '@mui/icons-material/Refresh'; import RouterIcon from '@mui/icons-material/Router'; import SettingsInputAntennaIcon from '@mui/icons-material/SettingsInputAntenna'; @@ -115,6 +116,15 @@ const NetworkStatusForm: FC = () => { + + + + + + + + + {isWiFi(data) && ( <> diff --git a/lib/framework/NetworkStatus.cpp b/lib/framework/NetworkStatus.cpp index 6aea4580f..546e7f8b5 100644 --- a/lib/framework/NetworkStatus.cpp +++ b/lib/framework/NetworkStatus.cpp @@ -19,9 +19,11 @@ void NetworkStatus::networkStatus(AsyncWebServerRequest * request) { // see if Ethernet is connected if (ethernet_connected) { - root["status"] = 10; // custom code #10 - ETHERNET_STATUS_CONNECTED + root["status"] = 10; // custom code #10 - ETHERNET_STATUS_CONNECTED + root["hostname"] = ETH.getHostname(); } else { - root["status"] = (uint8_t)wifi_status; + root["status"] = (uint8_t)wifi_status; + root["hostname"] = WiFi.getHostname(); } // for both connections show ethernet diff --git a/mock-api/Handler.ts b/mock-api/Handler.ts index fc519a0eb..13c39e707 100644 --- a/mock-api/Handler.ts +++ b/mock-api/Handler.ts @@ -249,7 +249,8 @@ const network_status = { subnet_mask: '255.255.255.0', gateway_ip: '10.10.10.1', dns_ip_1: '10.10.10.1', - dns_ip_2: '0.0.0.0' + dns_ip_2: '0.0.0.0', + hostname: 'ems-esp' }; const list_networks = { networks: [ @@ -650,9 +651,9 @@ const emsesp_devices = { }; const emsesp_coredata = { - connected: true, - // devices: [], - devices: [ + connected: false, + devices: [], + devices2: [ { id: 7, t: 4, From d16e77bba3693f0d0e81add3e24583fbf055078f Mon Sep 17 00:00:00 2001 From: Proddy Date: Wed, 3 Jan 2024 23:56:31 +0100 Subject: [PATCH 11/22] updated example --- pio_local.ini_example | 69 ++++++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 24 deletions(-) diff --git a/pio_local.ini_example b/pio_local.ini_example index 99fa32ed0..65f1a9177 100644 --- a/pio_local.ini_example +++ b/pio_local.ini_example @@ -1,7 +1,7 @@ -; example custom platformio.ini file for EMS-ESP +; example custom platformio ini file for EMS-ESP [common] -; custom build flags: +; custom build flags to use in my_build_flags ; -DEMSESP_WIFI_TWEAK ; experimental WiFi tweaks for stability ; -DEMSESP_UART_DEBUG ; debugging UART ; -DEMSESP_DEBUG ; enables DEBUG to the log. Will generate a lot of extra traffic on Console and Syslog @@ -11,42 +11,65 @@ ; -DEMSESP_TEST ; enable the tests. EN language only ; -DEMSESP_DE_ONLY ; only DE translated entity names ; -DEMSESP_EN_ONLY ; only EN translated entity names -; my_build_flags = -DEMSESP_DEBUG +; my_build_flags = -DEMSESP_TEST +; my_build_flags = -DEMSESP_DEBUG -DEMSESP_TEST [platformio] -default_envs = esp32_4M +; default_envs = esp32_4M ; default_envs = esp32_16M ; default_envs = lolin_s3 ; default_envs = standalone -; default_envs = debug +; default_envs = debug +; default_envs = custom [env:esp32_4M] -; update to arduino 3, IDF 5 -platform = https://github.com/Jason2866/platform-espressif32.git#Arduino/IDF5 -; ; if using OTA enter your details below ; upload_protocol = espota ; upload_flags = ; --port=8266 ; --auth=ems-esp-neo ; upload_port = ems-esp.local -; for USB use -upload_port = /dev/ttyUSB* +; for USB use one of these: +; upload_port = /dev/ttyUSB* ; upload_port = COM5 -; override arduino espressif core -platform = espressif32 ; take latest -; platform = espressif32@5.3.0 -; platform = espressif32@6.3.2 -; platform = espressif32@6.4.0 - -extra_scripts = - pre:scripts/build_interface.py ; comment out if you don't want to re-build the WebUI each time - scripts/rename_fw.py - ; post:scripts/app-tls-size.py - [env:esp32_16M] +[env:custom] +; use for ESP-S boards with 4MB flash +platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.10.03/platform-espressif32-2023.10.03.zip +; use for S3 boards: +; platform = espressif32 +framework = arduino +board = esp32dev +board_build.filesystem = littlefs +board_build.f_cpu = 240000000L +board_upload.flash_size = 4MB +board_build.partitions = esp32_partition_4M.csv +board_upload.use_1200bps_touch = false +board_upload.wait_for_upload_port = true +upload_port = /dev/ttyUSB0 +extra_scripts = + pre:scripts/build_interface.py + scripts/rename_fw.py +build_unflags = ${common.unbuild_flags} +build_flags = + ${common.core_build_flags} + ${factory_settings.build_flags} + ${common.my_build_flags} + -D ONEWIRE_CRC16=0 + -D NO_GLOBAL_ARDUINOOTA + -D ARDUINOJSON_ENABLE_STD_STRING=1 + -D ARDUINOJSON_USE_DOUBLE=0 + ; -D ARDUINOTRACE_ENABLE=1 + -D TASMOTA_SDK + ; -D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_WARN + -D EMSESP_TEST + -D EMSESP_DEBUG + -D CONFIG_ETH_ENABLED + -D TASMOTA_SDK + '-DEMSESP_DEFAULT_BOARD_PROFILE="Test"' + [env:lolin_s3] upload_port = /dev/ttyACM0 extra_scripts = @@ -61,7 +84,6 @@ board = esp32dev framework = arduino platform = espressif32 board_build.partitions = esp32_partition_debug.csv -; board_build.partitions = esp32_partition_4M.csv board_upload.flash_size = 4MB board_build.filesystem = littlefs upload_protocol = esptool @@ -73,6 +95,5 @@ debug_init_break = tbreak setup build_flags = ${factory_settings.build_flags} -DEMSESP_EN_ONLY -DCORE_DEBUG_LEVEL=5 -DONEWIRE_CRC16=0 -DNO_GLOBAL_ARDUINOOTA -DARDUINOJSON_ENABLE_STD_STRING=1 -DESP32=1 -DARDUINO_ARCH_ESP32=1 upload_port = /dev/ttyUSB0 extra_scripts = - ; pre:scripts/build_interface.py ; comment out if you don't want to re-build the WebUI each time scripts/rename_fw.py - ; post:scripts/app-tls-size.py + post:scripts/app-tls-size.py From 55ce551868c17016837db456b3743dd1ebc13e7c Mon Sep 17 00:00:00 2001 From: Proddy Date: Wed, 3 Jan 2024 23:56:52 +0100 Subject: [PATCH 12/22] added hostname to network status --- interface/src/types/network.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/interface/src/types/network.ts b/interface/src/types/network.ts index 70df69b1c..8740eb9b4 100644 --- a/interface/src/types/network.ts +++ b/interface/src/types/network.ts @@ -33,6 +33,7 @@ export interface NetworkStatus { gateway_ip: string; dns_ip_1: string; dns_ip_2: string; + hostname: string; } export interface NetworkSettings { From 3f42c4d56ba1650e7be324e5b504ce1c8b6ef866 Mon Sep 17 00:00:00 2001 From: Proddy Date: Wed, 3 Jan 2024 23:57:00 +0100 Subject: [PATCH 13/22] fix typo --- interface/src/project/DashboardDevices.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/project/DashboardDevices.tsx b/interface/src/project/DashboardDevices.tsx index 4fb862693..f59047e3f 100644 --- a/interface/src/project/DashboardDevices.tsx +++ b/interface/src/project/DashboardDevices.tsx @@ -420,7 +420,7 @@ const DashboardDevices: FC = () => { )} - {coreData.devices.length && ( + {coreData.devices.length !== 0 && (
{(tableList: any) => ( <> From b6dbf93de284daad4fb779cf20f2c1a839c402b1 Mon Sep 17 00:00:00 2001 From: Proddy Date: Thu, 4 Jan 2024 18:08:31 +0100 Subject: [PATCH 14/22] add missing setContentType --- lib_standalone/AsyncJson.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib_standalone/AsyncJson.h b/lib_standalone/AsyncJson.h index 2ec4a6322..265b96a22 100644 --- a/lib_standalone/AsyncJson.h +++ b/lib_standalone/AsyncJson.h @@ -175,6 +175,9 @@ class AsyncJsonResponse { void setCode(uint16_t) { } + + void setContentType(const char * s) { + } }; typedef std::function ArJsonRequestHandlerFunction; From b0076cd5dac099d634975275f3c9140f0ccddd44 Mon Sep 17 00:00:00 2001 From: Proddy Date: Thu, 4 Jan 2024 18:08:41 +0100 Subject: [PATCH 15/22] change comments --- interface/src/project/api.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/project/api.ts b/interface/src/project/api.ts index 98d65f92f..509e238e1 100644 --- a/interface/src/project/api.ts +++ b/interface/src/project/api.ts @@ -20,7 +20,7 @@ export const readCoreData = () => alovaInstance.Get(`/rest/coreData`); export const readDeviceData = (id: number) => alovaInstance.Get('/rest/deviceData', { // alovaInstance.Get(`/rest/deviceData/${id}`, { - params: { id }, // TODO remove later + params: { id }, // TODO replace later responseType: 'arraybuffer' // uses msgpack }); export const writeDeviceValue = (data: any) => alovaInstance.Post('/rest/writeDeviceValue', data); @@ -56,7 +56,7 @@ export const getSchedule = () => alovaInstance.Get('/rest/getSchedule'); export const readDeviceEntities = (id: number) => // alovaInstance.Get(`/rest/deviceEntities/${id}`, { alovaInstance.Get(`/rest/deviceEntities`, { - params: { id }, // TODO remove later + params: { id }, // TODO replace later responseType: 'arraybuffer', transformData(data: any) { return data.map((de: DeviceEntity) => ({ ...de, o_m: de.m, o_cn: de.cn, o_mi: de.mi, o_ma: de.ma })); From a3b6656be79905e635ae87562c97781d457384a0 Mon Sep 17 00:00:00 2001 From: Proddy Date: Thu, 4 Jan 2024 18:09:00 +0100 Subject: [PATCH 16/22] add additional Domoticz to discovery_type --- interface/src/framework/mqtt/MqttSettingsForm.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/interface/src/framework/mqtt/MqttSettingsForm.tsx b/interface/src/framework/mqtt/MqttSettingsForm.tsx index 6b1d1323b..6a8688dbf 100644 --- a/interface/src/framework/mqtt/MqttSettingsForm.tsx +++ b/interface/src/framework/mqtt/MqttSettingsForm.tsx @@ -273,6 +273,7 @@ const MqttSettingsForm: FC = () => { > Home Assistant Domoticz + Domoticz (latest) From 4c27cb831e2c3708b9f91c9272ae2b266b8b24c3 Mon Sep 17 00:00:00 2001 From: Proddy Date: Thu, 4 Jan 2024 18:09:18 +0100 Subject: [PATCH 17/22] update tests for temp sensors --- src/test/test.cpp | 3 ++- src/test/test.h | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/test.cpp b/src/test/test.cpp index 2503eea88..ce12a7fdd 100644 --- a/src/test/test.cpp +++ b/src/test/test.cpp @@ -286,7 +286,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const emsesp::EMSESP::temperaturesensor_.test(); // shell.invoke_command("show devices"); - shell.invoke_command("show values"); + // shell.invoke_command("show values"); shell.invoke_command("call system allvalues"); // shell.invoke_command("call system publish"); // shell.invoke_command("show mqtt"); @@ -705,6 +705,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const if (command == "temperature") { shell.printfln("Testing adding Temperature sensor"); emsesp::EMSESP::temperaturesensor_.test(); + shell.invoke_command("show values"); ok = true; } diff --git a/src/test/test.h b/src/test/test.h index 1ae7a5a83..5bf4d8641 100644 --- a/src/test/test.h +++ b/src/test/test.h @@ -58,7 +58,6 @@ namespace emsesp { // #define EMSESP_DEBUG_DEFAULT "custom_entities" // #define EMSESP_DEBUG_DEFAULT "heat_exchange" - class Test { public: static void run_test(uuid::console::Shell & shell, const std::string & command, const std::string & data = ""); From 9ca47627d263bd30fba2e826fd10bcc6032e9e2e Mon Sep 17 00:00:00 2001 From: Proddy Date: Thu, 4 Jan 2024 18:09:29 +0100 Subject: [PATCH 18/22] updated example pio --- pio_local.ini_example | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pio_local.ini_example b/pio_local.ini_example index 65f1a9177..6ac2a6cb1 100644 --- a/pio_local.ini_example +++ b/pio_local.ini_example @@ -20,7 +20,7 @@ ; default_envs = lolin_s3 ; default_envs = standalone ; default_envs = debug -; default_envs = custom +default_envs = custom [env:esp32_4M] ; if using OTA enter your details below @@ -37,6 +37,7 @@ [env:custom] ; use for ESP-S boards with 4MB flash +; make sure -D TASMOTA_SDK is also enabled platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.10.03/platform-espressif32-2023.10.03.zip ; use for S3 boards: ; platform = espressif32 @@ -50,7 +51,7 @@ board_upload.use_1200bps_touch = false board_upload.wait_for_upload_port = true upload_port = /dev/ttyUSB0 extra_scripts = - pre:scripts/build_interface.py + ; pre:scripts/build_interface.py scripts/rename_fw.py build_unflags = ${common.unbuild_flags} build_flags = @@ -66,8 +67,8 @@ build_flags = ; -D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_WARN -D EMSESP_TEST -D EMSESP_DEBUG - -D CONFIG_ETH_ENABLED - -D TASMOTA_SDK + -D CONFIG_ETH_ENABLED + ; -D TASMOTA_SDK '-DEMSESP_DEFAULT_BOARD_PROFILE="Test"' [env:lolin_s3] From 35ee8c33b3343c8e8fc18c56dbf1fb032ee855da Mon Sep 17 00:00:00 2001 From: Proddy Date: Thu, 4 Jan 2024 18:09:42 +0100 Subject: [PATCH 19/22] add comment --- src/temperaturesensor.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/temperaturesensor.h b/src/temperaturesensor.h index 3d7363054..f4350707f 100644 --- a/src/temperaturesensor.h +++ b/src/temperaturesensor.h @@ -62,6 +62,7 @@ class TemperatureSensor { bool apply_customization(); + // initial values int16_t temperature_c = EMS_VALUE_SHORT_NOTSET; bool read = false; bool ha_registered = false; From 591b8afcb0748dbf061dace8617b2330ab5fe721 Mon Sep 17 00:00:00 2001 From: Proddy Date: Thu, 4 Jan 2024 18:10:16 +0100 Subject: [PATCH 20/22] restructuring and added additional domoticz support --- src/temperaturesensor.cpp | 59 +++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/src/temperaturesensor.cpp b/src/temperaturesensor.cpp index 504853eb3..ba209fc7a 100644 --- a/src/temperaturesensor.cpp +++ b/src/temperaturesensor.cpp @@ -108,11 +108,14 @@ void TemperatureSensor::loop() { if (++scanretry_ > SCAN_MAX) { // every 30 sec scanretry_ = 0; #ifdef EMSESP_DEBUG_SENSOR - LOG_ERROR("Bus reset failed"); + LOG_DEBUG("Error: Bus reset failed"); #endif +#ifndef EMSESP_TEST + // don't reset if running in test mode where we simulate sensors for (auto & sensor : sensors_) { sensor.temperature_c = EMS_VALUE_SHORT_NOTSET; } +#endif } } } @@ -202,6 +205,7 @@ void TemperatureSensor::loop() { bus_.depower(); } // check for missing sensors after some samples + // but don't do this if running in test mode where we simulate sensors if (++scancnt_ > SCAN_MAX) { for (auto & sensor : sensors_) { if (!sensor.read) { @@ -309,6 +313,7 @@ bool TemperatureSensor::update(const std::string & id, const std::string & name, // if HA is enabled then delete the old record if (Mqtt::ha_enabled()) { remove_ha_topic(id); + sensor.ha_registered = false; // force HA configs to be re-created } sensor.set_name(name); @@ -458,6 +463,7 @@ void TemperatureSensor::remove_ha_topic(const std::string & id) { if (!Mqtt::ha_enabled()) { return; } + LOG_DEBUG("Removing HA config for temperature sensor ID %s", id.c_str()); // use '_' as HA doesn't like '-' in the topic name std::string sensorid = id; @@ -474,7 +480,6 @@ void TemperatureSensor::publish_values(const bool force) { } uint8_t num_sensors = sensors_.size(); - if (num_sensors == 0) { return; } @@ -485,19 +490,30 @@ void TemperatureSensor::publish_values(const bool force) { } } - DynamicJsonDocument doc(120 * num_sensors); + DynamicJsonDocument doc(150 * num_sensors); + + // used to see if we need to create the [devs] discovery section, as this needs only to be done once for all sensors + bool is_first_ha = true; + if (Mqtt::ha_enabled()) { + for (auto & sensor : sensors_) { + if (sensor.ha_registered) { + is_first_ha = false; + break; + } + } + } for (auto & sensor : sensors_) { bool has_value = Helpers::hasValue(sensor.temperature_c); - char val[10]; - if (Mqtt::is_nested()) { - JsonObject dataSensor = doc.createNestedObject(sensor.id()); - dataSensor["name"] = sensor.name(); - if (has_value) { - dataSensor["temp"] = serialized(Helpers::render_value(val, sensor.temperature_c, 10, EMSESP::system_.fahrenheit() ? 2 : 0)); + if (has_value) { + char val[10]; + if (Mqtt::is_nested()) { + JsonObject dataSensor = doc.createNestedObject(sensor.id()); + dataSensor["name"] = sensor.name(); + dataSensor["temp"] = serialized(Helpers::render_value(val, sensor.temperature_c, 10, EMSESP::system_.fahrenheit() ? 2 : 0)); + } else { + doc[sensor.name()] = serialized(Helpers::render_value(val, sensor.temperature_c, 10, EMSESP::system_.fahrenheit() ? 2 : 0)); } - } else if (has_value) { - doc[sensor.name()] = serialized(Helpers::render_value(val, sensor.temperature_c, 10, EMSESP::system_.fahrenheit() ? 2 : 0)); } // create the HA MQTT config @@ -509,7 +525,7 @@ void TemperatureSensor::publish_values(const bool force) { } else if (!sensor.ha_registered || force) { LOG_DEBUG("Recreating HA config for sensor ID %s", sensor.id().c_str()); - StaticJsonDocument config; + StaticJsonDocument config; // this needs to be large because of all the copying in add_ha_sections_to_doc() config["dev_cla"] = "temperature"; char stat_t[50]; @@ -518,8 +534,8 @@ void TemperatureSensor::publish_values(const bool force) { config["unit_of_meas"] = EMSdevice::uom_to_string(DeviceValueUOM::DEGREES); - char val_obj[50]; - char val_cond[95]; + char val_obj[70]; + char val_cond[170]; if (Mqtt::is_nested()) { 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 and %s is defined", sensor.id().c_str(), val_obj); @@ -530,10 +546,10 @@ void TemperatureSensor::publish_values(const bool force) { // for the value template, there's a problem still with Domoticz probably due to the special characters. // See https://github.com/emsesp/EMS-ESP32/issues/1360 - if (Mqtt::discovery_type() == Mqtt::discoveryType::DOMOTICZ) { - config["val_tpl"] = (std::string) "{{" + val_obj + "}}"; - } else { + if (Mqtt::discovery_type() == Mqtt::discoveryType::HOMEASSISTANT) { config["val_tpl"] = (std::string) "{{" + val_obj + " if " + val_cond + " else -55}}"; + } else { + config["val_tpl"] = (std::string) "{{" + val_obj + "}}"; // ommit value conditional Jinja2 template code } char uniq_s[70]; @@ -550,7 +566,7 @@ void TemperatureSensor::publish_values(const bool force) { snprintf(name, sizeof(name), "%s", sensor.name().c_str()); config["name"] = name; - Mqtt::add_ha_sections_to_doc("temperature", stat_t, config.as(), true, val_cond); + Mqtt::add_ha_sections_to_doc("temperature", stat_t, config.as(), is_first_ha, val_cond); char topic[Mqtt::MQTT_TOPIC_MAX_SIZE]; // use '_' as HA doesn't like '-' in the topic name @@ -569,7 +585,6 @@ void TemperatureSensor::publish_values(const bool force) { Mqtt::queue_publish(topic, doc.as()); } - // skip crc from id TemperatureSensor::Sensor::Sensor(const uint8_t addr[]) : internal_id_(((uint64_t)addr[0] << 48) | ((uint64_t)addr[1] << 40) | ((uint64_t)addr[2] << 32) | ((uint64_t)addr[3] << 24) | ((uint64_t)addr[4] << 16) @@ -629,15 +644,17 @@ void TemperatureSensor::test() { // add 2 temperature sensors uint8_t addr[ADDR_LEN] = {1, 2, 3, 4, 5, 6, 7, 8}; sensors_.emplace_back(addr); + // sensors_.back().apply_customization(); sensors_.back().temperature_c = 123; sensors_.back().read = true; - sensors_.back().apply_customization(); + publish_sensor(sensors_.back()); // call publish single uint8_t addr2[ADDR_LEN] = {11, 12, 13, 14, 15, 16, 17, 18}; sensors_.emplace_back(addr2); + // sensors_.back().apply_customization(); sensors_.back().temperature_c = 456; sensors_.back().read = true; - sensors_.back().apply_customization(); + publish_sensor(sensors_.back()); // call publish single } #endif From e62fc14b6dc9d9a1a99d1fb91e6af4ac85e43b87 Mon Sep 17 00:00:00 2001 From: Proddy Date: Thu, 4 Jan 2024 18:10:53 +0100 Subject: [PATCH 21/22] support domoticz - MQTT autodiscovery in Domoticz not working #1360 --- src/mqtt.cpp | 37 +++++++++++++++++------------- src/mqtt.h | 4 ++-- src/web/WebCustomEntityService.cpp | 2 +- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/mqtt.cpp b/src/mqtt.cpp index 0a96f0cea..6a5a24edf 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -863,8 +863,8 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev case DeviceValueType::USHORT: case DeviceValueType::ULONG: // number - https://www.home-assistant.io/integrations/number.mqtt - // Domoticz does not support number, use sensor - if (discovery_type() == discoveryType::HOMEASSISTANT) { + // older Domoticz does not support number, use sensor + if (discovery_type() == discoveryType::HOMEASSISTANT || discovery_type() == discoveryType::DOMOTICZ_LATEST) { snprintf(topic, sizeof(topic), "number/%s", config_topic); readonly_sensors = false; } else { @@ -1296,39 +1296,44 @@ void Mqtt::add_ha_sections_to_doc(const std::string & name, } // adds "availability" section to HA Discovery config - // but not for Domoticz - if (discovery_type() == discoveryType::HOMEASSISTANT) { - const char * tpl_draft = "{{'online' if %s else 'offline'}}"; - char tpl[150]; - JsonArray avty = config.createNestedArray("avty"); + JsonArray avty = config.createNestedArray("avty"); + StaticJsonDocument avty_json; - StaticJsonDocument<512> avty_json; + const char * tpl_draft = "{{'online' if %s else 'offline'}}"; - 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); + // EMS-ESP status check + char tpl[150]; + 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); // returns 0 if no mem + + // skip conditional Jinja2 templates if not home assistant + if (discovery_type() == discoveryType::HOMEASSISTANT) { + // condition 1 avty_json.clear(); 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); + avty.add(avty_json); // returns 0 if no mem + // condition 2 if (cond2 != nullptr) { avty_json.clear(); avty_json["t"] = state_t; snprintf(tpl, sizeof(tpl), tpl_draft, cond2); avty_json["val_tpl"] = tpl; - avty.add(avty_json); + avty.add(avty_json); // returns 0 if no mem } + // negative condition if (negcond != nullptr) { avty_json.clear(); avty_json["t"] = state_t; snprintf(tpl, sizeof(tpl), "{{'offline' if %s else 'online'}}", negcond); avty_json["val_tpl"] = tpl; - avty.add(avty_json); + avty.add(avty_json); // returns 0 if no mem } config["avty_mode"] = "all"; diff --git a/src/mqtt.h b/src/mqtt.h index 6854cc334..c965e0e51 100644 --- a/src/mqtt.h +++ b/src/mqtt.h @@ -35,7 +35,7 @@ using mqtt_sub_function_p = std::function; class Mqtt { public: - enum discoveryType : uint8_t { HOMEASSISTANT, DOMOTICZ }; + enum discoveryType : uint8_t { HOMEASSISTANT, DOMOTICZ, DOMOTICZ_LATEST }; enum entityFormat : uint8_t { SINGLE_LONG, SINGLE_SHORT, MULTI_SHORT }; void loop(); @@ -219,7 +219,7 @@ class Mqtt { static void add_ha_sections_to_doc(const std::string & name, const char * state_t, - const JsonObject & doc, + const JsonObject & config, const bool is_first = false, const char * cond1 = nullptr, const char * cond2 = nullptr, diff --git a/src/web/WebCustomEntityService.cpp b/src/web/WebCustomEntityService.cpp index 4f318a07f..7eaed6026 100644 --- a/src/web/WebCustomEntityService.cpp +++ b/src/web/WebCustomEntityService.cpp @@ -397,7 +397,7 @@ void WebCustomEntityService::publish(const bool force) { snprintf(topic, sizeof(topic), "switch/%s/custom_%s/config", Mqtt::basename().c_str(), entityItem.name.c_str()); } else if (entityItem.value_type == DeviceValueType::STRING) { snprintf(topic, sizeof(topic), "sensor/%s/custom_%s/config", Mqtt::basename().c_str(), entityItem.name.c_str()); - } else if (Mqtt::discovery_type() == Mqtt::discoveryType::HOMEASSISTANT) { + } else if (Mqtt::discovery_type() == Mqtt::discoveryType::HOMEASSISTANT || Mqtt::discovery_type() == Mqtt::discoveryType::DOMOTICZ_LATEST) { snprintf(topic, sizeof(topic), "number/%s/custom_%s/config", Mqtt::basename().c_str(), entityItem.name.c_str()); } else { snprintf(topic, sizeof(topic), "sensor/%s/custom_%s/config", Mqtt::basename().c_str(), entityItem.name.c_str()); From df33a24951f204a5bed5242342a240dcfa295af4 Mon Sep 17 00:00:00 2001 From: Proddy Date: Thu, 4 Jan 2024 18:11:08 +0100 Subject: [PATCH 22/22] fix add_ha_sections_to_doc calls --- src/shower.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/shower.cpp b/src/shower.cpp index aba136de1..ba2a912f0 100644 --- a/src/shower.cpp +++ b/src/shower.cpp @@ -210,7 +210,7 @@ void Shower::set_shower_state(bool state, bool force) { doc["pl_off"] = Helpers::render_boolean(result, false); } - Mqtt::add_ha_sections_to_doc("shower", stat_t, doc.as(), true); + Mqtt::add_ha_sections_to_doc("shower", stat_t, doc.as(), true); // create first dev & ids snprintf(topic, sizeof(topic), "binary_sensor/%s/shower_active/config", Mqtt::basename().c_str()); ha_configdone_ = Mqtt::queue_ha(topic, doc.as()); // publish the config payload with retain flag @@ -235,7 +235,7 @@ void Shower::set_shower_state(bool state, bool force) { doc["dev_cla"] = "duration"; // doc["ent_cat"] = "diagnostic"; - Mqtt::add_ha_sections_to_doc("shower", stat_t, doc.as(), "value_json.duration is defined"); + Mqtt::add_ha_sections_to_doc("shower", stat_t, doc.as(), false, "value_json.duration is defined"); snprintf(topic, sizeof(topic), "sensor/%s/shower_duration/config", Mqtt::basename().c_str()); Mqtt::queue_ha(topic, doc.as()); // publish the config payload with retain flag @@ -257,7 +257,7 @@ void Shower::set_shower_state(bool state, bool force) { doc["val_tpl"] = "{{value_json.timestamp if value_json.timestamp is defined else 0}}"; // doc["ent_cat"] = "diagnostic"; - Mqtt::add_ha_sections_to_doc("shower", stat_t, doc.as(), "value_json.timestamp is defined"); + Mqtt::add_ha_sections_to_doc("shower", stat_t, doc.as(), false, "value_json.timestamp is defined"); snprintf(topic, sizeof(topic), "sensor/%s/shower_timestamp/config", Mqtt::basename().c_str()); Mqtt::queue_ha(topic, doc.as()); // publish the config payload with retain flag