From 20811cf3df2cfc11dbe8aac1f1059c5caedff29c Mon Sep 17 00:00:00 2001 From: Donavan Becker Date: Wed, 12 Oct 2022 00:58:14 -0500 Subject: [PATCH] v2.0.0 (#474) ## [Version 2.0.0](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v2.0.0) (2022-10-12) ## What's Changed - Moved from v1.0 to v1.1 of [OpenAPI](https://github.com/OpenWonderLabs/SwitchBotAPI) - Publish device(s) as an external accessory. - Added `connectionType` config, this replaces the `BLE` config. - You can now select Both Connections, Only OpenAPI, Only BLE, or Disable. - `Both` will use BLE as the default connection and will use OpenAPI as a backup connection. - `OpenAPI` will only allow connections through the OpenAPI. - `BLE` will only allow connections through Bluetooth (BLE), . - `Disable` will disable all connections. This will also allow you to disable commands and refreshes for a specific device but leave it in HomeKit. - Added Support for Ceiling Light & Ceiling Light Pro - Fixes Smart Lock Issues fixed in v1.1 of OpenAPI. [#462](https://github.com/OpenWonderLabs/homebridge-switchbot/issues/462) = Fixes excesive logging from node-switchbot. [#435](https://github.com/OpenWonderLabs/homebridge-switchbot/issues/435), [#444](https://github.com/OpenWonderLabs/homebridge-switchbot/issues/444), [#446](https://github.com/OpenWonderLabs/homebridge-switchbot/issues/446) - Housekeeping and updated dependencies. **Full Changelog**: https://github.com/OpenWonderLabs/homebridge-switchbot/compare/v1.15.0...v2.0.0 --- .github/.DS_Store | Bin 6148 -> 6148 bytes .github/ISSUE_TEMPLATE/bug-report.yml | 1 + .github/ISSUE_TEMPLATE/feature-request.yml | 1 + .github/ISSUE_TEMPLATE/support-request.yml | 1 + .github/Old Releaser.zip | Bin 0 -> 2092 bytes .github/labeler.yml | 13 - .github/workflows/beta-release.yml | 31 + .github/workflows/build.yml | 18 + .github/workflows/codeql-analysis.yml | 68 +- .github/workflows/{label.yml => labeler.yml} | 12 +- .github/workflows/nodejs-beta.yml | 42 - .github/workflows/nodejs.yml | 47 - .github/workflows/prerelease-beta.js | 34 - .github/workflows/release-drafter.yml | 14 + .github/workflows/release.yml | 24 + .github/workflows/stale.yml | 28 +- .npmignore | 3 +- .prettierrc | 2 +- CHANGELOG.md | 21 +- README.md | 18 +- config.schema.json | 141 +- homebridge-ui/public/index.html | 1 + package-lock.json | 1492 +++++++----------- package.json | 30 +- src/device/bot.ts | 1266 ++++++++------- src/device/ceilinglight.ts | 1208 ++++++++++++++ src/device/colorbulb.ts | 1085 +++++++++---- src/device/contact.ts | 540 ++++--- src/device/curtain.ts | 1035 ++++++------ src/device/humidifier.ts | 985 +++++++----- src/device/lock.ts | 485 ++++-- src/device/meter.ts | 647 +++++--- src/device/meterplus.ts | 586 ++++--- src/device/motion.ts | 484 +++--- src/device/plug.ts | 647 ++++---- src/device/striplight.ts | 1010 +++++++++--- src/irdevice/airconditioner.ts | 543 ++++--- src/irdevice/airpurifier.ts | 276 ++-- src/irdevice/camera.ts | 230 ++- src/irdevice/fan.ts | 303 ++-- src/irdevice/light.ts | 266 ++-- src/irdevice/other.ts | 248 ++- src/irdevice/tv.ts | 331 ++-- src/irdevice/vacuumcleaner.ts | 232 ++- src/irdevice/waterheater.ts | 233 ++- src/platform.ts | 1148 ++++++++------ src/settings.ts | 62 +- 47 files changed, 9958 insertions(+), 5934 deletions(-) create mode 100644 .github/Old Releaser.zip delete mode 100644 .github/labeler.yml create mode 100644 .github/workflows/beta-release.yml create mode 100644 .github/workflows/build.yml rename .github/workflows/{label.yml => labeler.yml} (60%) delete mode 100644 .github/workflows/nodejs-beta.yml delete mode 100644 .github/workflows/nodejs.yml delete mode 100644 .github/workflows/prerelease-beta.js create mode 100644 .github/workflows/release-drafter.yml create mode 100644 .github/workflows/release.yml create mode 100644 src/device/ceilinglight.ts diff --git a/.github/.DS_Store b/.github/.DS_Store index fb176ff3420c25162f70a2fc50e8702044c3a9af..2421372c31c01570cf6b4291c2c463697221be3f 100644 GIT binary patch delta 49 zcmZoMXfc@J&&azmU^g=(@8kj&h0QuF-b|AN*@St@f{XHU^7GOe7#J8g78WvYX6N|J F4*+J?4nF_@ delta 32 ocmZoMXfc@J&&abeU^g=(&*TCYh0QuF-b@=yCopbi=lIJH0HnYP{Qv*} diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index 8bfaf787..e3ca4aaa 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -8,6 +8,7 @@ assignees: - SwitchBot-Wonderlabs - Minsheng - Devin-Wonderlabs + - chenliuyun body: - type: markdown attributes: diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature-request.yml index 2a2fad3e..e90d680b 100644 --- a/.github/ISSUE_TEMPLATE/feature-request.yml +++ b/.github/ISSUE_TEMPLATE/feature-request.yml @@ -8,6 +8,7 @@ assignees: - SwitchBot-Wonderlabs - Minsheng - Devin-Wonderlabs + - chenliuyun body: - type: markdown attributes: diff --git a/.github/ISSUE_TEMPLATE/support-request.yml b/.github/ISSUE_TEMPLATE/support-request.yml index 87325049..f613e3f6 100644 --- a/.github/ISSUE_TEMPLATE/support-request.yml +++ b/.github/ISSUE_TEMPLATE/support-request.yml @@ -8,6 +8,7 @@ assignees: - SwitchBot-Wonderlabs - Minsheng - Devin-Wonderlabs + - chenliuyun body: - type: markdown attributes: diff --git a/.github/Old Releaser.zip b/.github/Old Releaser.zip new file mode 100644 index 0000000000000000000000000000000000000000..70b2ed6f247fdc531dad78200b17edffe4c036f7 GIT binary patch literal 2092 zcmb7_c{JNu8^?b^Y^6als`l7LFhxtPRg_rMkT6vew2IibOvF;Pw54jR)>29=)zVr@ zr5#&GGGizjK^dw#ma)ZBMZKDlnOEPQIqx4c-{;(O?)~FF=ic*tzR%-?;N%hoc=zM% zonjR5Uo~(7fCwN5goOEq`3Cx8!+kYzz7bfsf4B=u5a3CR4a6O+$e2R_h-(uB0Q-3W zAOmUd_^Y`1|zE%bEk+@G0F9>MrcdhtA$ISPmKMnp!%m6o3(_V5P}PuhA^!L}E&ojZDzm4X0i z-j!}~WbZ6J(n(!h(IXosUMir4E!tX2m$@o&TCuZ#a{@mYwy0fu9-Eba0*U>tw=x5k znn-h&z7nVR5p1_Q)xz6_xpCz)!Pr(>wQNsoB`fG*rmv5Br5kr}a7UZihx!?*DM@2i z6UpLdNFnij&3)yCm95fhlA(FuoYY1&dFXVq2vgG?^^^34tZvW-`4`n)@1E-`=mh7E4`cQA^Cu@Sn?_l%z#V;O`p5zeWsA65vO^Wif0sODMA6ba!Xu zGU8(GWYF+bChh4qj}wB27c(>-S-W37cFCQ-z~GQl{so43E&zb+!w?kg1(%p?dG@(f4`D`;{$s7T^}W!Cj0RS5 zJ-vw`zET7;Z6^>m@-#4;DPGK%QTRQXk5qTwK@e2OT=BhONSozA9e8E1Qz9Usnn$oa zsF`Bn1$is*wp%jJA&pnLG9^J=PyQ#Bf`o#4&AO?F5bbTb>hE^7{q!e6@~#8NGf{cI znNjB>Qg$&~lBT&78!7eLC=XGR(#0Xec~DL$!;-F$$KySXQKB6~@+6@|9iEBBo*uS* z=i!n-HYXW^7D_$nQ2P@AIC2&rTU>7_Iqr~&Jc<;7)Ze^W-eAa3GZlUxqbzL0h1G|z z_YGTrenwc}u*Est+4MRn+fbLZykm$s`J=0C^!jQ^v(k4jUkRnEh$R^dZl}Y^uw(Aq z19{e*t>zD2We}1p^o$-^8U#N|Cw06mc%a*IL(s!k&Bok@jGO4Q!kRd8bmiQ*oKFD3 zQL}w$o7tjp9ncoUGe|Z#u69KR4KWR3YQ${($4<2!sLWl5?rKu<^QR$ftmGH4Pe1Kr z#fInqWAzOf0QkRP1^)*`RiHcq#ztH_wA(c?@l{KVVxgkD7@yf(^%@JP5U%mR#qS60 z3T|HRor_tQnSc5G4EP|FYB z$IM?lZoj&H=fmsK!P49-P^K&DcAn~-4hpfnG`_iLd^-8v#HvlzlKS&1i)oAU3%HQ2 zqT2%$_~xhzE+M0-kDlcz^Xaid(s4$unR-JRo)$`#LkaHLQ)T7< zPmIW38bOz6RjnxrhlRliwRaf^0p`348_uZnzkjsk001_EP6!Z(DChr1;Me_-JpvCz zPGs-?{XqOWKf9}bZ47o-JrFrjaQ{XBvd8{C`PUy~d+R{tM4x>h{+0ZnIL!$G=4RjJ O+z&Aj0DySdr#}F_i*t7X literal 0 HcmV?d00001 diff --git a/.github/labeler.yml b/.github/labeler.yml deleted file mode 100644 index d2f5577d..00000000 --- a/.github/labeler.yml +++ /dev/null @@ -1,13 +0,0 @@ -# Add 'branding' to any file changes within 'switchbot' folder -branding: image/* - -# Add 'enhancement' label to any change to index.js file -enhancement: - - src/* - - package.json - - pakcage-lock.json - - config.schema.json - -# Add 'workflow' to any changes within 'workflow' folder or any subfolders -workflow: - - .github/workflows/* diff --git a/.github/workflows/beta-release.yml b/.github/workflows/beta-release.yml new file mode 100644 index 00000000..1f1ebe03 --- /dev/null +++ b/.github/workflows/beta-release.yml @@ -0,0 +1,31 @@ +name: Node-CI Beta + +on: + push: + branches: [beta-*.*.*, beta] + workflow_dispatch: + +jobs: + build_and_test: + uses: OpenWonderLabs/.github/.github/workflows/nodejs-build-and-test.yml@latest + with: + enable_coverage: true + secrets: + token: ${{ secrets.GITHUB_TOKEN }} + lint: + needs: build_and_test + uses: OpenWonderLabs/.github/.github/workflows/eslint.yml@latest + + publish: + needs: lint + + if: ${{ github.repository == 'OpenWonderLabs/homebridge-switchbot' }} + + uses: OpenWonderLabs/.github/.github/workflows/npm-publish.yml@latest + with: + tag: 'beta' + dynamically_adjust_version: true + npm_version_command: 'pre' + pre_id: 'beta' + secrets: + npm_auth_token: ${{ secrets.npm_token }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..45d93f00 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,18 @@ +name: Node Build + +on: + push: + branches: [latest] + pull_request: + workflow_dispatch: + +jobs: + build_and_test: + uses: OpenWonderLabs/.github/.github/workflows/nodejs-build-and-test.yml@latest + with: + enable_coverage: true + secrets: + token: ${{ secrets.GITHUB_TOKEN }} + lint: + needs: build_and_test + uses: OpenWonderLabs/.github/.github/workflows/eslint.yml@latest diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 93afde39..4fd93a25 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -1,71 +1,13 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: 'CodeQL' +name: "CodeQL" on: push: - branches: [beta] + branches: [ latest, beta* ] pull_request: - # The branches below must be a subset of the branches above - branches: [beta] + branches: [ latest, beta* ] schedule: - - cron: '39 20 * * 5' + - cron: '17 9 * * 2' jobs: analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: ['javascript'] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] - # Learn more: - # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: OpenWonderLabs/.github/.github/workflows/codeql-analysis.yml@latest diff --git a/.github/workflows/label.yml b/.github/workflows/labeler.yml similarity index 60% rename from .github/workflows/label.yml rename to .github/workflows/labeler.yml index 38f4b093..caaf78d5 100644 --- a/.github/workflows/label.yml +++ b/.github/workflows/labeler.yml @@ -3,16 +3,14 @@ # # To use this workflow, you will need to set up a .github/labeler.yml # file with configuration. For more information, see: -# https://github.com/actions/labeler/blob/master/README.md +# https://github.com/actions/labeler/blob/main/README.md name: Labeler + on: [pull_request] jobs: label: - runs-on: ubuntu-latest - - steps: - - uses: actions/labeler@v4 - with: - repo-token: '${{ secrets.GITHUB_TOKEN }}' \ No newline at end of file + uses: OpenWonderLabs/.github/.github/workflows/labeler.yml@latest + secrets: + token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/nodejs-beta.yml b/.github/workflows/nodejs-beta.yml deleted file mode 100644 index 4bf8db7c..00000000 --- a/.github/workflows/nodejs-beta.yml +++ /dev/null @@ -1,42 +0,0 @@ -# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created -# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages - -name: Beta - -on: - push: - branches: - - beta - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 14 - - name: npm install, build and test - run: | - npm install - npm run lint - npm run build - env: - CI: true - - publish-npm: - if: github.repository == 'openwonderlabs/homebridge-switchbot' - needs: build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 14 - registry-url: https://registry.npmjs.org/ - - run: npm ci - - run: node .github/workflows/prerelease-beta.js - - run: npm --no-git-tag-version version prerelease --preid=beta - - run: npm publish --tag=beta - env: - NODE_AUTH_TOKEN: ${{secrets.npm_token}} diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml deleted file mode 100644 index c1f97326..00000000 --- a/.github/workflows/nodejs.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Latest - -on: - push: - branches: latest - pull_request: - release: # Run when release is created - types: [created] - -jobs: - build: - strategy: - matrix: - node-version: [14.x, 16.x] - os: [ubuntu-latest] - - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - - name: npm install, build and test - run: | - npm install - npm run lint - npm run build - env: - CI: true - - publish-npm: - # publish only if we are on our own repo, event was 'release' (a tag was created) and the tag starts with "v" (aka version tag) - if: github.repository == 'openwonderlabs/homebridge-switchbot' && github.event_name == 'release' && startsWith(github.ref, 'refs/tags/v') - needs: build # only run if build succeeds - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 14 # use the minimum required version - registry-url: https://registry.npmjs.org/ - - run: npm ci - - run: npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.npm_token }} diff --git a/.github/workflows/prerelease-beta.js b/.github/workflows/prerelease-beta.js deleted file mode 100644 index 67692a32..00000000 --- a/.github/workflows/prerelease-beta.js +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/env node - -const fs = require('fs'); -const semver = require('semver'); -const child_process = require('child_process'); - -function getTagVersionFromNpm(tag) { - try { - return child_process.execSync(`npm info ${package.name} version --tag="${tag}"`).toString('utf8').trim(); - } catch (e) { - return null; - } -} - -// load package.json -const package = JSON.parse(fs.readFileSync('package.json', 'utf8')); - -// work out the correct tag -const currentLatest = getTagVersionFromNpm('latest') || '0.0.0'; -const currentBeta = getTagVersionFromNpm('beta') || '0.0.0'; -const latestNpmTag = semver.gt(currentBeta, currentLatest, { - includePrerelease: true, -}) - ? currentBeta - : currentLatest; -const publishTag = semver.gt(package.version, latestNpmTag, { - includePrerelease: true, -}) - ? package.version - : latestNpmTag; - -// save the package.json -package.version = publishTag; -fs.writeFileSync('package.json', JSON.stringify(package, null, 4)); diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 00000000..87e9ab56 --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,14 @@ +name: Release Drafter + +on: + push: + branches: [latest] + pull_request: # required for autolabeler + types: [opened, reopened, synchronize] + workflow_dispatch: + +jobs: + stale: + uses: OpenWonderLabs/.github/.github/workflows/release-drafter.yml@latest + secrets: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..e92e3808 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,24 @@ +name: Node Release + +on: + push: + tags: + - 'v*.*.*' + workflow_dispatch: + +jobs: + build_and_test: + uses: OpenWonderLabs/.github/.github/workflows/nodejs-build-and-test.yml@latest + with: + enable_coverage: true + secrets: + token: ${{ secrets.GITHUB_TOKEN }} + + publish: + needs: build_and_test + + if: ${{ github.repository == 'OpenWonderLabs/homebridge-switchbot' }} + + uses: OpenWonderLabs/.github/.github/workflows/npm-publish.yml@latest + secrets: + npm_auth_token: ${{ secrets.npm_token }} diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 9e347252..c3b7181e 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -1,28 +1,12 @@ -name: Stale +name: Stale workflow on: - issues: - types: [reopened] + workflow_dispatch: schedule: - - cron: '*/60 * * * *' + - cron: '45 11 * * *' jobs: stale: - runs-on: ubuntu-latest - env: - ACTIONS_STEP_DEBUG: true - steps: - - uses: actions/stale@v5 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - stale-issue-message: 'This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.' - stale-pr-message: 'This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.' - stale-issue-label: 'stale' - stale-pr-label: 'stale' - days-before-stale: 15 - days-before-close: 2 - exempt-issue-labels: 'pinned' - exempt-pr-labels: 'awaiting-approval,work-in-progress' - remove-stale-when-updated: true - close-issue-message: 'This issue has been automatically closed because it has not had recent activity. Thank you for your contributions.' - close-pr-message: 'This pull request has been automatically closed because it has not had recent activity. Thank you for your contributions.' + uses: OpenWonderLabs/.github/.github/workflows/stale.yml@latest + secrets: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.npmignore b/.npmignore index 08622d1e..8eafe75d 100644 --- a/.npmignore +++ b/.npmignore @@ -1,3 +1,4 @@ node_modules .DS_Store -src/.DS_Store \ No newline at end of file +src/.DS_Store +examples \ No newline at end of file diff --git a/.prettierrc b/.prettierrc index 39f15e5a..d06c8e13 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,6 +1,6 @@ { "semi": true, - "singleQuote": true, + "singleQuote": false, "bracketSameLine": true, "printWidth": 150, "tabWidth": 2, diff --git a/CHANGELOG.md b/CHANGELOG.md index d3003ebf..7389eef4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,25 @@ All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/) +## [Version 2.0.0](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v2.0.0) (2022-10-12) + +## What's Changed + +- Moved from v1.0 to v1.1 of [OpenAPI](https://github.com/OpenWonderLabs/SwitchBotAPI) +- Publish device(s) as an external accessory. +- Added `connectionType` config, this replaces the `BLE` config. + - You can now select Both Connections, Only OpenAPI, Only BLE, or Disable. + - `Both` will use BLE as the default connection and will use OpenAPI as a backup connection. + - `OpenAPI` will only allow connections through the OpenAPI. + - `BLE` will only allow connections through Bluetooth (BLE), . + - `Disable` will disable all connections. This will also allow you to disable commands and refreshes for a specific device but leave it in HomeKit. +- Added Support for Ceiling Light & Ceiling Light Pro +- Fixes Smart Lock Issues fixed in v1.1 of OpenAPI. [#462](https://github.com/OpenWonderLabs/homebridge-switchbot/issues/462) += Fixes excesive logging from node-switchbot. [#435](https://github.com/OpenWonderLabs/homebridge-switchbot/issues/435), [#444](https://github.com/OpenWonderLabs/homebridge-switchbot/issues/444), [#446](https://github.com/OpenWonderLabs/homebridge-switchbot/issues/446) +- Housekeeping and updated dependencies. + +**Full Changelog**: https://github.com/OpenWonderLabs/homebridge-switchbot/compare/v1.15.0...v2.0.0 + ## [Version 1.15.0](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v1.15.0) (2022-08-27) ## What's Changed @@ -75,7 +94,7 @@ All notable changes to this project will be documented in this file. This projec ## What's Changed -- Fix for Curtain v3.3 and above, from v1.2.0 node-swtichbot update. +- Fix for Curtain v3.3 and above, from v1.2.0 node-switchbot update. - Housekeeping and updated dependencies. **Full Changelog**: https://github.com/OpenWonderLabs/homebridge-switchbot/compare/v1.12.5...v1.12.6 diff --git a/README.md b/README.md index 358915c3..67f0d1fc 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,7 @@ [![npm downloads](https://badgen.net/npm/dt/@switchbot/homebridge-switchbot)](https://www.npmjs.com/package/@switchbot/homebridge-switchbot) [![discord-switchbot](https://badgen.net/discord/online-members/5wYTbwP4ha?icon=discord&label=discord)](https://discord.gg/5wYTbwP4ha) -

The Homebridge SwitchBot OpenAPI -plugin allows you to access your SwitchBot Device(s) from HomeKit with +

The Homebridge SwitchBot plugin allows you to access your SwitchBot Device(s) from HomeKit with Homebridge.

@@ -27,13 +26,20 @@ plugin allows you to access your SwitchBot Device(s) from HomeKit with - ### If using OpenAPI Connection 1. Download SwitchBot App on App Store or Google Play Store 2. Register a SwitchBot account and log in into your account - 3. Generate an Open Token within the App + 3. Generate an Token within the App - Click Bottom Profile Tab - Click Preference - Click App version 10 Times, this will enable Developer Options - Click Developer Options - - Click Copy to Clipboard - 4. Input your `openToken` into the config paramter + - Click Copy `token` to Clipboard + 4. Input your `token` into the config parameter + 5. Generate an Secret within the App + - Click Bottom Profile Tab + - Click Preference + - Click App version 10 Times, this will enable Developer Options + - Click Developer Options + - Click Copy `secret` to Clipboard + 6. Input your `secret` into the config parameter - ### If using BLE Connection 1. Download SwitchBot App on App Store or Google Play Store 2. Register a SwitchBot account and log in into your account @@ -90,6 +96,8 @@ plugin allows you to access your SwitchBot Device(s) from HomeKit with - Must supply `deviceId` & `deviceName` to Device Config - Check `Enable Bluetooth Low Energy (BLE) Connection` on Device Config - [SwitchBot Bulb](https://www.switch-bot.com/products/switchbot-color-bulb) +- [SwitchBot Ceiling Light](https://www.switchbot.jp/collections/all/products/switchbot-ceiling-light) +- [SwitchBot Ceiling Light Pro](https://www.switchbot.jp/collections/all/products/switchbot-ceiling-light) - [SwitchBot Light Strip](https://www.switch-bot.com/products/switchbot-light-strip) - Supports OpenAPI Connection Only - If using OpenAPI: diff --git a/config.schema.json b/config.schema.json index 789521c9..c1ada0ee 100644 --- a/config.schema.json +++ b/config.schema.json @@ -3,7 +3,7 @@ "pluginType": "platform", "singular": true, "customUi": true, - "headerDisplay": "

\n\nThe **SwitchBot** plugin allows you to control SwitchBot Devices. \n\nTo get started link your SwtichBot account.\nTo get started link your SwtichBot account.\n\n1. Download SwitchBot App on App Store or Google Play Store.\n\n2. Register a SwitchBot account and log in into your account.\n\n3. Generate an Open Token within the App.\n\n4. Input your `Open Token` into the paramter below.", + "headerDisplay": "

\n\nThe **SwitchBot** plugin allows you to control SwitchBot Devices. \n\nTo get started link your SwitchBot account.\n\n1. Download SwitchBot App on App Store or Google Play Store.\n\n2. Register a SwitchBot account and log in into your account.\n\n3. Generate an Open Token within the App.\n\n4. Input your `Open Token` into the paramter below.", "footerDisplay": "Please raise any issues on our [project page](https://github.com/OpenWonderLabs/homebridge-switchbot/issues).\n\nIf you would like to have other SwitchBot Devices added to this plugin fill out [Feature Request Form](https://github.com/OpenWonderLabs/homebridge-switchbot/issues/new?assignees=&labels=&template=feature_request.md).\n\n[SwitchBot Website](https://www.switch-bot.com)", "schema": { "type": "object", @@ -16,20 +16,27 @@ "credentials": { "type": "object", "properties": { - "openToken": { + "token": { "title": "Token", "type": "string", "x-schema-form": { "type": "password" } }, + "secret": { + "title": "Secret", + "type": "string", + "x-schema-form": { + "type": "password" + } + }, "notice": { "title": "Notice", "type": "string", - "default": "Keep your token a secret!" + "default": "Keep your Token & Secret a secret!" } }, - "required": ["openToken", "notice"] + "required": ["token", "secret", "notice"] }, "options": { "type": "object", @@ -56,18 +63,11 @@ "hide_device": { "title": "Hide Device", "type": "boolean", - "description": "If true then devices that are reported as offline will be shown as off in HomeKit.", + "description": "If true, device will be removed or hidden from HomeKit.", "condition": { "functionBody": "return (model.options && model.options.devices && model.options.devices[arrayIndices].deviceId);" } }, - "offline": { - "title": "Offline as Off", - "type": "boolean", - "condition": { - "functionBody": "return (model.options && model.options.devices && model.options.devices[arrayIndices].deviceId && !model.options.devices[arrayIndices].hide_device);" - } - }, "configDeviceType": { "title": "Device Type", "type": "string", @@ -137,11 +137,30 @@ "functionBody": "return (model.options && model.options.devices && model.options.devices[arrayIndices].deviceId && !model.options.devices[arrayIndices].hide_device);" } }, - "ble": { - "title": "Enable Bluetooth Low Energy (BLE) Connection", - "type": "boolean", + "connectionType": { + "title": "Connection Type", + "type": "string", + "oneOf": [ + { + "title": "BLE/OpenAPI", + "enum": ["BLE/OpenAPI"] + }, + { + "title": "OpenAPI", + "enum": ["OpenAPI"] + }, + { + "title": "BLE", + "enum": ["BLE"] + }, + { + "title": "Disable", + "enum": ["Disabled"] + } + ], + "description": "Bluetooth (BLE) API is only available for the following Device Types: Humidifier, Meter, MeterPlus, Curtain, Bot, Motion Sensor, Contact Sensor, Plug Mini (US), Plug Mini (JP), & Color Bulb", "condition": { - "functionBody": "return (model.options && model.options.devices && model.options.devices[arrayIndices].deviceId && !model.options.devices[arrayIndices].hide_device && (model.options.devices[arrayIndices].configDeviceType === 'Humidifier' || model.options.devices[arrayIndices].configDeviceType === 'Meter' || model.options.devices[arrayIndices].configDeviceType === 'MeterPlus' || model.options.devices[arrayIndices].configDeviceType === 'Curtain' || model.options.devices[arrayIndices].configDeviceType === 'Bot' || model.options.devices[arrayIndices].configDeviceType === 'Motion Sensor' || model.options.devices[arrayIndices].configDeviceType === 'Contact Sensor' || model.options.devices[arrayIndices].configDeviceType === 'Plug Mini (US)' || model.options.devices[arrayIndices].configDeviceType === 'Plug Mini (JP)'));" + "functionBody": "return (model.options && model.options.devices && model.options.devices[arrayIndices].deviceId && !model.options.devices[arrayIndices].hide_device);" } }, "customBLEaddress": { @@ -149,7 +168,7 @@ "type": "string", "placeholder": "81F3UT59513F", "condition": { - "functionBody": "return (model.options && model.options.devices && model.options.devices[arrayIndices].deviceId && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].ble);" + "functionBody": "return (model.options && model.options.devices && model.options.devices[arrayIndices].deviceId && !model.options.devices[arrayIndices].hide_device && (model.options.devices[arrayIndices].connectionType === 'BLE' || model.options.devices[arrayIndices].connectionType === 'BLE/OpenAPI'));" } }, "scanDuration": { @@ -157,7 +176,7 @@ "type": "number", "placeholder": 1, "condition": { - "functionBody": "return (model.options && model.options.devices && model.options.devices[arrayIndices].deviceId && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].ble);" + "functionBody": "return (model.options && model.options.devices && model.options.devices[arrayIndices].deviceId && !model.options.devices[arrayIndices].hide_device && (model.options.devices[arrayIndices].connectionType === 'BLE' || model.options.devices[arrayIndices].connectionType === 'BLE/OpenAPI'));" } }, "bot": { @@ -498,6 +517,35 @@ } } }, + "mqttURL": { + "title": "MQTT URL", + "type": "string", + "placeholder": "192.168.7.1", + "condition": { + "functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].deviceId && (model.options.devices[arrayIndices].configDeviceType === 'Curtain' || model.options.devices[arrayIndices].configDeviceType === 'Meter' || model.options.devices[arrayIndices].configDeviceType === 'MeterPlus' || model.options.devices[arrayIndices].configDeviceType === 'Meter Plus (JP)'));" + } + }, + "mqttOptions": { + "title": "MQTT Options", + "type": "string", + "condition": { + "functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].deviceId && model.options.devices[arrayIndices].mqttURL && (model.options.devices[arrayIndices].configDeviceType === 'Curtain' || model.options.devices[arrayIndices].configDeviceType === 'Meter' || model.options.devices[arrayIndices].configDeviceType === 'MeterPlus' || model.options.devices[arrayIndices].configDeviceType === 'Meter Plus (JP)'));" + } + }, + "mqttPubOptions": { + "title": "MQTT Pub Options", + "type": "string", + "condition": { + "functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].deviceId && model.options.devices[arrayIndices].mqttURL && (model.options.devices[arrayIndices].configDeviceType === 'Curtain' || model.options.devices[arrayIndices].configDeviceType === 'Meter' || model.options.devices[arrayIndices].configDeviceType === 'MeterPlus' || model.options.devices[arrayIndices].configDeviceType === 'Meter Plus (JP)'));" + } + }, + "history": { + "title": "EVE History", + "type": "boolean", + "condition": { + "functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].deviceId && (model.options.devices[arrayIndices].configDeviceType === 'Curtain' || model.options.devices[arrayIndices].configDeviceType === 'Meter' || model.options.devices[arrayIndices].configDeviceType === 'MeterPlus' || model.options.devices[arrayIndices].configDeviceType === 'Meter Plus (JP)'));" + } + }, "firmware": { "title": "Firmware Override", "type": "string", @@ -516,6 +564,13 @@ "functionBody": "return (model.options && model.options.devices && model.options.devices[arrayIndices].deviceId && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType);" } }, + "external": { + "title": "External Accessory", + "type": "boolean", + "condition": { + "functionBody": "return (model.options && model.options.devices && model.options.devices[arrayIndices].deviceId && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType);" + } + }, "logging": { "title": "Device Logging Override Setting", "type": "string", @@ -538,7 +593,7 @@ } } }, - "required": ["deviceId", "configDeviceType", "configDeviceName", "logging"] + "required": ["deviceId", "configDeviceType", "configDeviceName", "connectionType", "logging"] }, "uniqueItems": true }, @@ -564,6 +619,7 @@ "hide_device": { "title": "Hide Device", "type": "boolean", + "description": "If true, device will be removed or hidden from HomeKit.", "condition": { "functionBody": "return (model.options && model.options.irdevices && model.options.irdevices[arrayIndices].deviceId);" } @@ -685,6 +741,24 @@ "functionBody": "return (model.options && model.options.irdevices && model.options.irdevices[arrayIndices].deviceId && !model.options.irdevices[arrayIndices].hide_device);" } }, + "connectionType": { + "title": "Connection Type", + "type": "string", + "oneOf": [ + { + "title": "OpenAPI", + "enum": ["OpenAPI"] + }, + { + "title": "Disable", + "enum": ["Disabled"] + } + ], + "description": "Enables OpenAPI, if disabled will leave device in HomeKit and commands will not be sent to OpenAPI.", + "condition": { + "functionBody": "return (model.options && model.options.devices && model.options.devices[arrayIndices].deviceId && !model.options.devices[arrayIndices].hide_device);" + } + }, "irair": { "type": "object", "properties": { @@ -793,6 +867,21 @@ } } }, + "firmware": { + "title": "Firmware Override", + "type": "string", + "placeholder": "1.2.8", + "condition": { + "functionBody": "return (model.options && model.options.irdevices && model.options.irdevices[arrayIndices].deviceId && !model.options.irdevices[arrayIndices].hide_device && model.options.irdevices[arrayIndices].configRemoteType);" + } + }, + "external": { + "title": "External Accessory", + "type": "boolean", + "condition": { + "functionBody": "return (model.options && model.options.irdevices && model.options.irdevices[arrayIndices].deviceId && !model.options.irdevices[arrayIndices].hide_device && model.options.irdevices[arrayIndices].configRemoteType);" + } + }, "logging": { "title": "Device Logging Override Setting", "type": "string", @@ -815,7 +904,7 @@ } } }, - "required": ["deviceId", "configRemoteType", "logging"] + "required": ["deviceId", "configRemoteType", "connectionType", "logging"] }, "uniqueItems": true }, @@ -861,7 +950,7 @@ "title": "SwitchBot Account Info", "expandable": true, "expanded": false, - "items": ["credentials.openToken"] + "items": ["credentials.token", "credentials.secret"] }, { "type": "fieldset", @@ -882,8 +971,7 @@ "options.devices[].deviceId", "options.devices[].hide_device", "options.devices[].configDeviceType", - "options.devices[].offline", - "options.devices[].ble", + "options.devices[].connectionType", "options.devices[].scanDuration", "options.devices[].bot.mode", "options.devices[].bot.deviceType", @@ -914,8 +1002,13 @@ "options.devices[].colorbulb.set_minStep", "options.devices[].colorbulb.adaptiveLightingShift", "options.devices[].lock.hide_contactsensor", + "options.devices[].mqttURL", + "options.devices[].mqttOptions", + "options.devices[].mqttPubOptions", + "options.devices[].history", "options.devices[].firmware", "options.devices[].refreshRate", + "options.devices[].external", "options.devices[].logging" ] } @@ -951,6 +1044,8 @@ "options.irdevices[].other.deviceType", "options.irdevices[].other.commandOn", "options.irdevices[].other.commandOff", + "options.irdevices[].firmware", + "options.irdevices[].external", "options.irdevices[].logging" ] } diff --git a/homebridge-ui/public/index.html b/homebridge-ui/public/index.html index 2dfa15c8..f4aac982 100644 --- a/homebridge-ui/public/index.html +++ b/homebridge-ui/public/index.html @@ -72,6 +72,7 @@ +

External Accessories Will Not Display Here.