From 0a06d374137d678eb8369d05aa54b2f04c357598 Mon Sep 17 00:00:00 2001 From: Tomer <57483589+tomer-w@users.noreply.github.com> Date: Sat, 7 Sep 2024 19:13:52 +0300 Subject: [PATCH 01/23] Improve log performance --- data/configuration.yaml | 25 +- lib/util/logger.ts | 28 ++- package-lock.json | 518 +++++++--------------------------------- package.json | 4 +- 4 files changed, 112 insertions(+), 463 deletions(-) diff --git a/data/configuration.yaml b/data/configuration.yaml index 3ed7c1ce00..83daf87397 100644 --- a/data/configuration.yaml +++ b/data/configuration.yaml @@ -1,20 +1,15 @@ -# Home Assistant integration (MQTT discovery) homeassistant: false - -# allow new devices to join permit_join: true - -# MQTT settings +frontend: true mqtt: - # MQTT base topic for zigbee2mqtt MQTT messages base_topic: zigbee2mqtt - # MQTT server URL - server: 'mqtt://localhost' - # MQTT server authentication, uncomment if required: - # user: my_user - # password: my_password - -# Serial settings + server: mqtt://localhost serial: - # Location of CC2531 USB sniffer - port: /dev/ttyACM0 + port: COM7 + adapter: deconz + adapter_delay: 200 +advanced: + log_level: debug +devices: + '0x00124b00271f9834': + friendly_name: '0x00124b00271f9834' diff --git a/lib/util/logger.ts b/lib/util/logger.ts index 71ea89a7cf..25cc86b695 100644 --- a/lib/util/logger.ts +++ b/lib/util/logger.ts @@ -182,32 +182,40 @@ class Logger { return this.cachedNamespacedLevels[namespace]; } - private log(level: settings.LogLevel, message: string, namespace: string): void { + private log(level: settings.LogLevel, messageOrLambda: string | (() => string), namespace: string): void { + if (this.isEnabled(level, namespace)) { + const message:string = (typeof messageOrLambda === "string") ? messageOrLambda : messageOrLambda() ; + this.logger.log(level, `${namespace}: ${message}`); + } + } + + public isEnabled(level: settings.LogLevel, namespace: string): boolean { const nsLevel = this.cacheNamespacedLevel(namespace); if (settings.LOG_LEVELS.indexOf(level) <= settings.LOG_LEVELS.indexOf(nsLevel)) { - this.logger.log(level, `${namespace}: ${message}`); + return true; } + return false; } - public error(message: string, namespace: string = 'z2m'): void { - this.log('error', message, namespace); + public error(messageOrLambda: string | (() => string), namespace: string = 'z2m'): void { + this.log('error', messageOrLambda, namespace); } - public warning(message: string, namespace: string = 'z2m'): void { - this.log('warning', message, namespace); + public warning(messageOrLambda: string | (() => string), namespace: string = 'z2m'): void { + this.log('warning', messageOrLambda, namespace); } - public info(message: string, namespace: string = 'z2m'): void { - this.log('info', message, namespace); + public info(messageOrLambda: string | (() => string), namespace: string = 'z2m'): void { + this.log('info', messageOrLambda, namespace); } - public debug(message: string, namespace: string = 'z2m'): void { + public debug(messageOrLambda: string | (() => string), namespace: string = 'z2m'): void { if (this.debugNamespaceIgnoreRegex?.test(namespace)) { return; } - this.log('debug', message, namespace); + this.log('debug', messageOrLambda, namespace); } // Cleanup any old log directory. diff --git a/package-lock.json b/package-lock.json index cd17d5c54a..4dbda3dc8f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,8 +32,8 @@ "winston-syslog": "^2.7.1", "winston-transport": "^4.7.1", "ws": "^8.18.0", - "zigbee-herdsman": "0.57.1", - "zigbee-herdsman-converters": "20.8.4", + "zigbee-herdsman": "file:../zigbee-herdsman", + "zigbee-herdsman-converters": "file:../zigbee-herdsman-converters", "zigbee2mqtt-frontend": "0.7.4" }, "bin": { @@ -71,6 +71,82 @@ "sd-notify": "^2.8.0" } }, + "../zigbee-herdsman": { + "version": "0.57.2", + "license": "MIT", + "dependencies": { + "@serialport/bindings-cpp": "^12.0.1", + "@serialport/parser-delimiter": "^12.0.0", + "@serialport/stream": "^12.0.0", + "bonjour-service": "^1.2.1", + "debounce": "^2.1.0", + "fast-deep-equal": "^3.1.3", + "mixin-deep": "^2.0.1", + "slip": "^1.0.2" + }, + "devDependencies": { + "@babel/cli": "^7.25.6", + "@babel/core": "^7.25.2", + "@babel/preset-env": "^7.25.4", + "@babel/preset-typescript": "^7.24.7", + "@eslint/js": "^9.9.1", + "@ianvs/prettier-plugin-sort-imports": "^4.3.1", + "@serialport/binding-mock": "^10.2.2", + "@types/debounce": "^1.2.4", + "@types/eslint__js": "^8.42.3", + "@types/jest": "^29.5.12", + "@types/mz": "^2.7.8", + "@types/nedb": "^1.8.16", + "@types/node": "^22.5.1", + "babel-jest": "^29.7.0", + "eslint": "^9.9.1", + "eslint-config-prettier": "^9.1.0", + "jest": "^29.7.0", + "prettier": "^3.3.3", + "regenerator-runtime": "^0.14.1", + "rimraf": "^6.0.1", + "typedoc": "^0.26.6", + "typedoc-plugin-markdown": "^4.2.6", + "typedoc-plugin-no-inherit": "^1.4.0", + "typescript": "^5.5.4", + "typescript-eslint": "^8.3.0" + } + }, + "../zigbee-herdsman-converters": { + "version": "20.12.2", + "license": "MIT", + "dependencies": { + "axios": "^1.7.7", + "buffer-crc32": "^1.0.0", + "https-proxy-agent": "^7.0.5", + "iconv-lite": "^0.6.3", + "semver": "^7.6.3", + "tar-stream": "^3.1.7", + "zigbee-herdsman": "^0.57.3" + }, + "devDependencies": { + "@types/buffer-crc32": "^0.2.4", + "@types/jest": "^29.5.12", + "@types/node": "^22.5.4", + "@types/semver": "^7.5.8", + "@types/tar-stream": "^3.1.3", + "@typescript-eslint/eslint-plugin": "^8.4.0", + "@typescript-eslint/parser": "^8.4.0", + "eslint": "^8.57.0", + "eslint-config-prettier": "^9.1.0", + "eslint-plugin-jest": "^28.8.3", + "eslint-plugin-perfectionist": "^3.4.0", + "eslint-plugin-tsdoc": "^0.3.0", + "fast-deep-equal": "*", + "husky": "^9.1.5", + "jest": "^29.7.0", + "prettier": "^3.3.3", + "rimraf": "^6.0.1", + "ts-jest": "^29.2.5", + "ts-morph": "^23.0.0", + "typescript": "^5.5.4" + } + }, "node_modules/@ampproject/remapping": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", @@ -3145,12 +3221,6 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, - "node_modules/@leichtgewicht/ip-codec": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@leichtgewicht/ip-codec/-/ip-codec-2.0.5.tgz", - "integrity": "sha512-Vo+PSpZG2/fmgmiNzYK9qWRh8h/CHrwD0mo1h1DzL4yzHNSfWYujGTYsWGreD000gcgmZ7K4Ys6Tx9TxtsKdDw==", - "license": "MIT" - }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -3199,124 +3269,6 @@ "node": ">=14" } }, - "node_modules/@serialport/bindings-cpp": { - "version": "12.0.1", - "resolved": "https://registry.npmjs.org/@serialport/bindings-cpp/-/bindings-cpp-12.0.1.tgz", - "integrity": "sha512-r2XOwY2dDvbW7dKqSPIk2gzsr6M6Qpe9+/Ngs94fNaNlcTRCV02PfaoDmRgcubpNVVcLATlxSxPTIDw12dbKOg==", - "hasInstallScript": true, - "license": "MIT", - "dependencies": { - "@serialport/bindings-interface": "1.2.2", - "@serialport/parser-readline": "11.0.0", - "debug": "4.3.4", - "node-addon-api": "7.0.0", - "node-gyp-build": "4.6.0" - }, - "engines": { - "node": ">=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/serialport/donate" - } - }, - "node_modules/@serialport/bindings-cpp/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "license": "MIT", - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/@serialport/bindings-interface": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/@serialport/bindings-interface/-/bindings-interface-1.2.2.tgz", - "integrity": "sha512-CJaUd5bLvtM9c5dmO9rPBHPXTa9R2UwpkJ0wdh9JCYcbrPWsKz+ErvR0hBLeo7NPeiFdjFO4sonRljiw4d2XiA==", - "license": "MIT", - "engines": { - "node": "^12.22 || ^14.13 || >=16" - } - }, - "node_modules/@serialport/parser-delimiter": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/@serialport/parser-delimiter/-/parser-delimiter-12.0.0.tgz", - "integrity": "sha512-gu26tVt5lQoybhorLTPsH2j2LnX3AOP2x/34+DUSTNaUTzu2fBXw+isVjQJpUBFWu6aeQRZw5bJol5X9Gxjblw==", - "license": "MIT", - "engines": { - "node": ">=12.0.0" - }, - "funding": { - "url": "https://opencollective.com/serialport/donate" - } - }, - "node_modules/@serialport/parser-readline": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/@serialport/parser-readline/-/parser-readline-11.0.0.tgz", - "integrity": "sha512-rRAivhRkT3YO28WjmmG4FQX6L+KMb5/ikhyylRfzWPw0nSXy97+u07peS9CbHqaNvJkMhH1locp2H36aGMOEIA==", - "license": "MIT", - "dependencies": { - "@serialport/parser-delimiter": "11.0.0" - }, - "engines": { - "node": ">=12.0.0" - }, - "funding": { - "url": "https://opencollective.com/serialport/donate" - } - }, - "node_modules/@serialport/parser-readline/node_modules/@serialport/parser-delimiter": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/@serialport/parser-delimiter/-/parser-delimiter-11.0.0.tgz", - "integrity": "sha512-aZLJhlRTjSmEwllLG7S4J8s8ctRAS0cbvCpO87smLvl3e4BgzbVgF6Z6zaJd3Aji2uSiYgfedCdNc4L6W+1E2g==", - "license": "MIT", - "engines": { - "node": ">=12.0.0" - }, - "funding": { - "url": "https://opencollective.com/serialport/donate" - } - }, - "node_modules/@serialport/stream": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/@serialport/stream/-/stream-12.0.0.tgz", - "integrity": "sha512-9On64rhzuqKdOQyiYLYv2lQOh3TZU/D3+IWCR5gk0alPel2nwpp4YwDEGiUBfrQZEdQ6xww0PWkzqth4wqwX3Q==", - "license": "MIT", - "dependencies": { - "@serialport/bindings-interface": "1.2.2", - "debug": "4.3.4" - }, - "engines": { - "node": ">=12.0.0" - }, - "funding": { - "url": "https://opencollective.com/serialport/donate" - } - }, - "node_modules/@serialport/stream/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "license": "MIT", - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, "node_modules/@sinclair/typebox": { "version": "0.27.8", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", @@ -3758,18 +3710,6 @@ "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, - "node_modules/agent-base": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.1.tgz", - "integrity": "sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA==", - "license": "MIT", - "dependencies": { - "debug": "^4.3.4" - }, - "engines": { - "node": ">= 14" - } - }, "node_modules/ajv": { "version": "8.17.1", "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", @@ -3860,29 +3800,6 @@ "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==", "license": "MIT" }, - "node_modules/asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", - "license": "MIT" - }, - "node_modules/axios": { - "version": "1.7.7", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz", - "integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==", - "license": "MIT", - "dependencies": { - "follow-redirects": "^1.15.6", - "form-data": "^4.0.0", - "proxy-from-env": "^1.1.0" - } - }, - "node_modules/b4a": { - "version": "1.6.6", - "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.6.6.tgz", - "integrity": "sha512-5Tk1HLk6b6ctmjIkAcU/Ujv/1WqiDl0F0JdRCR80VsOcUlHcu7pWeWRlOqQLHfDEsVx9YH/aif5AG4ehoCtTmg==", - "license": "Apache-2.0" - }, "node_modules/babel-jest": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.7.0.tgz", @@ -4116,13 +4033,6 @@ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "license": "MIT" }, - "node_modules/bare-events": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/bare-events/-/bare-events-2.4.2.tgz", - "integrity": "sha512-qMKFd2qG/36aA4GwvKq8MxnPgCQAmBWmSyLWsJcbn8v03wvIPQ/hG1Ms8bPzndZxMDoHpxez5VOS+gC9Yi24/Q==", - "license": "Apache-2.0", - "optional": true - }, "node_modules/base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", @@ -4216,16 +4126,6 @@ "safe-buffer": "~5.2.0" } }, - "node_modules/bonjour-service": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/bonjour-service/-/bonjour-service-1.2.1.tgz", - "integrity": "sha512-oSzCS2zV14bh2kji6vNe7vrpJYCHGvcZnlffFQ1MEoX/WOeQ/teD8SYWKR942OI3INjq8OMNJlbPK5LLLUxFDw==", - "license": "MIT", - "dependencies": { - "fast-deep-equal": "^3.1.3", - "multicast-dns": "^7.2.5" - } - }, "node_modules/brace-expansion": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", @@ -4315,15 +4215,6 @@ "ieee754": "^1.2.1" } }, - "node_modules/buffer-crc32": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-1.0.0.tgz", - "integrity": "sha512-Db1SbgBS/fg/392AblrMJk97KggmvYhr4pB5ZIMTWtaivCPMWLkmb7m21cJvpvgK+J3nsU2CmmixNBZx4vFj/w==", - "license": "MIT", - "engines": { - "node": ">=8.0.0" - } - }, "node_modules/buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", @@ -4497,18 +4388,6 @@ "text-hex": "1.0.x" } }, - "node_modules/combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "license": "MIT", - "dependencies": { - "delayed-stream": "~1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/commist": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/commist/-/commist-3.2.0.tgz", @@ -4764,15 +4643,6 @@ "node": ">=0.10.0" } }, - "node_modules/delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "license": "MIT", - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/depd": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", @@ -4825,18 +4695,6 @@ "node": ">=8" } }, - "node_modules/dns-packet": { - "version": "5.6.1", - "resolved": "https://registry.npmjs.org/dns-packet/-/dns-packet-5.6.1.tgz", - "integrity": "sha512-l4gcSouhcgIKRvyy99RNVOgxXiicE+2jZoNmaNmZ6JXiGajBOJAesk1OBlJuM5k2c+eudGdLxDqXuPCKIj6kpw==", - "license": "MIT", - "dependencies": { - "@leichtgewicht/ip-codec": "^2.0.1" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/doctrine": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", @@ -5493,12 +5351,6 @@ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "license": "MIT" }, - "node_modules/fast-fifo": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.2.tgz", - "integrity": "sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==", - "license": "MIT" - }, "node_modules/fast-glob": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", @@ -5713,26 +5565,6 @@ "integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==", "license": "MIT" }, - "node_modules/follow-redirects": { - "version": "1.15.6", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", - "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/RubenVerborgh" - } - ], - "license": "MIT", - "engines": { - "node": ">=4.0" - }, - "peerDependenciesMeta": { - "debug": { - "optional": true - } - } - }, "node_modules/foreground-child": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.0.tgz", @@ -5761,20 +5593,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", - "license": "MIT", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/fresh": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", @@ -6029,19 +5847,6 @@ "node": ">= 0.8" } }, - "node_modules/https-proxy-agent": { - "version": "7.0.5", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.5.tgz", - "integrity": "sha512-1e4Wqeblerz+tMKPIq2EMGiiWW1dIjZOksyHWSUm1rmuvw/how9hBHZ38lAGj5ID4Ik6EdkOw7NmWPy6LAwalw==", - "license": "MIT", - "dependencies": { - "agent-base": "^7.0.2", - "debug": "4" - }, - "engines": { - "node": ">= 14" - } - }, "node_modules/human-signals": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", @@ -6058,18 +5863,6 @@ "integrity": "sha512-inh5wue5XdfObhu/IGEMiA1nUXigSGcaKNemcbLRKa7jXYGDZXr3LoT9pTIzq2hPEbld7w/qv9h+ikWGz8fL1g==", "license": "Unlicense" }, - "node_modules/iconv-lite": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", - "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", - "license": "MIT", - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/ieee754": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", @@ -8362,27 +8155,6 @@ "node": ">=4" } }, - "node_modules/mime-db": { - "version": "1.52.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime-types": { - "version": "2.1.35", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", - "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", - "license": "MIT", - "dependencies": { - "mime-db": "1.52.0" - }, - "engines": { - "node": ">= 0.6" - } - }, "node_modules/mimic-fn": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", @@ -8427,15 +8199,6 @@ "node": ">=16 || 14 >=14.17" } }, - "node_modules/mixin-deep": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-2.0.1.tgz", - "integrity": "sha512-imbHQNRglyaplMmjBLL3V5R6Bfq5oM+ivds3SKgc6oRtzErEnBUUc5No11Z2pilkUvl42gJvi285xTNswcKCMA==", - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/mkdir-recursive": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/mkdir-recursive/-/mkdir-recursive-0.4.0.tgz", @@ -8554,19 +8317,6 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "license": "MIT" }, - "node_modules/multicast-dns": { - "version": "7.2.5", - "resolved": "https://registry.npmjs.org/multicast-dns/-/multicast-dns-7.2.5.tgz", - "integrity": "sha512-2eznPJP8z2BFLX50tf0LuODrpINqP1RVIm/CObbTcBRITQgmC/TjcREF1NeTBzIcR5XO/ukWo+YHOjBbFwIupg==", - "license": "MIT", - "dependencies": { - "dns-packet": "^5.2.2", - "thunky": "^1.0.2" - }, - "bin": { - "multicast-dns": "cli.js" - } - }, "node_modules/nan": { "version": "2.20.0", "resolved": "https://registry.npmjs.org/nan/-/nan-2.20.0.tgz", @@ -8588,23 +8338,6 @@ "dev": true, "license": "MIT" }, - "node_modules/node-addon-api": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.0.0.tgz", - "integrity": "sha512-vgbBJTS4m5/KkE16t5Ly0WW9hz46swAstv0hYYwMtbG7AznRhNyfLRe8HZAiWIpcHzoO7HxhLuBQj9rJ/Ho0ZA==", - "license": "MIT" - }, - "node_modules/node-gyp-build": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.6.0.tgz", - "integrity": "sha512-NTZVKn9IylLwUzaKjkas1e4u2DLNcV4rdYagA4PWdPwW87Bi7z+BznyKSRwS/761tV/lzCGXplWsiaMjLqP2zQ==", - "license": "MIT", - "bin": { - "node-gyp-build": "bin.js", - "node-gyp-build-optional": "optional.js", - "node-gyp-build-test": "build-test.js" - } - }, "node_modules/node-int64": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", @@ -9031,12 +8764,6 @@ "node": ">= 6" } }, - "node_modules/proxy-from-env": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", - "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", - "license": "MIT" - }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -9084,12 +8811,6 @@ ], "license": "MIT" }, - "node_modules/queue-tick": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/queue-tick/-/queue-tick-1.0.1.tgz", - "integrity": "sha512-kJt5qhMxoszgU/62PLP1CJytzd2NKetjSRnyuj31fDd3Rlcz3fzlFdFLD1SItunPwyqEOkca6GbV612BWfaBag==", - "license": "MIT" - }, "node_modules/range-parser": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", @@ -9386,12 +9107,6 @@ "node": ">=10" } }, - "node_modules/safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "license": "MIT" - }, "node_modules/sd-notify": { "version": "2.8.0", "resolved": "https://registry.npmjs.org/sd-notify/-/sd-notify-2.8.0.tgz", @@ -9555,12 +9270,6 @@ "node": ">=8" } }, - "node_modules/slip": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/slip/-/slip-1.0.2.tgz", - "integrity": "sha512-XrcHe3NAcyD3wO+O4I13RcS4/3AF+S9RvGNj9JhJeS02HyImwD2E3QWLrmn9hBfL+fB6yapagwxRkeyYzhk98g==", - "license": "(MIT OR GPL-2.0)" - }, "node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -9637,20 +9346,6 @@ "node": ">= 0.8" } }, - "node_modules/streamx": { - "version": "2.19.0", - "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.19.0.tgz", - "integrity": "sha512-5z6CNR4gtkPbwlxyEqoDGDmWIzoNJqCBt4Eac1ICP9YaIT08ct712cFj0u1rx4F8luAuL+3Qc+RFIdI4OX00kg==", - "license": "MIT", - "dependencies": { - "fast-fifo": "^1.3.2", - "queue-tick": "^1.0.1", - "text-decoder": "^1.1.0" - }, - "optionalDependencies": { - "bare-events": "^2.2.0" - } - }, "node_modules/string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", @@ -9787,17 +9482,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/tar-stream": { - "version": "3.1.7", - "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.1.7.tgz", - "integrity": "sha512-qJj60CXt7IU1Ffyc3NJMjh6EkuCFej46zUqJ4J7pqYlThyd9bO0XBTmcOIhSzZJVWfsLks0+nle/j538YAW9RQ==", - "license": "MIT", - "dependencies": { - "b4a": "^1.6.4", - "fast-fifo": "^1.2.0", - "streamx": "^2.15.0" - } - }, "node_modules/test-exclude": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", @@ -9837,15 +9521,6 @@ "node": "*" } }, - "node_modules/text-decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/text-decoder/-/text-decoder-1.1.1.tgz", - "integrity": "sha512-8zll7REEv4GDD3x4/0pW+ppIxSNs7H1J10IKFZsuOMscumCdM2a+toDGLPA3T+1+fLBql4zbt5z83GEQGGV5VA==", - "license": "Apache-2.0", - "dependencies": { - "b4a": "^1.6.4" - } - }, "node_modules/text-hex": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz", @@ -9859,12 +9534,6 @@ "dev": true, "license": "MIT" }, - "node_modules/thunky": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/thunky/-/thunky-1.1.0.tgz", - "integrity": "sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA==", - "license": "MIT" - }, "node_modules/tmp": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.3.tgz", @@ -10493,35 +10162,12 @@ } }, "node_modules/zigbee-herdsman": { - "version": "0.57.1", - "resolved": "https://registry.npmjs.org/zigbee-herdsman/-/zigbee-herdsman-0.57.1.tgz", - "integrity": "sha512-ZMHa/w4UmIPty9Dzw5ViI+fH5bti1d8EjohCmGv6qVyX86CZd3nTul+jwMLWWHM0pYKyUHgRfUeX/WGHH9N33w==", - "license": "MIT", - "dependencies": { - "@serialport/bindings-cpp": "^12.0.1", - "@serialport/parser-delimiter": "^12.0.0", - "@serialport/stream": "^12.0.0", - "bonjour-service": "^1.2.1", - "debounce": "^2.1.0", - "fast-deep-equal": "^3.1.3", - "mixin-deep": "^2.0.1", - "slip": "^1.0.2" - } + "resolved": "../zigbee-herdsman", + "link": true }, "node_modules/zigbee-herdsman-converters": { - "version": "20.8.4", - "resolved": "https://registry.npmjs.org/zigbee-herdsman-converters/-/zigbee-herdsman-converters-20.8.4.tgz", - "integrity": "sha512-g9vC4UES9exqbvcMprYlkENVATtpXshnn6ho5meqfk14VSLWsVd6O1X9H6w2y9ItFE/if2PM1+esSACeBAYrcg==", - "license": "MIT", - "dependencies": { - "axios": "^1.7.7", - "buffer-crc32": "^1.0.0", - "https-proxy-agent": "^7.0.5", - "iconv-lite": "^0.6.3", - "semver": "^7.6.3", - "tar-stream": "^3.1.7", - "zigbee-herdsman": "^0.57.1" - } + "resolved": "../zigbee-herdsman-converters", + "link": true }, "node_modules/zigbee2mqtt-frontend": { "version": "0.7.4", diff --git a/package.json b/package.json index ef5f82c91d..cb9491f05e 100644 --- a/package.json +++ b/package.json @@ -60,8 +60,8 @@ "winston-syslog": "^2.7.1", "winston-transport": "^4.7.1", "ws": "^8.18.0", - "zigbee-herdsman": "0.57.1", - "zigbee-herdsman-converters": "20.8.4", + "zigbee-herdsman": "file:../zigbee-herdsman", + "zigbee-herdsman-converters": "file:../zigbee-herdsman-converters", "zigbee2mqtt-frontend": "0.7.4" }, "devDependencies": { From 83ba5a2d24a3343da865437526a86de227d67d78 Mon Sep 17 00:00:00 2001 From: Tomer <57483589+tomer-w@users.noreply.github.com> Date: Sat, 7 Sep 2024 19:40:37 +0300 Subject: [PATCH 02/23] Bug fix --- lib/util/logger.ts | 2 +- package-lock.json | 13 ------------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/lib/util/logger.ts b/lib/util/logger.ts index 25cc86b695..51f7cf3318 100644 --- a/lib/util/logger.ts +++ b/lib/util/logger.ts @@ -184,7 +184,7 @@ class Logger { private log(level: settings.LogLevel, messageOrLambda: string | (() => string), namespace: string): void { if (this.isEnabled(level, namespace)) { - const message:string = (typeof messageOrLambda === "string") ? messageOrLambda : messageOrLambda() ; + const message:string = (typeof messageOrLambda === "function") ? messageOrLambda() : messageOrLambda ; this.logger.log(level, `${namespace}: ${message}`); } } diff --git a/package-lock.json b/package-lock.json index f545c5f078..e2a6427701 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4672,19 +4672,6 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/dir-glob": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", - "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", - "dev": true, - "license": "MIT", - "dependencies": { - "path-type": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/doctrine": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", From a00f522ef5da2a263feef04b4da8a09de4f35348 Mon Sep 17 00:00:00 2001 From: Tomer <57483589+tomer-w@users.noreply.github.com> Date: Sat, 7 Sep 2024 19:51:21 +0300 Subject: [PATCH 03/23] Revert sample configuration --- data/configuration.yaml | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/data/configuration.yaml b/data/configuration.yaml index 83daf87397..3ed7c1ce00 100644 --- a/data/configuration.yaml +++ b/data/configuration.yaml @@ -1,15 +1,20 @@ +# Home Assistant integration (MQTT discovery) homeassistant: false + +# allow new devices to join permit_join: true -frontend: true + +# MQTT settings mqtt: + # MQTT base topic for zigbee2mqtt MQTT messages base_topic: zigbee2mqtt - server: mqtt://localhost + # MQTT server URL + server: 'mqtt://localhost' + # MQTT server authentication, uncomment if required: + # user: my_user + # password: my_password + +# Serial settings serial: - port: COM7 - adapter: deconz - adapter_delay: 200 -advanced: - log_level: debug -devices: - '0x00124b00271f9834': - friendly_name: '0x00124b00271f9834' + # Location of CC2531 USB sniffer + port: /dev/ttyACM0 From cac4b34a9a74588eb110bced2a506b93f8f09aa7 Mon Sep 17 00:00:00 2001 From: Tomer <57483589+tomer-w@users.noreply.github.com> Date: Sat, 7 Sep 2024 20:06:43 +0300 Subject: [PATCH 04/23] Align package versions --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e677c9122e..22f81139d5 100644 --- a/package.json +++ b/package.json @@ -60,8 +60,8 @@ "winston-syslog": "^2.7.1", "winston-transport": "^4.7.1", "ws": "^8.18.0", - "zigbee-herdsman": "file:../zigbee-herdsman", - "zigbee-herdsman-converters": "file:../zigbee-herdsman-converters", + "zigbee-herdsman": "0.57.4", + "zigbee-herdsman-converters": "20.12.2", "zigbee2mqtt-frontend": "0.7.4" }, "devDependencies": { From 163216373ee662c165768aa91afcb9d3178ec7e7 Mon Sep 17 00:00:00 2001 From: Tomer <57483589+tomer-w@users.noreply.github.com> Date: Sun, 8 Sep 2024 08:48:38 +0300 Subject: [PATCH 05/23] Revert dependecies version to allow testing --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 22f81139d5..22b6fa5c2c 100644 --- a/package.json +++ b/package.json @@ -60,8 +60,8 @@ "winston-syslog": "^2.7.1", "winston-transport": "^4.7.1", "ws": "^8.18.0", - "zigbee-herdsman": "0.57.4", - "zigbee-herdsman-converters": "20.12.2", + "zigbee-herdsman": "0.57.3", + "zigbee-herdsman-converters": "20.12.1", "zigbee2mqtt-frontend": "0.7.4" }, "devDependencies": { From ff732a193fd54081eea5c390f5a3e57b7b6d2be1 Mon Sep 17 00:00:00 2001 From: Tomer <57483589+tomer-w@users.noreply.github.com> Date: Sun, 8 Sep 2024 08:50:47 +0300 Subject: [PATCH 06/23] Update package-lock.json --- package-lock.json | 520 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 437 insertions(+), 83 deletions(-) diff --git a/package-lock.json b/package-lock.json index 786fb40365..f8e273a010 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "zigbee2mqtt", - "version": "1.40.1", + "version": "1.40.1-dev", "license": "GPL-3.0", "dependencies": { "ajv": "^8.17.1", @@ -32,8 +32,8 @@ "winston-syslog": "^2.7.1", "winston-transport": "^4.7.1", "ws": "^8.18.0", - "zigbee-herdsman": "file:../zigbee-herdsman", - "zigbee-herdsman-converters": "file:../zigbee-herdsman-converters", + "zigbee-herdsman": "0.57.3", + "zigbee-herdsman-converters": "20.12.1", "zigbee2mqtt-frontend": "0.7.4" }, "bin": { @@ -71,82 +71,6 @@ "sd-notify": "^2.8.0" } }, - "../zigbee-herdsman": { - "version": "0.57.2", - "license": "MIT", - "dependencies": { - "@serialport/bindings-cpp": "^12.0.1", - "@serialport/parser-delimiter": "^12.0.0", - "@serialport/stream": "^12.0.0", - "bonjour-service": "^1.2.1", - "debounce": "^2.1.0", - "fast-deep-equal": "^3.1.3", - "mixin-deep": "^2.0.1", - "slip": "^1.0.2" - }, - "devDependencies": { - "@babel/cli": "^7.25.6", - "@babel/core": "^7.25.2", - "@babel/preset-env": "^7.25.4", - "@babel/preset-typescript": "^7.24.7", - "@eslint/js": "^9.9.1", - "@ianvs/prettier-plugin-sort-imports": "^4.3.1", - "@serialport/binding-mock": "^10.2.2", - "@types/debounce": "^1.2.4", - "@types/eslint__js": "^8.42.3", - "@types/jest": "^29.5.12", - "@types/mz": "^2.7.8", - "@types/nedb": "^1.8.16", - "@types/node": "^22.5.1", - "babel-jest": "^29.7.0", - "eslint": "^9.9.1", - "eslint-config-prettier": "^9.1.0", - "jest": "^29.7.0", - "prettier": "^3.3.3", - "regenerator-runtime": "^0.14.1", - "rimraf": "^6.0.1", - "typedoc": "^0.26.6", - "typedoc-plugin-markdown": "^4.2.6", - "typedoc-plugin-no-inherit": "^1.4.0", - "typescript": "^5.5.4", - "typescript-eslint": "^8.3.0" - } - }, - "../zigbee-herdsman-converters": { - "version": "20.12.2", - "license": "MIT", - "dependencies": { - "axios": "^1.7.7", - "buffer-crc32": "^1.0.0", - "https-proxy-agent": "^7.0.5", - "iconv-lite": "^0.6.3", - "semver": "^7.6.3", - "tar-stream": "^3.1.7", - "zigbee-herdsman": "^0.57.3" - }, - "devDependencies": { - "@types/buffer-crc32": "^0.2.4", - "@types/jest": "^29.5.12", - "@types/node": "^22.5.4", - "@types/semver": "^7.5.8", - "@types/tar-stream": "^3.1.3", - "@typescript-eslint/eslint-plugin": "^8.4.0", - "@typescript-eslint/parser": "^8.4.0", - "eslint": "^8.57.0", - "eslint-config-prettier": "^9.1.0", - "eslint-plugin-jest": "^28.8.3", - "eslint-plugin-perfectionist": "^3.4.0", - "eslint-plugin-tsdoc": "^0.3.0", - "fast-deep-equal": "*", - "husky": "^9.1.5", - "jest": "^29.7.0", - "prettier": "^3.3.3", - "rimraf": "^6.0.1", - "ts-jest": "^29.2.5", - "ts-morph": "^23.0.0", - "typescript": "^5.5.4" - } - }, "node_modules/@ampproject/remapping": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", @@ -3221,6 +3145,12 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@leichtgewicht/ip-codec": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@leichtgewicht/ip-codec/-/ip-codec-2.0.5.tgz", + "integrity": "sha512-Vo+PSpZG2/fmgmiNzYK9qWRh8h/CHrwD0mo1h1DzL4yzHNSfWYujGTYsWGreD000gcgmZ7K4Ys6Tx9TxtsKdDw==", + "license": "MIT" + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -3269,6 +3199,124 @@ "node": ">=14" } }, + "node_modules/@serialport/bindings-cpp": { + "version": "12.0.1", + "resolved": "https://registry.npmjs.org/@serialport/bindings-cpp/-/bindings-cpp-12.0.1.tgz", + "integrity": "sha512-r2XOwY2dDvbW7dKqSPIk2gzsr6M6Qpe9+/Ngs94fNaNlcTRCV02PfaoDmRgcubpNVVcLATlxSxPTIDw12dbKOg==", + "hasInstallScript": true, + "license": "MIT", + "dependencies": { + "@serialport/bindings-interface": "1.2.2", + "@serialport/parser-readline": "11.0.0", + "debug": "4.3.4", + "node-addon-api": "7.0.0", + "node-gyp-build": "4.6.0" + }, + "engines": { + "node": ">=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/serialport/donate" + } + }, + "node_modules/@serialport/bindings-cpp/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "license": "MIT", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/@serialport/bindings-interface": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@serialport/bindings-interface/-/bindings-interface-1.2.2.tgz", + "integrity": "sha512-CJaUd5bLvtM9c5dmO9rPBHPXTa9R2UwpkJ0wdh9JCYcbrPWsKz+ErvR0hBLeo7NPeiFdjFO4sonRljiw4d2XiA==", + "license": "MIT", + "engines": { + "node": "^12.22 || ^14.13 || >=16" + } + }, + "node_modules/@serialport/parser-delimiter": { + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/@serialport/parser-delimiter/-/parser-delimiter-12.0.0.tgz", + "integrity": "sha512-gu26tVt5lQoybhorLTPsH2j2LnX3AOP2x/34+DUSTNaUTzu2fBXw+isVjQJpUBFWu6aeQRZw5bJol5X9Gxjblw==", + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://opencollective.com/serialport/donate" + } + }, + "node_modules/@serialport/parser-readline": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/@serialport/parser-readline/-/parser-readline-11.0.0.tgz", + "integrity": "sha512-rRAivhRkT3YO28WjmmG4FQX6L+KMb5/ikhyylRfzWPw0nSXy97+u07peS9CbHqaNvJkMhH1locp2H36aGMOEIA==", + "license": "MIT", + "dependencies": { + "@serialport/parser-delimiter": "11.0.0" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://opencollective.com/serialport/donate" + } + }, + "node_modules/@serialport/parser-readline/node_modules/@serialport/parser-delimiter": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/@serialport/parser-delimiter/-/parser-delimiter-11.0.0.tgz", + "integrity": "sha512-aZLJhlRTjSmEwllLG7S4J8s8ctRAS0cbvCpO87smLvl3e4BgzbVgF6Z6zaJd3Aji2uSiYgfedCdNc4L6W+1E2g==", + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://opencollective.com/serialport/donate" + } + }, + "node_modules/@serialport/stream": { + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/@serialport/stream/-/stream-12.0.0.tgz", + "integrity": "sha512-9On64rhzuqKdOQyiYLYv2lQOh3TZU/D3+IWCR5gk0alPel2nwpp4YwDEGiUBfrQZEdQ6xww0PWkzqth4wqwX3Q==", + "license": "MIT", + "dependencies": { + "@serialport/bindings-interface": "1.2.2", + "debug": "4.3.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://opencollective.com/serialport/donate" + } + }, + "node_modules/@serialport/stream/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "license": "MIT", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, "node_modules/@sinclair/typebox": { "version": "0.27.8", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", @@ -3710,6 +3758,18 @@ "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, + "node_modules/agent-base": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.1.tgz", + "integrity": "sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA==", + "license": "MIT", + "dependencies": { + "debug": "^4.3.4" + }, + "engines": { + "node": ">= 14" + } + }, "node_modules/ajv": { "version": "8.17.1", "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", @@ -3790,6 +3850,29 @@ "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==", "license": "MIT" }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" + }, + "node_modules/axios": { + "version": "1.7.7", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz", + "integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/b4a": { + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.6.6.tgz", + "integrity": "sha512-5Tk1HLk6b6ctmjIkAcU/Ujv/1WqiDl0F0JdRCR80VsOcUlHcu7pWeWRlOqQLHfDEsVx9YH/aif5AG4ehoCtTmg==", + "license": "Apache-2.0" + }, "node_modules/babel-jest": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.7.0.tgz", @@ -4023,6 +4106,13 @@ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "license": "MIT" }, + "node_modules/bare-events": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/bare-events/-/bare-events-2.4.2.tgz", + "integrity": "sha512-qMKFd2qG/36aA4GwvKq8MxnPgCQAmBWmSyLWsJcbn8v03wvIPQ/hG1Ms8bPzndZxMDoHpxez5VOS+gC9Yi24/Q==", + "license": "Apache-2.0", + "optional": true + }, "node_modules/base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", @@ -4116,6 +4206,16 @@ "safe-buffer": "~5.2.0" } }, + "node_modules/bonjour-service": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/bonjour-service/-/bonjour-service-1.2.1.tgz", + "integrity": "sha512-oSzCS2zV14bh2kji6vNe7vrpJYCHGvcZnlffFQ1MEoX/WOeQ/teD8SYWKR942OI3INjq8OMNJlbPK5LLLUxFDw==", + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.3", + "multicast-dns": "^7.2.5" + } + }, "node_modules/brace-expansion": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", @@ -4205,6 +4305,15 @@ "ieee754": "^1.2.1" } }, + "node_modules/buffer-crc32": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-1.0.0.tgz", + "integrity": "sha512-Db1SbgBS/fg/392AblrMJk97KggmvYhr4pB5ZIMTWtaivCPMWLkmb7m21cJvpvgK+J3nsU2CmmixNBZx4vFj/w==", + "license": "MIT", + "engines": { + "node": ">=8.0.0" + } + }, "node_modules/buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", @@ -4378,6 +4487,18 @@ "text-hex": "1.0.x" } }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/commist": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/commist/-/commist-3.2.0.tgz", @@ -4633,6 +4754,15 @@ "node": ">=0.10.0" } }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/depd": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", @@ -4672,6 +4802,18 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/dns-packet": { + "version": "5.6.1", + "resolved": "https://registry.npmjs.org/dns-packet/-/dns-packet-5.6.1.tgz", + "integrity": "sha512-l4gcSouhcgIKRvyy99RNVOgxXiicE+2jZoNmaNmZ6JXiGajBOJAesk1OBlJuM5k2c+eudGdLxDqXuPCKIj6kpw==", + "license": "MIT", + "dependencies": { + "@leichtgewicht/ip-codec": "^2.0.1" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/doctrine": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", @@ -5328,6 +5470,12 @@ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "license": "MIT" }, + "node_modules/fast-fifo": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.2.tgz", + "integrity": "sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==", + "license": "MIT" + }, "node_modules/fast-glob": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", @@ -5542,6 +5690,26 @@ "integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==", "license": "MIT" }, + "node_modules/follow-redirects": { + "version": "1.15.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", + "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, "node_modules/foreground-child": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.0.tgz", @@ -5570,6 +5738,20 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/fresh": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", @@ -5803,6 +5985,19 @@ "node": ">= 0.8" } }, + "node_modules/https-proxy-agent": { + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.5.tgz", + "integrity": "sha512-1e4Wqeblerz+tMKPIq2EMGiiWW1dIjZOksyHWSUm1rmuvw/how9hBHZ38lAGj5ID4Ik6EdkOw7NmWPy6LAwalw==", + "license": "MIT", + "dependencies": { + "agent-base": "^7.0.2", + "debug": "4" + }, + "engines": { + "node": ">= 14" + } + }, "node_modules/human-signals": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", @@ -5819,6 +6014,18 @@ "integrity": "sha512-inh5wue5XdfObhu/IGEMiA1nUXigSGcaKNemcbLRKa7jXYGDZXr3LoT9pTIzq2hPEbld7w/qv9h+ikWGz8fL1g==", "license": "Unlicense" }, + "node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/ieee754": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", @@ -8111,6 +8318,27 @@ "node": ">=4" } }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/mimic-fn": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", @@ -8155,6 +8383,15 @@ "node": ">=16 || 14 >=14.17" } }, + "node_modules/mixin-deep": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-2.0.1.tgz", + "integrity": "sha512-imbHQNRglyaplMmjBLL3V5R6Bfq5oM+ivds3SKgc6oRtzErEnBUUc5No11Z2pilkUvl42gJvi285xTNswcKCMA==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/mkdir-recursive": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/mkdir-recursive/-/mkdir-recursive-0.4.0.tgz", @@ -8273,6 +8510,19 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "license": "MIT" }, + "node_modules/multicast-dns": { + "version": "7.2.5", + "resolved": "https://registry.npmjs.org/multicast-dns/-/multicast-dns-7.2.5.tgz", + "integrity": "sha512-2eznPJP8z2BFLX50tf0LuODrpINqP1RVIm/CObbTcBRITQgmC/TjcREF1NeTBzIcR5XO/ukWo+YHOjBbFwIupg==", + "license": "MIT", + "dependencies": { + "dns-packet": "^5.2.2", + "thunky": "^1.0.2" + }, + "bin": { + "multicast-dns": "cli.js" + } + }, "node_modules/nan": { "version": "2.20.0", "resolved": "https://registry.npmjs.org/nan/-/nan-2.20.0.tgz", @@ -8294,6 +8544,23 @@ "dev": true, "license": "MIT" }, + "node_modules/node-addon-api": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.0.0.tgz", + "integrity": "sha512-vgbBJTS4m5/KkE16t5Ly0WW9hz46swAstv0hYYwMtbG7AznRhNyfLRe8HZAiWIpcHzoO7HxhLuBQj9rJ/Ho0ZA==", + "license": "MIT" + }, + "node_modules/node-gyp-build": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.6.0.tgz", + "integrity": "sha512-NTZVKn9IylLwUzaKjkas1e4u2DLNcV4rdYagA4PWdPwW87Bi7z+BznyKSRwS/761tV/lzCGXplWsiaMjLqP2zQ==", + "license": "MIT", + "bin": { + "node-gyp-build": "bin.js", + "node-gyp-build-optional": "optional.js", + "node-gyp-build-test": "build-test.js" + } + }, "node_modules/node-int64": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", @@ -8710,6 +8977,12 @@ "node": ">= 6" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "license": "MIT" + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -8757,6 +9030,12 @@ ], "license": "MIT" }, + "node_modules/queue-tick": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/queue-tick/-/queue-tick-1.0.1.tgz", + "integrity": "sha512-kJt5qhMxoszgU/62PLP1CJytzd2NKetjSRnyuj31fDd3Rlcz3fzlFdFLD1SItunPwyqEOkca6GbV612BWfaBag==", + "license": "MIT" + }, "node_modules/range-parser": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", @@ -9053,6 +9332,12 @@ "node": ">=10" } }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, "node_modules/sd-notify": { "version": "2.8.0", "resolved": "https://registry.npmjs.org/sd-notify/-/sd-notify-2.8.0.tgz", @@ -9216,6 +9501,12 @@ "node": ">=8" } }, + "node_modules/slip": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/slip/-/slip-1.0.2.tgz", + "integrity": "sha512-XrcHe3NAcyD3wO+O4I13RcS4/3AF+S9RvGNj9JhJeS02HyImwD2E3QWLrmn9hBfL+fB6yapagwxRkeyYzhk98g==", + "license": "(MIT OR GPL-2.0)" + }, "node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -9292,6 +9583,20 @@ "node": ">= 0.8" } }, + "node_modules/streamx": { + "version": "2.20.0", + "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.20.0.tgz", + "integrity": "sha512-ZGd1LhDeGFucr1CUCTBOS58ZhEendd0ttpGT3usTvosS4ntIwKN9LJFp+OeCSprsCPL14BXVRZlHGRY1V9PVzQ==", + "license": "MIT", + "dependencies": { + "fast-fifo": "^1.3.2", + "queue-tick": "^1.0.1", + "text-decoder": "^1.1.0" + }, + "optionalDependencies": { + "bare-events": "^2.2.0" + } + }, "node_modules/string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", @@ -9428,6 +9733,17 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/tar-stream": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.1.7.tgz", + "integrity": "sha512-qJj60CXt7IU1Ffyc3NJMjh6EkuCFej46zUqJ4J7pqYlThyd9bO0XBTmcOIhSzZJVWfsLks0+nle/j538YAW9RQ==", + "license": "MIT", + "dependencies": { + "b4a": "^1.6.4", + "fast-fifo": "^1.2.0", + "streamx": "^2.15.0" + } + }, "node_modules/test-exclude": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", @@ -9467,6 +9783,15 @@ "node": "*" } }, + "node_modules/text-decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/text-decoder/-/text-decoder-1.1.1.tgz", + "integrity": "sha512-8zll7REEv4GDD3x4/0pW+ppIxSNs7H1J10IKFZsuOMscumCdM2a+toDGLPA3T+1+fLBql4zbt5z83GEQGGV5VA==", + "license": "Apache-2.0", + "dependencies": { + "b4a": "^1.6.4" + } + }, "node_modules/text-hex": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz", @@ -9480,6 +9805,12 @@ "dev": true, "license": "MIT" }, + "node_modules/thunky": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/thunky/-/thunky-1.1.0.tgz", + "integrity": "sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA==", + "license": "MIT" + }, "node_modules/tmp": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.3.tgz", @@ -10108,12 +10439,35 @@ } }, "node_modules/zigbee-herdsman": { - "resolved": "../zigbee-herdsman", - "link": true + "version": "0.57.3", + "resolved": "https://registry.npmjs.org/zigbee-herdsman/-/zigbee-herdsman-0.57.3.tgz", + "integrity": "sha512-WpJFb5GpqqCWTrUOSP4MbUZoPudVp+G2ehbpgSQOG8ITsVHsQyQ6iA52l77pG9DXGGwUgmycIXKFmsG6U5zCbA==", + "license": "MIT", + "dependencies": { + "@serialport/bindings-cpp": "^12.0.1", + "@serialport/parser-delimiter": "^12.0.0", + "@serialport/stream": "^12.0.0", + "bonjour-service": "^1.2.1", + "debounce": "^2.1.0", + "fast-deep-equal": "^3.1.3", + "mixin-deep": "^2.0.1", + "slip": "^1.0.2" + } }, "node_modules/zigbee-herdsman-converters": { - "resolved": "../zigbee-herdsman-converters", - "link": true + "version": "20.12.1", + "resolved": "https://registry.npmjs.org/zigbee-herdsman-converters/-/zigbee-herdsman-converters-20.12.1.tgz", + "integrity": "sha512-ylV6hfbe/+AIl5cVlGd3KI4s5OE7xZ1IEsEftxb/0atwS+ldToDqfB31dq256XMFNZU/Atet1H90OAwXS2IHrA==", + "license": "MIT", + "dependencies": { + "axios": "^1.7.7", + "buffer-crc32": "^1.0.0", + "https-proxy-agent": "^7.0.5", + "iconv-lite": "^0.6.3", + "semver": "^7.6.3", + "tar-stream": "^3.1.7", + "zigbee-herdsman": "^0.57.3" + } }, "node_modules/zigbee2mqtt-frontend": { "version": "0.7.4", From db8fc5fe076562aed461a967a21f541795d88049 Mon Sep 17 00:00:00 2001 From: Tomer <57483589+tomer-w@users.noreply.github.com> Date: Sun, 8 Sep 2024 08:53:46 +0300 Subject: [PATCH 07/23] Fix prettier issue --- lib/util/logger.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util/logger.ts b/lib/util/logger.ts index 86dae63946..207e68a66d 100644 --- a/lib/util/logger.ts +++ b/lib/util/logger.ts @@ -191,7 +191,7 @@ class Logger { private log(level: settings.LogLevel, messageOrLambda: string | (() => string), namespace: string): void { if (this.isEnabled(level, namespace)) { - const message:string = (typeof messageOrLambda === "function") ? messageOrLambda() : messageOrLambda ; + const message: string = typeof messageOrLambda === 'function' ? messageOrLambda() : messageOrLambda; this.logger.log(level, `${namespace}: ${message}`); } } From 97e56ba20277b9fdccba8329ec307f2b00e18774 Mon Sep 17 00:00:00 2001 From: Tomer <57483589+tomer-w@users.noreply.github.com> Date: Sun, 8 Sep 2024 09:07:21 +0300 Subject: [PATCH 08/23] Coverage to 100% --- test/logger.test.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/logger.test.js b/test/logger.test.js index 95a74872c4..81e52d1b21 100644 --- a/test/logger.test.js +++ b/test/logger.test.js @@ -164,6 +164,9 @@ describe('Logger', () => { logger[level]('msg', 'abcd'); expect(logSpy).toHaveBeenLastCalledWith(level, 'abcd: msg'); expect(consoleWriteSpy).toHaveBeenCalledTimes(i++); + logger[level](() => 'func msg', 'abcd'); + expect(logSpy).toHaveBeenLastCalledWith(level, 'abcd: func msg'); + expect(consoleWriteSpy).toHaveBeenCalledTimes(i++); for (const higherLevel of otherLevels.higher) { logger[higherLevel]('higher msg'); From 6b4be3267812399e795968da80e1c86ffa59f5c0 Mon Sep 17 00:00:00 2001 From: Tomer <57483589+tomer-w@users.noreply.github.com> Date: Mon, 9 Sep 2024 12:13:16 +0300 Subject: [PATCH 09/23] Fix CR comments --- .gitignore | 1 + data/configuration.yaml | 25 ++++++++++--------------- lib/util/logger.ts | 11 ++--------- 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index 3cfd813f58..b52c217ad6 100644 --- a/.gitignore +++ b/.gitignore @@ -75,3 +75,4 @@ data/* # commit-user-lookup.json scripts/commit-user-lookup.json +data/configuration.yaml diff --git a/data/configuration.yaml b/data/configuration.yaml index 3ed7c1ce00..9b1a4f1314 100644 --- a/data/configuration.yaml +++ b/data/configuration.yaml @@ -1,20 +1,15 @@ -# Home Assistant integration (MQTT discovery) homeassistant: false - -# allow new devices to join permit_join: true - -# MQTT settings +frontend: true mqtt: - # MQTT base topic for zigbee2mqtt MQTT messages base_topic: zigbee2mqtt - # MQTT server URL - server: 'mqtt://localhost' - # MQTT server authentication, uncomment if required: - # user: my_user - # password: my_password - -# Serial settings + server: mqtt://localhost serial: - # Location of CC2531 USB sniffer - port: /dev/ttyACM0 + port: COM7 + adapter: deconz + adapter_delay: 200 +advanced: + log_level: debug +devices: + '0x00124b00271f9834': + friendly_name: '0x00124b00271f9834' \ No newline at end of file diff --git a/lib/util/logger.ts b/lib/util/logger.ts index 207e68a66d..032bb3dbe0 100644 --- a/lib/util/logger.ts +++ b/lib/util/logger.ts @@ -190,19 +190,12 @@ class Logger { } private log(level: settings.LogLevel, messageOrLambda: string | (() => string), namespace: string): void { - if (this.isEnabled(level, namespace)) { - const message: string = typeof messageOrLambda === 'function' ? messageOrLambda() : messageOrLambda; - this.logger.log(level, `${namespace}: ${message}`); - } - } - - public isEnabled(level: settings.LogLevel, namespace: string): boolean { const nsLevel = this.cacheNamespacedLevel(namespace); if (settings.LOG_LEVELS.indexOf(level) <= settings.LOG_LEVELS.indexOf(nsLevel)) { - return true; + const message: string = messageOrLambda instanceof Function ? messageOrLambda() : messageOrLambda; + this.logger.log(level, `${namespace}: ${message}`); } - return false; } public error(messageOrLambda: string | (() => string), namespace: string = 'z2m'): void { From 7842842ff24f31fdb7755df3c57ab18519fbd0c1 Mon Sep 17 00:00:00 2001 From: Tomer <57483589+tomer-w@users.noreply.github.com> Date: Mon, 9 Sep 2024 12:35:04 +0300 Subject: [PATCH 10/23] remove uneeded changes --- .gitignore | 1 - data/configuration.yaml | 25 +++++++++++++++---------- package-lock.json | 8 ++++---- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index b52c217ad6..3cfd813f58 100644 --- a/.gitignore +++ b/.gitignore @@ -75,4 +75,3 @@ data/* # commit-user-lookup.json scripts/commit-user-lookup.json -data/configuration.yaml diff --git a/data/configuration.yaml b/data/configuration.yaml index 9b1a4f1314..3ed7c1ce00 100644 --- a/data/configuration.yaml +++ b/data/configuration.yaml @@ -1,15 +1,20 @@ +# Home Assistant integration (MQTT discovery) homeassistant: false + +# allow new devices to join permit_join: true -frontend: true + +# MQTT settings mqtt: + # MQTT base topic for zigbee2mqtt MQTT messages base_topic: zigbee2mqtt - server: mqtt://localhost + # MQTT server URL + server: 'mqtt://localhost' + # MQTT server authentication, uncomment if required: + # user: my_user + # password: my_password + +# Serial settings serial: - port: COM7 - adapter: deconz - adapter_delay: 200 -advanced: - log_level: debug -devices: - '0x00124b00271f9834': - friendly_name: '0x00124b00271f9834' \ No newline at end of file + # Location of CC2531 USB sniffer + port: /dev/ttyACM0 diff --git a/package-lock.json b/package-lock.json index f8e273a010..2805cd5fa8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "zigbee2mqtt", - "version": "1.40.1-dev", + "version": "1.40.1", "license": "GPL-3.0", "dependencies": { "ajv": "^8.17.1", @@ -5691,9 +5691,9 @@ "license": "MIT" }, "node_modules/follow-redirects": { - "version": "1.15.9", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", - "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", "funding": [ { "type": "individual", From 5015038792f9b3f0ce0ebad79526cea9096c3982 Mon Sep 17 00:00:00 2001 From: Tomer <57483589+tomer-w@users.noreply.github.com> Date: Mon, 9 Sep 2024 13:13:51 +0300 Subject: [PATCH 11/23] Make the same perf optimization to the MQTT messages --- lib/mqtt.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/mqtt.ts b/lib/mqtt.ts index 9263aa3713..56b14edd21 100644 --- a/lib/mqtt.ts +++ b/lib/mqtt.ts @@ -145,7 +145,7 @@ export default class MQTT { @bind public onMessage(topic: string, message: Buffer): void { // Since we subscribe to zigbee2mqtt/# we also receive the message we send ourselves, skip these. if (!this.publishedTopics.has(topic)) { - logger.debug(`Received MQTT message on '${topic}' with data '${message.toString()}'`, NS); + logger.debug(() => `Received MQTT message on '${topic}' with data '${message.toString()}'`, NS); this.eventBus.emitMQTTMessage({topic, message: message.toString()}); } @@ -196,7 +196,7 @@ export default class MQTT { } if (!skipLog) { - logger.info(`MQTT publish: topic '${topic}', payload '${payload}'`, NS); + logger.info(() => `MQTT publish: topic '${topic}', payload '${payload}'`, NS); } const actualOptions: mqtt.IClientPublishOptions = {...defaultOptions, ...options}; From c0128d9f2b787c17cfc8c9d80c23dbb5084dbc16 Mon Sep 17 00:00:00 2001 From: Tomer <57483589+tomer-w@users.noreply.github.com> Date: Mon, 9 Sep 2024 15:54:15 +0300 Subject: [PATCH 12/23] Fix MQTT tests --- test/controller.test.js | 25 +++++++++++++++++++++++-- test/stub/logger.js | 11 ++++++----- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/test/controller.test.js b/test/controller.test.js index a77196abe0..ae5784271c 100644 --- a/test/controller.test.js +++ b/test/controller.test.js @@ -1,6 +1,7 @@ process.env.NOTIFY_SOCKET = 'mocked'; const data = require('./stub/data'); const logger = require('./stub/logger'); +const Transport = require('winston-transport'); const zigbeeHerdsman = require('./stub/zigbeeHerdsman'); const MQTT = require('./stub/mqtt'); const path = require('path'); @@ -325,21 +326,41 @@ describe('Controller', () => { }); it('Handle mqtt message', async () => { + class DummyTransport extends Transport { + log(info, callback) {} + } + const transport = new DummyTransport(); + logger.setTransportsEnabled(true); + let spyTransport = jest.spyOn(transport, 'log').mockImplementation(); + logger.addTransport(transport); + await controller.start(); logger.debug.mockClear(); await MQTT.events.message('dummytopic', 'dummymessage'); - expect(logger.debug).toHaveBeenCalledWith("Received MQTT message on 'dummytopic' with data 'dummymessage'", LOG_MQTT_NS); + expect(spyTransport).toHaveBeenCalledWith({"level": "debug", "message": "Received MQTT message on 'dummytopic' with data 'dummymessage'", "namespace": LOG_MQTT_NS}, expect.any(Function)); + logger.removeTransport(transport) + logger.setTransportsEnabled(false); }); it('Skip MQTT messages on topic we published to', async () => { + class DummyTransport extends Transport { + log(info, callback) {} + } + const transport = new DummyTransport(); + logger.setTransportsEnabled(true); + let spyTransport = jest.spyOn(transport, 'log').mockImplementation(); + logger.addTransport(transport); + await controller.start(); logger.debug.mockClear(); await MQTT.events.message('zigbee2mqtt/skip-this-topic', 'skipped'); - expect(logger.debug).toHaveBeenCalledWith("Received MQTT message on 'zigbee2mqtt/skip-this-topic' with data 'skipped'", LOG_MQTT_NS); + expect(spyTransport).toHaveBeenCalledWith({"level": "debug", "message": "Received MQTT message on 'zigbee2mqtt/skip-this-topic' with data 'skipped'", "namespace": LOG_MQTT_NS}, expect.any(Function)); logger.debug.mockClear(); await controller.mqtt.publish('skip-this-topic', '', {}); await MQTT.events.message('zigbee2mqtt/skip-this-topic', 'skipped'); expect(logger.debug).toHaveBeenCalledTimes(0); + logger.removeTransport(transport) + logger.setTransportsEnabled(false); }); it('On zigbee event message', async () => { diff --git a/test/stub/logger.js b/test/stub/logger.js index b9b9346ca2..127af4be94 100644 --- a/test/stub/logger.js +++ b/test/stub/logger.js @@ -5,8 +5,9 @@ let namespacedLevels = {}; let transports = []; let transportsEnabled = false; -const callTransports = (level, message, namespace) => { +const callTransports = (level, messageOrLambda, namespace) => { if (transportsEnabled) { + const message = messageOrLambda instanceof Function ? messageOrLambda() : messageOrLambda; for (const transport of transports) { transport.log({level, message, namespace}, () => {}); } @@ -15,10 +16,10 @@ const callTransports = (level, message, namespace) => { const mock = { init: jest.fn(), - info: jest.fn().mockImplementation((msg, namespace = 'z2m') => callTransports('info', msg, namespace)), - warning: jest.fn().mockImplementation((msg, namespace = 'z2m') => callTransports('warning', msg, namespace)), - error: jest.fn().mockImplementation((msg, namespace = 'z2m') => callTransports('error', msg, namespace)), - debug: jest.fn().mockImplementation((msg, namespace = 'z2m') => callTransports('debug', msg, namespace)), + info: jest.fn().mockImplementation((messageOrLambda, namespace = 'z2m') => callTransports('info', messageOrLambda, namespace)), + warning: jest.fn().mockImplementation((messageOrLambda, namespace = 'z2m') => callTransports('warning', messageOrLambda, namespace)), + error: jest.fn().mockImplementation((messageOrLambda, namespace = 'z2m') => callTransports('error', messageOrLambda, namespace)), + debug: jest.fn().mockImplementation((messageOrLambda, namespace = 'z2m') => callTransports('debug', messageOrLambda, namespace)), cleanup: jest.fn(), logOutput: jest.fn(), add: (transport) => transports.push(transport), From 5b6f176e118407c760aa2957c43a30ac2dc2282d Mon Sep 17 00:00:00 2001 From: Tomer <57483589+tomer-w@users.noreply.github.com> Date: Mon, 9 Sep 2024 15:56:42 +0300 Subject: [PATCH 13/23] prettier fix --- test/controller.test.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/controller.test.js b/test/controller.test.js index ae5784271c..5660ca0ca5 100644 --- a/test/controller.test.js +++ b/test/controller.test.js @@ -337,8 +337,11 @@ describe('Controller', () => { await controller.start(); logger.debug.mockClear(); await MQTT.events.message('dummytopic', 'dummymessage'); - expect(spyTransport).toHaveBeenCalledWith({"level": "debug", "message": "Received MQTT message on 'dummytopic' with data 'dummymessage'", "namespace": LOG_MQTT_NS}, expect.any(Function)); - logger.removeTransport(transport) + expect(spyTransport).toHaveBeenCalledWith( + {level: 'debug', message: "Received MQTT message on 'dummytopic' with data 'dummymessage'", namespace: LOG_MQTT_NS}, + expect.any(Function), + ); + logger.removeTransport(transport); logger.setTransportsEnabled(false); }); @@ -354,12 +357,15 @@ describe('Controller', () => { await controller.start(); logger.debug.mockClear(); await MQTT.events.message('zigbee2mqtt/skip-this-topic', 'skipped'); - expect(spyTransport).toHaveBeenCalledWith({"level": "debug", "message": "Received MQTT message on 'zigbee2mqtt/skip-this-topic' with data 'skipped'", "namespace": LOG_MQTT_NS}, expect.any(Function)); + expect(spyTransport).toHaveBeenCalledWith( + {level: 'debug', message: "Received MQTT message on 'zigbee2mqtt/skip-this-topic' with data 'skipped'", namespace: LOG_MQTT_NS}, + expect.any(Function), + ); logger.debug.mockClear(); await controller.mqtt.publish('skip-this-topic', '', {}); await MQTT.events.message('zigbee2mqtt/skip-this-topic', 'skipped'); expect(logger.debug).toHaveBeenCalledTimes(0); - logger.removeTransport(transport) + logger.removeTransport(transport); logger.setTransportsEnabled(false); }); From de5b9d623530a098964112a1b4ab1c73ec9f7029 Mon Sep 17 00:00:00 2001 From: Tomer <57483589+tomer-w@users.noreply.github.com> Date: Wed, 11 Sep 2024 14:06:19 +0300 Subject: [PATCH 14/23] Allow easy mocking of stub logger callTransports function to receive the actual message --- test/controller.test.js | 33 +++++++-------------------------- test/stub/logger.js | 27 +++++++++++++++------------ 2 files changed, 22 insertions(+), 38 deletions(-) diff --git a/test/controller.test.js b/test/controller.test.js index 5660ca0ca5..208c17a7c3 100644 --- a/test/controller.test.js +++ b/test/controller.test.js @@ -326,47 +326,28 @@ describe('Controller', () => { }); it('Handle mqtt message', async () => { - class DummyTransport extends Transport { - log(info, callback) {} - } - const transport = new DummyTransport(); - logger.setTransportsEnabled(true); - let spyTransport = jest.spyOn(transport, 'log').mockImplementation(); - logger.addTransport(transport); + const eventbus = controller.eventBus; + let spyEventbusEmitMQTTMessage = jest.spyOn(eventbus, 'emitMQTTMessage').mockImplementation(); await controller.start(); logger.debug.mockClear(); await MQTT.events.message('dummytopic', 'dummymessage'); - expect(spyTransport).toHaveBeenCalledWith( - {level: 'debug', message: "Received MQTT message on 'dummytopic' with data 'dummymessage'", namespace: LOG_MQTT_NS}, - expect.any(Function), - ); - logger.removeTransport(transport); - logger.setTransportsEnabled(false); + expect(spyEventbusEmitMQTTMessage).toHaveBeenCalledWith({topic: 'dummytopic', message: "dummymessage"}); + expect(logger.callTransports).toHaveBeenCalledWith("debug", "Received MQTT message on 'dummytopic' with data 'dummymessage'", LOG_MQTT_NS); }); it('Skip MQTT messages on topic we published to', async () => { - class DummyTransport extends Transport { - log(info, callback) {} - } - const transport = new DummyTransport(); - logger.setTransportsEnabled(true); - let spyTransport = jest.spyOn(transport, 'log').mockImplementation(); - logger.addTransport(transport); + const eventbus = controller.eventBus; + let spyEventbusEmitMQTTMessage = jest.spyOn(eventbus, 'emitMQTTMessage').mockImplementation(); await controller.start(); logger.debug.mockClear(); await MQTT.events.message('zigbee2mqtt/skip-this-topic', 'skipped'); - expect(spyTransport).toHaveBeenCalledWith( - {level: 'debug', message: "Received MQTT message on 'zigbee2mqtt/skip-this-topic' with data 'skipped'", namespace: LOG_MQTT_NS}, - expect.any(Function), - ); + expect(spyEventbusEmitMQTTMessage).toHaveBeenCalledWith({topic: 'zigbee2mqtt/skip-this-topic', message: "skipped"}); logger.debug.mockClear(); await controller.mqtt.publish('skip-this-topic', '', {}); await MQTT.events.message('zigbee2mqtt/skip-this-topic', 'skipped'); expect(logger.debug).toHaveBeenCalledTimes(0); - logger.removeTransport(transport); - logger.setTransportsEnabled(false); }); it('On zigbee event message', async () => { diff --git a/test/stub/logger.js b/test/stub/logger.js index 127af4be94..e0393a801a 100644 --- a/test/stub/logger.js +++ b/test/stub/logger.js @@ -5,21 +5,24 @@ let namespacedLevels = {}; let transports = []; let transportsEnabled = false; -const callTransports = (level, messageOrLambda, namespace) => { - if (transportsEnabled) { - const message = messageOrLambda instanceof Function ? messageOrLambda() : messageOrLambda; - for (const transport of transports) { - transport.log({level, message, namespace}, () => {}); - } - } -}; const mock = { + callTransports:jest.fn().mockImplementation((level, message, namespace) => { + if (transportsEnabled) { + for (const transport of transports) { + transport.log({level, message, namespace}, () => {}); + } + } + }), + log: (level, messageOrLambda, namespace = 'z2m') => { + const message = messageOrLambda instanceof Function ? messageOrLambda() : messageOrLambda; + mock.callTransports(level, message, namespace) + }, init: jest.fn(), - info: jest.fn().mockImplementation((messageOrLambda, namespace = 'z2m') => callTransports('info', messageOrLambda, namespace)), - warning: jest.fn().mockImplementation((messageOrLambda, namespace = 'z2m') => callTransports('warning', messageOrLambda, namespace)), - error: jest.fn().mockImplementation((messageOrLambda, namespace = 'z2m') => callTransports('error', messageOrLambda, namespace)), - debug: jest.fn().mockImplementation((messageOrLambda, namespace = 'z2m') => callTransports('debug', messageOrLambda, namespace)), + info: jest.fn().mockImplementation((messageOrLambda, namespace = 'z2m') => mock.log('info', messageOrLambda, namespace)), + warning: jest.fn().mockImplementation((messageOrLambda, namespace = 'z2m') => mock.log('warning', messageOrLambda, namespace)), + error: jest.fn().mockImplementation((messageOrLambda, namespace = 'z2m') => mock.log('error', messageOrLambda, namespace)), + debug: jest.fn().mockImplementation((messageOrLambda, namespace = 'z2m') => mock.log('debug', messageOrLambda, namespace)), cleanup: jest.fn(), logOutput: jest.fn(), add: (transport) => transports.push(transport), From ed7c82e3857e572ab6316f0a063e0b7971915dc2 Mon Sep 17 00:00:00 2001 From: Tomer <57483589+tomer-w@users.noreply.github.com> Date: Wed, 11 Sep 2024 14:18:56 +0300 Subject: [PATCH 15/23] cleanup leftover --- test/controller.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/controller.test.js b/test/controller.test.js index 208c17a7c3..34b46f66e2 100644 --- a/test/controller.test.js +++ b/test/controller.test.js @@ -1,7 +1,6 @@ process.env.NOTIFY_SOCKET = 'mocked'; const data = require('./stub/data'); const logger = require('./stub/logger'); -const Transport = require('winston-transport'); const zigbeeHerdsman = require('./stub/zigbeeHerdsman'); const MQTT = require('./stub/mqtt'); const path = require('path'); From 75e81f83ee50b8d550b2d8cf15cde24c351dbe35 Mon Sep 17 00:00:00 2001 From: Tomer <57483589+tomer-w@users.noreply.github.com> Date: Wed, 11 Sep 2024 14:37:26 +0300 Subject: [PATCH 16/23] Fix prettier issues --- test/controller.test.js | 6 +++--- test/stub/logger.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/controller.test.js b/test/controller.test.js index 34b46f66e2..739401fd7f 100644 --- a/test/controller.test.js +++ b/test/controller.test.js @@ -331,8 +331,8 @@ describe('Controller', () => { await controller.start(); logger.debug.mockClear(); await MQTT.events.message('dummytopic', 'dummymessage'); - expect(spyEventbusEmitMQTTMessage).toHaveBeenCalledWith({topic: 'dummytopic', message: "dummymessage"}); - expect(logger.callTransports).toHaveBeenCalledWith("debug", "Received MQTT message on 'dummytopic' with data 'dummymessage'", LOG_MQTT_NS); + expect(spyEventbusEmitMQTTMessage).toHaveBeenCalledWith({topic: 'dummytopic', message: 'dummymessage'}); + expect(logger.callTransports).toHaveBeenCalledWith('debug', "Received MQTT message on 'dummytopic' with data 'dummymessage'", LOG_MQTT_NS); }); it('Skip MQTT messages on topic we published to', async () => { @@ -342,7 +342,7 @@ describe('Controller', () => { await controller.start(); logger.debug.mockClear(); await MQTT.events.message('zigbee2mqtt/skip-this-topic', 'skipped'); - expect(spyEventbusEmitMQTTMessage).toHaveBeenCalledWith({topic: 'zigbee2mqtt/skip-this-topic', message: "skipped"}); + expect(spyEventbusEmitMQTTMessage).toHaveBeenCalledWith({topic: 'zigbee2mqtt/skip-this-topic', message: 'skipped'}); logger.debug.mockClear(); await controller.mqtt.publish('skip-this-topic', '', {}); await MQTT.events.message('zigbee2mqtt/skip-this-topic', 'skipped'); diff --git a/test/stub/logger.js b/test/stub/logger.js index e0393a801a..f533f643af 100644 --- a/test/stub/logger.js +++ b/test/stub/logger.js @@ -7,7 +7,7 @@ let transports = []; let transportsEnabled = false; const mock = { - callTransports:jest.fn().mockImplementation((level, message, namespace) => { + callTransports: jest.fn().mockImplementation((level, message, namespace) => { if (transportsEnabled) { for (const transport of transports) { transport.log({level, message, namespace}, () => {}); @@ -16,7 +16,7 @@ const mock = { }), log: (level, messageOrLambda, namespace = 'z2m') => { const message = messageOrLambda instanceof Function ? messageOrLambda() : messageOrLambda; - mock.callTransports(level, message, namespace) + mock.callTransports(level, message, namespace); }, init: jest.fn(), info: jest.fn().mockImplementation((messageOrLambda, namespace = 'z2m') => mock.log('info', messageOrLambda, namespace)), From bb2c4be36f8ef102d186c4280267bae5e2164554 Mon Sep 17 00:00:00 2001 From: Tomer <57483589+tomer-w@users.noreply.github.com> Date: Thu, 12 Sep 2024 07:28:48 +0300 Subject: [PATCH 17/23] Finalize logger mock structure and add few lambda log calls --- lib/zigbee.ts | 9 ++++----- test/controller.test.js | 2 +- test/stub/logger.js | 19 +++++++------------ 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/lib/zigbee.ts b/lib/zigbee.ts index e2796c9a21..ea15cdaa9f 100644 --- a/lib/zigbee.ts +++ b/lib/zigbee.ts @@ -56,8 +56,7 @@ export default class Zigbee { acceptJoiningDeviceHandler: this.acceptJoiningDeviceHandler, }; - const herdsmanSettingsLog = JSON.stringify(herdsmanSettings).replaceAll(JSON.stringify(herdsmanSettings.network.networkKey), '"HIDDEN"'); - logger.debug(`Using zigbee-herdsman with settings: '${stringify(herdsmanSettingsLog)}'`); + logger.debug(() => `Using zigbee-herdsman with settings: '${stringify(JSON.stringify(herdsmanSettings).replaceAll(JSON.stringify(herdsmanSettings.network.networkKey), '"HIDDEN"'))}'`); let startResult; try { @@ -112,7 +111,7 @@ export default class Zigbee { this.herdsman.on('message', async (data: ZHEvents.MessagePayload) => { const device = this.resolveDevice(data.device.ieeeAddr)!; await device.resolveDefinition(); - logger.debug( + logger.debug(() => `Received Zigbee message from '${device.name}', type '${data.type}', ` + `cluster '${data.cluster}', data '${stringify(data.data)}' from endpoint ${data.endpoint.ID}` + (data.hasOwnProperty('groupID') ? ` with groupID ${data.groupID}` : ``) + @@ -123,8 +122,8 @@ export default class Zigbee { }); logger.info(`zigbee-herdsman started (${startResult})`); - logger.info(`Coordinator firmware version: '${stringify(await this.getCoordinatorVersion())}'`); - logger.debug(`Zigbee network parameters: ${stringify(await this.herdsman.getNetworkParameters())}`); + logger.info(() => `Coordinator firmware version: '${stringify(this.getCoordinatorVersion())}'`); + logger.debug(() => `Zigbee network parameters: ${stringify(this.herdsman.getNetworkParameters())}`); for (const device of this.devicesIterator(utils.deviceNotCoordinator)) { // If a passlist is used, all other device will be removed from the network. diff --git a/test/controller.test.js b/test/controller.test.js index 739401fd7f..7d14787cfb 100644 --- a/test/controller.test.js +++ b/test/controller.test.js @@ -332,7 +332,7 @@ describe('Controller', () => { logger.debug.mockClear(); await MQTT.events.message('dummytopic', 'dummymessage'); expect(spyEventbusEmitMQTTMessage).toHaveBeenCalledWith({topic: 'dummytopic', message: 'dummymessage'}); - expect(logger.callTransports).toHaveBeenCalledWith('debug', "Received MQTT message on 'dummytopic' with data 'dummymessage'", LOG_MQTT_NS); + expect(logger.log).toHaveBeenCalledWith('debug', "Received MQTT message on 'dummytopic' with data 'dummymessage'", LOG_MQTT_NS); }); it('Skip MQTT messages on topic we published to', async () => { diff --git a/test/stub/logger.js b/test/stub/logger.js index f533f643af..6bf3813db3 100644 --- a/test/stub/logger.js +++ b/test/stub/logger.js @@ -1,28 +1,23 @@ let level = 'info'; let debugNamespaceIgnore = ''; let namespacedLevels = {}; - let transports = []; - let transportsEnabled = false; +const getMessage = (messageOrLambda) => (messageOrLambda instanceof Function ? messageOrLambda() : messageOrLambda); const mock = { - callTransports: jest.fn().mockImplementation((level, message, namespace) => { + log: jest.fn().mockImplementation((level, message, namespace = 'z2m') => { if (transportsEnabled) { for (const transport of transports) { - transport.log({level, message, namespace}, () => {}); + mock.callTransports(level, message, namespace); } } }), - log: (level, messageOrLambda, namespace = 'z2m') => { - const message = messageOrLambda instanceof Function ? messageOrLambda() : messageOrLambda; - mock.callTransports(level, message, namespace); - }, init: jest.fn(), - info: jest.fn().mockImplementation((messageOrLambda, namespace = 'z2m') => mock.log('info', messageOrLambda, namespace)), - warning: jest.fn().mockImplementation((messageOrLambda, namespace = 'z2m') => mock.log('warning', messageOrLambda, namespace)), - error: jest.fn().mockImplementation((messageOrLambda, namespace = 'z2m') => mock.log('error', messageOrLambda, namespace)), - debug: jest.fn().mockImplementation((messageOrLambda, namespace = 'z2m') => mock.log('debug', messageOrLambda, namespace)), + info: jest.fn().mockImplementation((messageOrLambda, namespace = 'z2m') => mock.log('info', getMessage(messageOrLambda), namespace)), + warning: jest.fn().mockImplementation((messageOrLambda, namespace = 'z2m') => mock.log('warning', getMessage(messageOrLambda), namespace)), + error: jest.fn().mockImplementation((messageOrLambda, namespace = 'z2m') => mock.log('error', getMessage(messageOrLambda), namespace)), + debug: jest.fn().mockImplementation((messageOrLambda, namespace = 'z2m') => mock.log('debug', getMessage(messageOrLambda), namespace)), cleanup: jest.fn(), logOutput: jest.fn(), add: (transport) => transports.push(transport), From b409d538e389ae170f86ab5618b32d3e97992b23 Mon Sep 17 00:00:00 2001 From: Tomer <57483589+tomer-w@users.noreply.github.com> Date: Thu, 12 Sep 2024 07:32:34 +0300 Subject: [PATCH 18/23] fix prettier issue --- .vscode/launch.json | 13 +++++++++++++ data/configuration.yaml | 6 +++++- lib/zigbee.ts | 10 +++++++--- package-lock.json | 15 +++++++++++++-- package.json | 1 + 5 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000000..96be28ceb8 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,13 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Jest", + "program": "${workspaceRoot}/node_modules/jest/bin/jest.js", + "args": ["-i", "-t", "Handle mqtt message"], + "skipFiles": ["/**/*.js", "node_modules"] + } + ] +} diff --git a/data/configuration.yaml b/data/configuration.yaml index 3ed7c1ce00..5dc604bc62 100644 --- a/data/configuration.yaml +++ b/data/configuration.yaml @@ -17,4 +17,8 @@ mqtt: # Serial settings serial: # Location of CC2531 USB sniffer - port: /dev/ttyACM0 + port: COM5 + adapter: deconz + +advanced: + log_level: debug \ No newline at end of file diff --git a/lib/zigbee.ts b/lib/zigbee.ts index 8ad537d56e..4e49922152 100644 --- a/lib/zigbee.ts +++ b/lib/zigbee.ts @@ -58,7 +58,10 @@ export default class Zigbee { acceptJoiningDeviceHandler: this.acceptJoiningDeviceHandler, }; - logger.debug(() => `Using zigbee-herdsman with settings: '${stringify(JSON.stringify(herdsmanSettings).replaceAll(JSON.stringify(herdsmanSettings.network.networkKey), '"HIDDEN"'))}'`); + logger.debug( + () => + `Using zigbee-herdsman with settings: '${stringify(JSON.stringify(herdsmanSettings).replaceAll(JSON.stringify(herdsmanSettings.network.networkKey), '"HIDDEN"'))}'`, + ); let startResult; try { @@ -113,8 +116,9 @@ export default class Zigbee { this.herdsman.on('message', async (data: ZHEvents.MessagePayload) => { const device = this.resolveDevice(data.device.ieeeAddr)!; await device.resolveDefinition(); - logger.debug(() => - `Received Zigbee message from '${device.name}', type '${data.type}', ` + + logger.debug( + () => + `Received Zigbee message from '${device.name}', type '${data.type}', ` + `cluster '${data.cluster}', data '${stringify(data.data)}' from endpoint ${data.endpoint.ID}` + (data['groupID'] !== undefined ? ` with groupID ${data.groupID}` : ``) + (device.zh.type === 'Coordinator' ? `, ignoring since it is from coordinator` : ``), diff --git a/package-lock.json b/package-lock.json index a1e5f75868..38f5c18e8a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,6 +24,7 @@ "moment": "^2.30.1", "mqtt": "^5.10.1", "object-assign-deep": "^0.4.0", + "prettier-plugin-sort-imports": "^1.8.6", "rimraf": "^6.0.1", "semver": "^7.6.3", "source-map-support": "^0.5.21", @@ -8805,7 +8806,6 @@ "version": "3.3.3", "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", - "dev": true, "license": "MIT", "bin": { "prettier": "bin/prettier.cjs" @@ -8817,6 +8817,18 @@ "url": "https://github.com/prettier/prettier?sponsor=1" } }, + "node_modules/prettier-plugin-sort-imports": { + "version": "1.8.6", + "resolved": "https://registry.npmjs.org/prettier-plugin-sort-imports/-/prettier-plugin-sort-imports-1.8.6.tgz", + "integrity": "sha512-jOEzFCyvdDL8geCmr4DP/VBKULZ6OaDQHBEmHTuFHf4EzWyedmwnHg2KawNy5rnrQ6gnCqwrfgymMQZctzCE1Q==", + "license": "MIT", + "dependencies": { + "prettier": "^3.1.1" + }, + "peerDependencies": { + "typescript": ">4.0.0" + } + }, "node_modules/pretty-format": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz", @@ -9810,7 +9822,6 @@ "version": "5.5.4", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", - "dev": true, "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", diff --git a/package.json b/package.json index eb11f77731..7f91be7728 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "moment": "^2.30.1", "mqtt": "^5.10.1", "object-assign-deep": "^0.4.0", + "prettier-plugin-sort-imports": "^1.8.6", "rimraf": "^6.0.1", "semver": "^7.6.3", "source-map-support": "^0.5.21", From 1c88f022eefeec3a7be2e4815c264781507374dd Mon Sep 17 00:00:00 2001 From: Tomer <57483589+tomer-w@users.noreply.github.com> Date: Thu, 12 Sep 2024 07:44:53 +0300 Subject: [PATCH 19/23] Run prettier --- lib/zigbee.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/zigbee.ts b/lib/zigbee.ts index ea15cdaa9f..f9fd9cb387 100644 --- a/lib/zigbee.ts +++ b/lib/zigbee.ts @@ -56,7 +56,10 @@ export default class Zigbee { acceptJoiningDeviceHandler: this.acceptJoiningDeviceHandler, }; - logger.debug(() => `Using zigbee-herdsman with settings: '${stringify(JSON.stringify(herdsmanSettings).replaceAll(JSON.stringify(herdsmanSettings.network.networkKey), '"HIDDEN"'))}'`); + logger.debug( + () => + `Using zigbee-herdsman with settings: '${stringify(JSON.stringify(herdsmanSettings).replaceAll(JSON.stringify(herdsmanSettings.network.networkKey), '"HIDDEN"'))}'`, + ); let startResult; try { @@ -111,8 +114,9 @@ export default class Zigbee { this.herdsman.on('message', async (data: ZHEvents.MessagePayload) => { const device = this.resolveDevice(data.device.ieeeAddr)!; await device.resolveDefinition(); - logger.debug(() => - `Received Zigbee message from '${device.name}', type '${data.type}', ` + + logger.debug( + () => + `Received Zigbee message from '${device.name}', type '${data.type}', ` + `cluster '${data.cluster}', data '${stringify(data.data)}' from endpoint ${data.endpoint.ID}` + (data.hasOwnProperty('groupID') ? ` with groupID ${data.groupID}` : ``) + (device.zh.type === 'Coordinator' ? `, ignoring since it is from coordinator` : ``), From f7b88ff5959ad25dca1a50d4d813218678a5b0a6 Mon Sep 17 00:00:00 2001 From: Tomer <57483589+tomer-w@users.noreply.github.com> Date: Thu, 12 Sep 2024 08:55:35 +0300 Subject: [PATCH 20/23] Revert "fix prettier issue" This reverts commit b409d538e389ae170f86ab5618b32d3e97992b23. --- .vscode/launch.json | 13 ------------- data/configuration.yaml | 6 +----- lib/zigbee.ts | 10 +++------- package-lock.json | 15 ++------------- package.json | 1 - 5 files changed, 6 insertions(+), 39 deletions(-) delete mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 96be28ceb8..0000000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "type": "node", - "request": "launch", - "name": "Jest", - "program": "${workspaceRoot}/node_modules/jest/bin/jest.js", - "args": ["-i", "-t", "Handle mqtt message"], - "skipFiles": ["/**/*.js", "node_modules"] - } - ] -} diff --git a/data/configuration.yaml b/data/configuration.yaml index 5dc604bc62..3ed7c1ce00 100644 --- a/data/configuration.yaml +++ b/data/configuration.yaml @@ -17,8 +17,4 @@ mqtt: # Serial settings serial: # Location of CC2531 USB sniffer - port: COM5 - adapter: deconz - -advanced: - log_level: debug \ No newline at end of file + port: /dev/ttyACM0 diff --git a/lib/zigbee.ts b/lib/zigbee.ts index 4e49922152..8ad537d56e 100644 --- a/lib/zigbee.ts +++ b/lib/zigbee.ts @@ -58,10 +58,7 @@ export default class Zigbee { acceptJoiningDeviceHandler: this.acceptJoiningDeviceHandler, }; - logger.debug( - () => - `Using zigbee-herdsman with settings: '${stringify(JSON.stringify(herdsmanSettings).replaceAll(JSON.stringify(herdsmanSettings.network.networkKey), '"HIDDEN"'))}'`, - ); + logger.debug(() => `Using zigbee-herdsman with settings: '${stringify(JSON.stringify(herdsmanSettings).replaceAll(JSON.stringify(herdsmanSettings.network.networkKey), '"HIDDEN"'))}'`); let startResult; try { @@ -116,9 +113,8 @@ export default class Zigbee { this.herdsman.on('message', async (data: ZHEvents.MessagePayload) => { const device = this.resolveDevice(data.device.ieeeAddr)!; await device.resolveDefinition(); - logger.debug( - () => - `Received Zigbee message from '${device.name}', type '${data.type}', ` + + logger.debug(() => + `Received Zigbee message from '${device.name}', type '${data.type}', ` + `cluster '${data.cluster}', data '${stringify(data.data)}' from endpoint ${data.endpoint.ID}` + (data['groupID'] !== undefined ? ` with groupID ${data.groupID}` : ``) + (device.zh.type === 'Coordinator' ? `, ignoring since it is from coordinator` : ``), diff --git a/package-lock.json b/package-lock.json index 38f5c18e8a..a1e5f75868 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,7 +24,6 @@ "moment": "^2.30.1", "mqtt": "^5.10.1", "object-assign-deep": "^0.4.0", - "prettier-plugin-sort-imports": "^1.8.6", "rimraf": "^6.0.1", "semver": "^7.6.3", "source-map-support": "^0.5.21", @@ -8806,6 +8805,7 @@ "version": "3.3.3", "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", + "dev": true, "license": "MIT", "bin": { "prettier": "bin/prettier.cjs" @@ -8817,18 +8817,6 @@ "url": "https://github.com/prettier/prettier?sponsor=1" } }, - "node_modules/prettier-plugin-sort-imports": { - "version": "1.8.6", - "resolved": "https://registry.npmjs.org/prettier-plugin-sort-imports/-/prettier-plugin-sort-imports-1.8.6.tgz", - "integrity": "sha512-jOEzFCyvdDL8geCmr4DP/VBKULZ6OaDQHBEmHTuFHf4EzWyedmwnHg2KawNy5rnrQ6gnCqwrfgymMQZctzCE1Q==", - "license": "MIT", - "dependencies": { - "prettier": "^3.1.1" - }, - "peerDependencies": { - "typescript": ">4.0.0" - } - }, "node_modules/pretty-format": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz", @@ -9822,6 +9810,7 @@ "version": "5.5.4", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", + "dev": true, "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", diff --git a/package.json b/package.json index 7f91be7728..eb11f77731 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,6 @@ "moment": "^2.30.1", "mqtt": "^5.10.1", "object-assign-deep": "^0.4.0", - "prettier-plugin-sort-imports": "^1.8.6", "rimraf": "^6.0.1", "semver": "^7.6.3", "source-map-support": "^0.5.21", From f14d9f1dafb61259ef0c2d294b76c6e2195469ec Mon Sep 17 00:00:00 2001 From: Tomer <57483589+tomer-w@users.noreply.github.com> Date: Thu, 12 Sep 2024 09:02:54 +0300 Subject: [PATCH 21/23] Update zigbee.ts Fix prettier issue --- lib/zigbee.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/zigbee.ts b/lib/zigbee.ts index 8ad537d56e..4e49922152 100644 --- a/lib/zigbee.ts +++ b/lib/zigbee.ts @@ -58,7 +58,10 @@ export default class Zigbee { acceptJoiningDeviceHandler: this.acceptJoiningDeviceHandler, }; - logger.debug(() => `Using zigbee-herdsman with settings: '${stringify(JSON.stringify(herdsmanSettings).replaceAll(JSON.stringify(herdsmanSettings.network.networkKey), '"HIDDEN"'))}'`); + logger.debug( + () => + `Using zigbee-herdsman with settings: '${stringify(JSON.stringify(herdsmanSettings).replaceAll(JSON.stringify(herdsmanSettings.network.networkKey), '"HIDDEN"'))}'`, + ); let startResult; try { @@ -113,8 +116,9 @@ export default class Zigbee { this.herdsman.on('message', async (data: ZHEvents.MessagePayload) => { const device = this.resolveDevice(data.device.ieeeAddr)!; await device.resolveDefinition(); - logger.debug(() => - `Received Zigbee message from '${device.name}', type '${data.type}', ` + + logger.debug( + () => + `Received Zigbee message from '${device.name}', type '${data.type}', ` + `cluster '${data.cluster}', data '${stringify(data.data)}' from endpoint ${data.endpoint.ID}` + (data['groupID'] !== undefined ? ` with groupID ${data.groupID}` : ``) + (device.zh.type === 'Coordinator' ? `, ignoring since it is from coordinator` : ``), From 113b29976db6577a350b9a1431c80ff4d6e07d09 Mon Sep 17 00:00:00 2001 From: Tomer <57483589+tomer-w@users.noreply.github.com> Date: Thu, 12 Sep 2024 09:39:38 +0300 Subject: [PATCH 22/23] Fix test issues --- test/controller.test.js | 12 +++++++++--- test/publish.test.js | 2 +- test/stub/logger.js | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/test/controller.test.js b/test/controller.test.js index 7d14787cfb..b71723c37d 100644 --- a/test/controller.test.js +++ b/test/controller.test.js @@ -362,8 +362,10 @@ describe('Controller', () => { }; await zigbeeHerdsman.events.message(payload); await flushPromises(); - expect(logger.debug).toHaveBeenCalledWith( + expect(logger.log).toHaveBeenCalledWith( + 'debug', `Received Zigbee message from 'bulb', type 'attributeReport', cluster 'genBasic', data '{"modelId":"TRADFRI bulb E27 WS opal 980lm"}' from endpoint 1`, + 'z2m', ); }); @@ -381,8 +383,10 @@ describe('Controller', () => { }; await zigbeeHerdsman.events.message(payload); await flushPromises(); - expect(logger.debug).toHaveBeenCalledWith( + expect(logger.log).toHaveBeenCalledWith( + 'debug', `Received Zigbee message from 'bulb', type 'attributeReport', cluster 'genBasic', data '{"modelId":"TRADFRI bulb E27 WS opal 980lm"}' from endpoint 1 with groupID 0`, + 'z2m', ); }); @@ -971,8 +975,10 @@ describe('Controller', () => { }; await zigbeeHerdsman.events.message(payload); await flushPromises(); - expect(logger.debug).toHaveBeenCalledWith( + expect(logger.log).toHaveBeenCalledWith( + 'debug', `Received Zigbee message from 'Coordinator', type 'attributeReport', cluster 'genBasic', data '{"modelId":null}' from endpoint 1, ignoring since it is from coordinator`, + 'z2m', ); }); diff --git a/test/publish.test.js b/test/publish.test.js index 3d0b129bc3..fe7d370eef 100644 --- a/test/publish.test.js +++ b/test/publish.test.js @@ -600,7 +600,7 @@ describe('Publish', () => { await MQTT.events.message(`zigbee2mqtt/${device.ieeeAddr}/set`, stringify({state: 'OFF'})); await flushPromises(); console.log(logger.error.mock.calls); - expect(logger.error).toHaveBeenCalledWith(`Cannot publish to unsupported device 'button_double_key_interviewing'`); + expect(logger.log).toHaveBeenCalledWith('error', `Cannot publish to unsupported device 'button_double_key_interviewing'`, 'z2m'); }); it('Should log error when device has no such endpoint (via property)', async () => { diff --git a/test/stub/logger.js b/test/stub/logger.js index 6bf3813db3..c03dd45c47 100644 --- a/test/stub/logger.js +++ b/test/stub/logger.js @@ -9,7 +9,7 @@ const mock = { log: jest.fn().mockImplementation((level, message, namespace = 'z2m') => { if (transportsEnabled) { for (const transport of transports) { - mock.callTransports(level, message, namespace); + transport.log({level, message, namespace}, () => {}); } } }), From 48a21574d769ea29a7507c691cb5c1b4b44a8d76 Mon Sep 17 00:00:00 2001 From: Tomer <57483589+tomer-w@users.noreply.github.com> Date: Thu, 12 Sep 2024 15:17:29 +0300 Subject: [PATCH 23/23] Revert await removal --- lib/zigbee.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/zigbee.ts b/lib/zigbee.ts index 4e49922152..2ce66b1080 100644 --- a/lib/zigbee.ts +++ b/lib/zigbee.ts @@ -128,8 +128,8 @@ export default class Zigbee { }); logger.info(`zigbee-herdsman started (${startResult})`); - logger.info(() => `Coordinator firmware version: '${stringify(this.getCoordinatorVersion())}'`); - logger.debug(() => `Zigbee network parameters: ${stringify(this.herdsman.getNetworkParameters())}`); + logger.info(`Coordinator firmware version: '${stringify(await this.getCoordinatorVersion())}'`); + logger.debug(`Zigbee network parameters: ${stringify(await this.herdsman.getNetworkParameters())}`); for (const device of this.devicesIterator(utils.deviceNotCoordinator)) { // If a passlist is used, all other device will be removed from the network.