From b7b0564b6269af5ac0c1a89222efedab4494506d Mon Sep 17 00:00:00 2001 From: Donavan Becker Date: Fri, 1 Nov 2024 16:10:27 -0500 Subject: [PATCH] platform config --- .github/auto-merge.yml | 3 - .github/workflows/beta-release.yml | 25 ++++---- .github/workflows/build.yml | 4 +- .github/workflows/changerelease.yml | 2 +- .github/workflows/dependabot.yml | 13 ---- .github/workflows/labeler.yml | 2 +- .github/workflows/release-drafter.yml | 2 +- .github/workflows/release.yml | 23 +++---- .github/workflows/stale.yml | 2 +- package-lock.json | 88 ++++++++++++++++----------- package.json | 6 +- src/devices/device.ts | 8 +-- src/platform.ts | 1 + 13 files changed, 91 insertions(+), 88 deletions(-) delete mode 100644 .github/auto-merge.yml delete mode 100644 .github/workflows/dependabot.yml diff --git a/.github/auto-merge.yml b/.github/auto-merge.yml deleted file mode 100644 index 9a6f2f8..0000000 --- a/.github/auto-merge.yml +++ /dev/null @@ -1,3 +0,0 @@ -- match: - dependency_type: all - update_type: all \ No newline at end of file diff --git a/.github/workflows/beta-release.yml b/.github/workflows/beta-release.yml index ca0d55f..7c6f30f 100644 --- a/.github/workflows/beta-release.yml +++ b/.github/workflows/beta-release.yml @@ -7,21 +7,21 @@ on: jobs: build_and_test: - uses: donavanbecker/.github/.github/workflows/nodejs-build-and-test.yml@latest + uses: homebridge/.github/.github/workflows/nodejs-build-and-test.yml@latest with: enable_coverage: true secrets: token: ${{ secrets.GITHUB_TOKEN }} lint: needs: build_and_test - uses: donavanbecker/.github/.github/workflows/eslint.yml@latest + uses: homebridge/.github/.github/workflows/eslint.yml@latest publish: needs: lint - if: ${{ github.repository == 'homebridge-plugins/homebridge-air' }} - - uses: donavanbecker/.github/.github/workflows/npm-publish.yml@latest + permissions: + id-token: write + uses: homebridge/.github/.github/workflows/npm-publish-esm.yml@latest with: tag: 'beta' dynamically_adjust_version: true @@ -33,7 +33,7 @@ jobs: pre-release: needs: publish if: ${{ github.repository == 'homebridge-plugins/homebridge-air' }} - uses: donavanbecker/.github/.github/workflows/pre-release.yml@latest + uses: homebridge/.github/.github/workflows/pre-release.yml@latest with: npm_version: ${{ needs.publish.outputs.NPM_VERSION }} body: | @@ -42,11 +42,14 @@ jobs: [How To Test Beta Releases](https://github.com/homebridge-plugins/homebridge-air/wiki/Beta-Version) github-releases-to-discord: - needs: [publish, pre-release] + name: Discord Webhooks + needs: [build_and_test,publish] if: ${{ github.repository == 'homebridge-plugins/homebridge-air' }} - uses: donavanbecker/.github/.github/workflows/discord-webhooks.yml@latest + uses: homebridge/.github/.github/workflows/discord-webhooks.yml@latest with: - message_title: "RainBird Beta Release" - message_url: "https://github.com/OpenWonderLabs/homebridge-air/releases/tag/v${{ needs.publish.outputs.NPM_VERSION }}" + title: "Air Beta Release" + description: | + Version `v${{ needs.publish.outputs.NPM_VERSION }}` + url: "https://github.com/homebridge-plugins/homebridge-air/releases/tag/v${{ needs.publish.outputs.NPM_VERSION }}" secrets: - DISCORD_WEBHOOK_URL_BETA: ${{ secrets.DISCORD_WEBHOOK_URL_BETA }} + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL_BETA || secrets.DISCORD_WEBHOOK_URL_LATEST }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 842fa20..8fbf227 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,11 +8,11 @@ on: jobs: build_and_test: - uses: donavanbecker/.github/.github/workflows/nodejs-build-and-test.yml@latest + uses: homebridge/.github/.github/workflows/nodejs-build-and-test.yml@latest with: enable_coverage: true secrets: token: ${{ secrets.GITHUB_TOKEN }} lint: needs: build_and_test - uses: donavanbecker/.github/.github/workflows/eslint.yml@latest + uses: homebridge/.github/.github/workflows/eslint.yml@latest diff --git a/.github/workflows/changerelease.yml b/.github/workflows/changerelease.yml index 111ba97..135b42d 100644 --- a/.github/workflows/changerelease.yml +++ b/.github/workflows/changerelease.yml @@ -6,6 +6,6 @@ on: jobs: changerelease: - uses: donavanbecker/.github/.github/workflows/changerelease.yml@latest + uses: homebridge/.github/.github/workflows/change-release.yml@latest secrets: token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml deleted file mode 100644 index 525d2b2..0000000 --- a/.github/workflows/dependabot.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: AutoDependabot - -on: - pull_request: - branches: [ beta, latest ] - pull_request_target: - branches: [ beta, latest ] - -jobs: - dependabot: - uses: donavanbecker/.github/.github/workflows/dependabot.yml@latest - secrets: - token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 6eb3c01..d3af51c 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -4,6 +4,6 @@ on: [pull_request] jobs: labeler: - uses: donavanbecker/.github/.github/workflows/labeler.yml@latest + uses: homebridge/.github/.github/workflows/labeler.yml@latest secrets: token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 8326f06..87bed0f 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -9,6 +9,6 @@ on: jobs: release-drafter: - uses: donavanbecker/.github/.github/workflows/release-drafter.yml@latest + uses: homebridge/.github/.github/workflows/release-drafter.yml@latest secrets: token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 900869f..b5e3bd6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,7 @@ on: jobs: build_and_test: - uses: donavanbecker/.github/.github/workflows/nodejs-build-and-test.yml@latest + uses: homebridge/.github/.github/workflows/nodejs-build-and-test.yml@latest with: enable_coverage: true secrets: @@ -14,21 +14,22 @@ jobs: publish: needs: build_and_test - if: ${{ github.repository == 'homebridge-plugins/homebridge-air' }} - - uses: donavanbecker/.github/.github/workflows/npm-publish.yml@latest + permissions: + id-token: write + uses: homebridge/.github/.github/workflows/npm-publish-esm.yml@latest secrets: npm_auth_token: ${{ secrets.npm_token }} github-releases-to-discord: - needs: publish - + name: Discord Webhooks + needs: [build_and_test,publish] if: ${{ github.repository == 'homebridge-plugins/homebridge-air' }} - - uses: donavanbecker/.github/.github/workflows/discord-webhooks.yml@latest + uses: homebridge/.github/.github/workflows/discord-webhooks.yml@latest with: - message_title: "Air" - message_url: "https://github.com/donavanbecker/homebridge-august/releases/tag/v${{ github.event.release.tag_name }}" + title: "Air Release" + description: | + Version `v${{ needs.publish.outputs.NPM_VERSION }}` + url: "https://github.com/homebridge-plugins/homebridge-air/releases/tag/v${{ needs.publish.outputs.NPM_VERSION }}" secrets: - DISCORD_WEBHOOK_URL_LATEST: ${{ secrets.DISCORD_WEBHOOK_URL_LATEST }} + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL_LATEST }} diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index f07b234..2683a78 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -7,6 +7,6 @@ on: jobs: stale: - uses: donavanbecker/.github/.github/workflows/stale.yml@latest + uses: homebridge/.github/.github/workflows/stale.yml@latest secrets: token: ${{ secrets.GITHUB_TOKEN }} diff --git a/package-lock.json b/package-lock.json index 93e686e..cc35746 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,11 +31,11 @@ "@types/fs-extra": "^11.0.4", "@types/jest": "^29.5.14", "@types/mdast": "^4.0.4", - "@types/node": "^22.8.5", + "@types/node": "^22.8.6", "@types/semver": "^7.5.8", "@types/source-map-support": "^0.5.10", "@vitest/coverage-v8": "^2.1.4", - "eslint": "^9.13.0", + "eslint": "^9.14.0", "eslint-plugin-format": "^0.1.2", "homebridge": "^1.8.5", "homebridge-config-ui-x": "4.62.0", @@ -44,7 +44,7 @@ "npm-check-updates": "^17.1.9", "shx": "^0.3.4", "ts-node": "^10.9.2", - "typedoc": "^0.26.10", + "typedoc": "^0.26.11", "typescript": "^5.6.3", "typescript-axios-wb": "^1.0.3", "vitest": "^2.1.4" @@ -1395,9 +1395,9 @@ } }, "node_modules/@eslint/js": { - "version": "9.13.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.13.0.tgz", - "integrity": "sha512-IFLyoY4d72Z5y/6o/BazFBezupzI/taV8sGumxTAVw3lXG9A6md1Dc34T9s1FoD/an9pJH8RHbAxsaEbBed9lA==", + "version": "9.14.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.14.0.tgz", + "integrity": "sha512-pFoEtFWCPyDOl+C6Ift+wC7Ro89otjigCf5vcuWqWgqNSQbRrpjSvdeE6ofLz4dHmyxD5f7gIdGT4+p36L6Twg==", "dev": true, "license": "MIT", "engines": { @@ -1760,6 +1760,20 @@ "node": ">=18.18.0" } }, + "node_modules/@humanfs/node/node_modules/@humanwhocodes/retry": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.3.1.tgz", + "integrity": "sha512-JBxkERygn7Bv/GbN5Rv8Ul6LVknS+5Bp6RgDC/O8gEBU/yeH5Ui5C/OlWrTb6qct7LjjfT6Re2NxB0ln0yYybA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, "node_modules/@humanwhocodes/module-importer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", @@ -1775,9 +1789,9 @@ } }, "node_modules/@humanwhocodes/retry": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.3.1.tgz", - "integrity": "sha512-JBxkERygn7Bv/GbN5Rv8Ul6LVknS+5Bp6RgDC/O8gEBU/yeH5Ui5C/OlWrTb6qct7LjjfT6Re2NxB0ln0yYybA==", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.0.tgz", + "integrity": "sha512-xnRgu9DxZbkWak/te3fcytNyp8MTbuiZIaueg2rgEvBuN55n04nwLYLU9TX/VVlusc9L2ZNXi99nUFNkHXtr5g==", "dev": true, "license": "Apache-2.0", "engines": { @@ -3175,9 +3189,9 @@ "license": "MIT" }, "node_modules/@stylistic/eslint-plugin": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin/-/eslint-plugin-2.10.0.tgz", - "integrity": "sha512-neWEgjp0qKxutbrKac5g23V5LX2c2Clyiz3zFxxybY8VSMfr+MmvwM204zg8YFbe9n2zcTwkpppCL2luwYcMhg==", + "version": "2.10.1", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin/-/eslint-plugin-2.10.1.tgz", + "integrity": "sha512-U+4yzNXElTf9q0kEfnloI9XbOyD4cnEQCxjUI94q0+W++0GAEQvJ/slwEj9lwjDHfGADRSr+Tco/z0XJvmDfCQ==", "dev": true, "license": "MIT", "dependencies": { @@ -3422,9 +3436,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "22.8.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.8.5.tgz", - "integrity": "sha512-5iYk6AMPtsMbkZqCO1UGF9W5L38twq11S2pYWkybGHH2ogPUvXWNlQqJBzuEZWKj/WRH+QTeiv6ySWqJtvIEgA==", + "version": "22.8.6", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.8.6.tgz", + "integrity": "sha512-tosuJYKrIqjQIlVCM4PEGxOmyg3FCPa/fViuJChnGeEIhjA46oy8FMVoF9su1/v8PNs2a8Q0iFNyOx0uOF91nw==", "dev": true, "license": "MIT", "dependencies": { @@ -5706,9 +5720,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.49", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.49.tgz", - "integrity": "sha512-ZXfs1Of8fDb6z7WEYZjXpgIRF6MEu8JdeGA0A40aZq6OQbS+eJpnnV49epZRna2DU/YsEjSQuGtQPPtvt6J65A==", + "version": "1.5.50", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.50.tgz", + "integrity": "sha512-eMVObiUQ2LdgeO1F/ySTXsvqvxb6ZH2zPGaMYsWzRDdOddUa77tdmI0ltg+L16UpbWdhPmuF3wIQYyQq65WfZw==", "dev": true, "license": "ISC" }, @@ -5942,22 +5956,22 @@ } }, "node_modules/eslint": { - "version": "9.13.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.13.0.tgz", - "integrity": "sha512-EYZK6SX6zjFHST/HRytOdA/zE72Cq/bfw45LSyuwrdvcclb/gqV8RRQxywOBEWO2+WDpva6UZa4CcDeJKzUCFA==", + "version": "9.14.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.14.0.tgz", + "integrity": "sha512-c2FHsVBr87lnUtjP4Yhvk4yEhKrQavGafRA/Se1ouse8PfbfC/Qh9Mxa00yWsZRlqeUB9raXip0aiiUZkgnr9g==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", - "@eslint-community/regexpp": "^4.11.0", + "@eslint-community/regexpp": "^4.12.1", "@eslint/config-array": "^0.18.0", "@eslint/core": "^0.7.0", "@eslint/eslintrc": "^3.1.0", - "@eslint/js": "9.13.0", + "@eslint/js": "9.14.0", "@eslint/plugin-kit": "^0.2.0", - "@humanfs/node": "^0.16.5", + "@humanfs/node": "^0.16.6", "@humanwhocodes/module-importer": "^1.0.1", - "@humanwhocodes/retry": "^0.3.1", + "@humanwhocodes/retry": "^0.4.0", "@types/estree": "^1.0.6", "@types/json-schema": "^7.0.15", "ajv": "^6.12.4", @@ -5965,9 +5979,9 @@ "cross-spawn": "^7.0.2", "debug": "^4.3.2", "escape-string-regexp": "^4.0.0", - "eslint-scope": "^8.1.0", - "eslint-visitor-keys": "^4.1.0", - "espree": "^10.2.0", + "eslint-scope": "^8.2.0", + "eslint-visitor-keys": "^4.2.0", + "espree": "^10.3.0", "esquery": "^1.5.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", @@ -12320,9 +12334,9 @@ "license": "Apache-2.0" }, "node_modules/regex": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/regex/-/regex-4.3.3.tgz", - "integrity": "sha512-r/AadFO7owAq1QJVeZ/nq9jNS1vyZt+6t1p/E59B56Rn2GCya+gr1KSyOzNL/er+r+B7phv5jG2xU2Nz1YkmJg==", + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/regex/-/regex-4.4.0.tgz", + "integrity": "sha512-uCUSuobNVeqUupowbdZub6ggI5/JZkYyJdDogddJr60L764oxC2pMZov1fQ3wM9bdyzUILDG+Sqx6NAKAz9rKQ==", "dev": true, "license": "MIT" }, @@ -13933,9 +13947,9 @@ } }, "node_modules/tslib": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.0.tgz", - "integrity": "sha512-jWVzBLplnCmoaTr13V9dYbiQ99wvZRd0vNWaDRg+aVYRcjDF3nDksxFDE/+fkXnKhpnUUkmx5pK/v8mCtLVqZA==", + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", "license": "0BSD" }, "node_modules/tunnel-agent": { @@ -13995,9 +14009,9 @@ } }, "node_modules/typedoc": { - "version": "0.26.10", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.26.10.tgz", - "integrity": "sha512-xLmVKJ8S21t+JeuQLNueebEuTVphx6IrP06CdV7+0WVflUSW3SPmR+h1fnWVdAR/FQePEgsSWCUHXqKKjzuUAw==", + "version": "0.26.11", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.26.11.tgz", + "integrity": "sha512-sFEgRRtrcDl2FxVP58Ze++ZK2UQAEvtvvH8rRlig1Ja3o7dDaMHmaBfvJmdGnNEFaLTpQsN8dpvZaTqJSu/Ugw==", "dev": true, "license": "Apache-2.0", "dependencies": { diff --git a/package.json b/package.json index bdf1a62..aeeaeaf 100644 --- a/package.json +++ b/package.json @@ -73,11 +73,11 @@ "@types/fs-extra": "^11.0.4", "@types/jest": "^29.5.14", "@types/mdast": "^4.0.4", - "@types/node": "^22.8.5", + "@types/node": "^22.8.6", "@types/semver": "^7.5.8", "@types/source-map-support": "^0.5.10", "@vitest/coverage-v8": "^2.1.4", - "eslint": "^9.13.0", + "eslint": "^9.14.0", "eslint-plugin-format": "^0.1.2", "homebridge": "^1.8.5", "homebridge-config-ui-x": "4.62.0", @@ -86,7 +86,7 @@ "npm-check-updates": "^17.1.9", "shx": "^0.3.4", "ts-node": "^10.9.2", - "typedoc": "^0.26.10", + "typedoc": "^0.26.11", "typescript": "^5.6.3", "typescript-axios-wb": "^1.0.3", "vitest": "^2.1.4" diff --git a/src/devices/device.ts b/src/devices/device.ts index 61025f9..4a5f2a7 100644 --- a/src/devices/device.ts +++ b/src/devices/device.ts @@ -46,17 +46,17 @@ export abstract class deviceBase { } async getDeviceLogSettings(accessory: PlatformAccessory, device: devicesConfig): Promise { - this.deviceLogging = this.platform.debugMode ? 'debugMode' : device.logging ?? this.config.logging ?? 'standard' - const logging = this.platform.debugMode ? 'Debug Mode' : device.logging ? 'Device Config' : this.config.logging ? 'Platform Config' : 'Default' + this.deviceLogging = this.platform.debugMode ? 'debugMode' : device.logging ?? this.platform.platformLogging ?? 'standard' + const logging = this.platform.debugMode ? 'Debug Mode' : device.logging ? 'Device Config' : this.platform.platformLogging ? 'Platform Config' : 'Default' accessory.context.deviceLogging = this.deviceLogging await this.debugLog(`Using ${logging} Logging: ${this.deviceLogging}`) } async getDeviceRateSettings(accessory: PlatformAccessory, device: devicesConfig): Promise { // refreshRate - this.deviceRefreshRate = device.refreshRate ?? this.config.options?.refreshRate ?? 3600 + this.deviceRefreshRate = device.refreshRate ?? this.platform.platformRefreshRate ?? 3600 accessory.context.deviceRefreshRate = this.deviceRefreshRate - const refreshRate = device.refreshRate ? 'Device Config' : this.config.options?.refreshRate ? 'Platform Config' : 'Default' + const refreshRate = device.refreshRate ? 'Device Config' : this.platform.platformRefreshRate ? 'Platform Config' : 'Default' await this.debugLog(`Using ${refreshRate} Refresh Rate: ${this.deviceRefreshRate}`) } diff --git a/src/platform.ts b/src/platform.ts index 73151be..13b2a66 100644 --- a/src/platform.ts +++ b/src/platform.ts @@ -49,6 +49,7 @@ export class AirPlatform implements DynamicPlatformPlugin { // Plugin options into our config variables. this.config = { platform: PLATFORM_NAME, + name: config.name, devices: config.devices as devicesConfig[], refreshRate: config.refreshRate as number, logging: config.logging as string,