From 642b2aa4653fca70be8e06d5ec1dead0a292d381 Mon Sep 17 00:00:00 2001 From: Donavan Becker Date: Wed, 24 Nov 2021 21:32:04 -0600 Subject: [PATCH] v1.2.1 (#102) ## [Version 1.2.1](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v1.2.0) (2021-11-24) ## What's Changed * Fixed Bug: Curtains alternate between open/close state. [#85](https://github.com/OpenWonderLabs/homebridge-switchbot/issues/85) * Fixed Bug: Meter not working with BLE. [#110](https://github.com/OpenWonderLabs/homebridge-switchbot/issues/110) * Housekeeping and updated dependencies. **Full Changelog**: https://github.com/OpenWonderLabs/homebridge-switchbot/compare/v1.2.0...v1.2.1 Fixed #110 Fixed #85 --- CHANGELOG.md | 9 + config.schema.json | 77 ++--- package-lock.json | 482 ++++++------------------------- package.json | 10 +- src/devices/bots.ts | 67 +++-- src/devices/colorbulb.ts | 7 +- src/devices/contact.ts | 12 +- src/devices/curtains.ts | 38 ++- src/devices/humidifiers.ts | 17 +- src/devices/indoorcam.ts | 6 +- src/devices/meters.ts | 32 +- src/devices/motion.ts | 12 +- src/devices/plugs.ts | 7 +- src/irdevices/airconditioners.ts | 6 +- src/irdevices/airpurifiers.ts | 6 +- src/irdevices/cameras.ts | 6 +- src/irdevices/fans.ts | 6 +- src/irdevices/lights.ts | 6 +- src/irdevices/others.ts | 6 +- src/irdevices/tvs.ts | 2 +- src/irdevices/vacuumcleaners.ts | 2 +- src/irdevices/waterheaters.ts | 6 +- src/platform.ts | 70 +++-- 23 files changed, 301 insertions(+), 591 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac204cd0..7d6f5103 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/) +## [Version 1.2.1](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v1.2.0) (2021-11-24) + +## What's Changed +* Fixed Bug: Curtains alternate between open/close state. [#85](https://github.com/OpenWonderLabs/homebridge-switchbot/issues/85) +* Fixed Bug: Meter not working with BLE. [#110](https://github.com/OpenWonderLabs/homebridge-switchbot/issues/110) +* Housekeeping and updated dependencies. + +**Full Changelog**: https://github.com/OpenWonderLabs/homebridge-switchbot/compare/v1.2.0...v1.2.1 + ## [Version 1.2.0](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v1.2.0) (2021-11-19) ## What's Changed diff --git a/config.schema.json b/config.schema.json index 63649761..8ed91ae0 100644 --- a/config.schema.json +++ b/config.schema.json @@ -50,16 +50,16 @@ "configDeviceName": { "title": "Device Name", "type": "string", - "placeholder": "Bot", + "placeholder": "SwitchBot", "condition": { - "functionBody": "return (model.options && model.options.devices && model.options.devices[arrayIndices].deviceId && model.options.devices[arrayIndices].ble);" + "functionBody": "return (model.options && model.options.devices && model.options.devices[arrayIndices].deviceId && model.options.devices[arrayIndices].ble && !model.options.devices[arrayIndices].hide_device);" } }, "hide_device": { "title": "Hide Device", "type": "boolean", "condition": { - "functionBody": "return (model.options && model.options.devices && model.options.devices[arrayIndices].deviceId && !model.options.devices[arrayIndices].ble);" + "functionBody": "return (model.options && model.options.devices && model.options.devices[arrayIndices].deviceId);" } }, "configDeviceType": { @@ -243,34 +243,31 @@ "curtain": { "type": "object", "properties": { - "disable_group": { - "title": "Disable Grouping", - "type": "boolean", - "condition": { - "functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType === 'Curtain' && model.options.devices[arrayIndices].deviceId);" - } - }, - "hide_lightsensor": { - "title": "Hide Curtain's Light Sensor", - "type": "boolean", + "set_minStep": { + "title": "Set Minimum Step", + "type": "number", + "placeholder": "1", + "description": "Sets the minimum steps that curtain allows. So if set to 20, it would allow you to set the curtain state to 0, 20, 40, 60, 80, and 100", "condition": { "functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType === 'Curtain' && model.options.devices[arrayIndices].deviceId);" } }, - "set_minlux": { - "title": "Set Min Lux", + "set_min": { + "title": "Set Minimum Open State", "type": "number", - "placeholder": "1", + "placeholder": "0", + "description": "Sets the minimum percentage before needed to set Curtain to Open", "condition": { - "functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType === 'Curtain' && model.options.devices[arrayIndices].deviceId && !model.options.devices[arrayIndices].curtain.hide_lightsensor);" + "functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType === 'Curtain' && model.options.devices[arrayIndices].deviceId);" } }, - "set_maxlux": { - "title": "Set Max Lux", + "set_max": { + "title": "Set Maximum Close State", "type": "number", - "placeholder": "6001", + "placeholder": "100", + "description": "Sets the maximum percentage before needing to set Curtain to Closed", "condition": { - "functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType === 'Curtain' && model.options.devices[arrayIndices].deviceId && !model.options.devices[arrayIndices].curtain.hide_lightsensor);" + "functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType === 'Curtain' && model.options.devices[arrayIndices].deviceId);" } }, "refreshRate": { @@ -283,28 +280,34 @@ "functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType === 'Curtain' && model.options.devices[arrayIndices].deviceId);" } }, - "set_minStep": { - "title": "Set Min Step", - "type": "number", - "placeholder": "1", + "disable_group": { + "title": "Disable Grouping", + "type": "boolean", "condition": { "functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType === 'Curtain' && model.options.devices[arrayIndices].deviceId);" } }, - "set_min": { - "title": "Set Min", - "type": "number", - "placeholder": "0", + "hide_lightsensor": { + "title": "Hide Curtain's Light Sensor", + "type": "boolean", "condition": { "functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType === 'Curtain' && model.options.devices[arrayIndices].deviceId);" } }, - "set_max": { - "title": "Set Max", + "set_minlux": { + "title": "Set Min Lux", "type": "number", - "placeholder": "100", + "placeholder": "1", "condition": { - "functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType === 'Curtain' && model.options.devices[arrayIndices].deviceId);" + "functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType === 'Curtain' && model.options.devices[arrayIndices].deviceId && !model.options.devices[arrayIndices].curtain.hide_lightsensor);" + } + }, + "set_maxlux": { + "title": "Set Max Lux", + "type": "number", + "placeholder": "6001", + "condition": { + "functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType === 'Curtain' && model.options.devices[arrayIndices].deviceId && !model.options.devices[arrayIndices].curtain.hide_lightsensor);" } } } @@ -713,14 +716,14 @@ "options.devices[].meter.unit", "options.devices[].humidifier.set_minStep", "options.devices[].humidifier.hide_temperature", + "options.devices[].curtain.set_minStep", + "options.devices[].curtain.set_min", + "options.devices[].curtain.set_max", + "options.devices[].curtain.refreshRate", "options.devices[].curtain.disable_group", "options.devices[].curtain.hide_lightsensor", "options.devices[].curtain.set_minlux", "options.devices[].curtain.set_maxlux", - "options.devices[].curtain.refreshRate", - "options.devices[].curtain.set_minStep", - "options.devices[].curtain.set_min", - "options.devices[].curtain.set_max", "options.devices[].contact.hide_lightsensor", "options.devices[].contact.hide_motionsensor", "options.devices[].colorbulb.set_minStep" diff --git a/package-lock.json b/package-lock.json index 21d9e9a0..bd96fda4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@switchbot/homebridge-switchbot", - "version": "1.2.0", + "version": "1.2.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@switchbot/homebridge-switchbot", - "version": "1.2.0", + "version": "1.2.1", "funding": [ { "type": "Paypal", @@ -21,11 +21,11 @@ "rxjs": "^7.4.0" }, "devDependencies": { - "@types/node": "^16.11.9", + "@types/node": "^16.11.10", "@typescript-eslint/eslint-plugin": "^5.4.0", "@typescript-eslint/parser": "^5.4.0", - "eslint": "^8.2.0", - "homebridge": "^1.3.6", + "eslint": "^8.3.0", + "homebridge": "^1.3.8", "nodemon": "^2.0.15", "npm-check-updates": "^12.0.2", "rimraf": "^3.0.2", @@ -34,7 +34,7 @@ "typescript-axios-wb": "^1.0.3" }, "engines": { - "homebridge": "^1.3.6", + "homebridge": "^1.3.8", "node": "^14.18.1 || ^16.13.0" } }, @@ -405,9 +405,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "16.11.9", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.9.tgz", - "integrity": "sha512-MKmdASMf3LtPzwLyRrFjtFFZ48cMf8jmX5VRYrDQiJa8Ybu5VAmkqBWqKU8fdCwD8ysw4mQ9nrEHvzg6gunR7A==", + "version": "16.11.10", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.10.tgz", + "integrity": "sha512-3aRnHa1KlOEEhJ6+CvyHKK5vE9BcLGjtUpwvqYLRvYNQKMfabu3BwfJaA/SLW8dxe28LsNDjtHwePTuzn3gmOA==", "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { @@ -717,13 +717,13 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz", "integrity": "sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ==", - "optional": true + "devOptional": true }, "node_modules/are-we-there-yet": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-2.0.0.tgz", "integrity": "sha512-Ci/qENmwHnsYo9xKIcUJN5LeDKdJ6R1Z1j9V/J5wyq8nh/mYPEpIKJbBZXtZjG04HiK7zV/p6Vs9952MrMeUIw==", - "optional": true, + "devOptional": true, "dependencies": { "delegates": "^1.0.0", "readable-stream": "^3.6.0" @@ -1072,16 +1072,13 @@ } }, "node_modules/cli-table": { - "version": "0.3.8", - "resolved": "https://registry.npmjs.org/cli-table/-/cli-table-0.3.8.tgz", - "integrity": "sha512-5IO15fJRzgM+hHZjvQlqD6UPRuVGWR4Ny5ZzaM5VJxJEQqSIEVyVh9dMAUN6CBAVfMc4/6CFEzbhnRftLRCyug==", + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/cli-table/-/cli-table-0.3.9.tgz", + "integrity": "sha512-7eA6hFtAZwVx3dWAGoaBqTrzWko5jRUFKpHT64ZHkJpaA3y5wf5NlLjguqTRmqycatJZiwftODYYyGNLbQ7MuA==", "dev": true, "dependencies": { "colors": "1.0.3", "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">= 12" } }, "node_modules/clone-response": { @@ -1093,15 +1090,6 @@ "mimic-response": "^1.0.0" } }, - "node_modules/code-point-at": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -1124,7 +1112,7 @@ "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==", - "optional": true, + "devOptional": true, "bin": { "color-support": "bin.js" } @@ -1176,12 +1164,6 @@ "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", "devOptional": true }, - "node_modules/core-util-is": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", - "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", - "dev": true - }, "node_modules/create-require": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", @@ -1532,9 +1514,9 @@ } }, "node_modules/eslint": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.2.0.tgz", - "integrity": "sha512-erw7XmM+CLxTOickrimJ1SiF55jiNlVSp2qqm0NuBWPtHYQCegD5ZMaW0c3i5ytPqL+SSLaCxdvQXFPLJn+ABw==", + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.3.0.tgz", + "integrity": "sha512-aIay56Ph6RxOTC7xyr59Kt3ewX185SaGnAr8eWukoPLeriCrvGjvAubxuvaXOfsxhtwV5g0uBOsyhAom4qJdww==", "dev": true, "dependencies": { "@eslint/eslintrc": "^1.0.4", @@ -1546,10 +1528,10 @@ "doctrine": "^3.0.0", "enquirer": "^2.3.5", "escape-string-regexp": "^4.0.0", - "eslint-scope": "^6.0.0", + "eslint-scope": "^7.1.0", "eslint-utils": "^3.0.0", - "eslint-visitor-keys": "^3.0.0", - "espree": "^9.0.0", + "eslint-visitor-keys": "^3.1.0", + "espree": "^9.1.0", "esquery": "^1.4.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", @@ -1636,9 +1618,9 @@ } }, "node_modules/eslint/node_modules/eslint-scope": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-6.0.0.tgz", - "integrity": "sha512-uRDL9MWmQCkaFus8RF5K9/L/2fn+80yoW3jkD53l4shjCh26fCtvJGasxjUqP5OT87SYTxCVA3BwTUzuELx9kA==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.0.tgz", + "integrity": "sha512-aWwkhnS0qAXqNOgKOK0dJ2nvzEbhEvpy8OlJ9kZ0FeZnA6zpjv1/Vei+puGFFX7zkPCkHHXb7IDX3A+7yPrRWg==", "dev": true, "dependencies": { "esrecurse": "^4.3.0", @@ -1667,14 +1649,14 @@ } }, "node_modules/espree": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.0.0.tgz", - "integrity": "sha512-r5EQJcYZ2oaGbeR0jR0fFVijGOcwai07/690YRXLINuhmVeRY4UKSAsQPe/0BNuDgwP7Ophoc1PRsr2E3tkbdQ==", + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.1.0.tgz", + "integrity": "sha512-ZgYLvCS1wxOczBYGcQT9DDWgicXwJ4dbocr9uYN+/eresBAUuBu+O4WzB21ufQ/JqQT8gyp7hJ3z8SHii32mTQ==", "dev": true, "dependencies": { - "acorn": "^8.5.0", + "acorn": "^8.6.0", "acorn-jsx": "^5.3.1", - "eslint-visitor-keys": "^3.0.0" + "eslint-visitor-keys": "^3.1.0" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -1980,7 +1962,7 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/gauge/-/gauge-4.0.0.tgz", "integrity": "sha512-F8sU45yQpjQjxKkm1UOAhf0U/O0aFt//Fl7hsrNVto+patMHjs7dPI9mFOGUKbhrgKm0S3EjW3scMFuQmWSROw==", - "optional": true, + "devOptional": true, "dependencies": { "ansi-regex": "^5.0.1", "aproba": "^1.0.3 || ^2.0.0", @@ -2263,9 +2245,9 @@ } }, "node_modules/homebridge": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/homebridge/-/homebridge-1.3.6.tgz", - "integrity": "sha512-5kax/4ex1qYwF6lfIrNrH4c117zwcCXqqsSQ8qWg+dUYmTXapmtp8Iknsl3vzm5nHq9t/U9HUb5yHCSShmyXxQ==", + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/homebridge/-/homebridge-1.3.8.tgz", + "integrity": "sha512-LGX5qbLAWRfNpifaO2EN5+h78d70BctXryDN9QXXlPOQQziGMrvo9rBLQmihTNtJQut+P2JnUg+cBgcR1HYmIQ==", "dev": true, "dependencies": { "chalk": "^4.1.2", @@ -3364,9 +3346,9 @@ } }, "node_modules/node-gyp": { - "version": "8.4.0", - "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-8.4.0.tgz", - "integrity": "sha512-Bi/oCm5bH6F+FmzfUxJpPaxMEyIhszULGR3TprmTeku8/dMFcdTcypk120NeZqEt54r1BrgEKtm2jJiuIKE28Q==", + "version": "8.4.1", + "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-8.4.1.tgz", + "integrity": "sha512-olTJRgUtAb/hOXG0E93wZDs5YiJlgbXxTwQAFHyNlRsXQnYzUaF2aGgujZbw+hR8aF4ZG/rST57bWMWD16jr9w==", "dev": true, "dependencies": { "env-paths": "^2.2.0", @@ -3374,7 +3356,7 @@ "graceful-fs": "^4.2.6", "make-fetch-happen": "^9.1.0", "nopt": "^5.0.0", - "npmlog": "^4.1.2", + "npmlog": "^6.0.0", "rimraf": "^3.0.2", "semver": "^7.3.5", "tar": "^6.1.2", @@ -3398,133 +3380,6 @@ "node-gyp-build-test": "build-test.js" } }, - "node_modules/node-gyp/node_modules/ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/node-gyp/node_modules/aproba": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", - "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==", - "dev": true - }, - "node_modules/node-gyp/node_modules/are-we-there-yet": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.7.tgz", - "integrity": "sha512-nxwy40TuMiUGqMyRHgCSWZ9FM4VAoRP4xUYSTv5ImRog+h9yISPbVH7H8fASCIzYn9wlEv4zvFL7uKDMCFQm3g==", - "dev": true, - "dependencies": { - "delegates": "^1.0.0", - "readable-stream": "^2.0.6" - } - }, - "node_modules/node-gyp/node_modules/gauge": { - "version": "2.7.4", - "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", - "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", - "dev": true, - "dependencies": { - "aproba": "^1.0.3", - "console-control-strings": "^1.0.0", - "has-unicode": "^2.0.0", - "object-assign": "^4.1.0", - "signal-exit": "^3.0.0", - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", - "wide-align": "^1.1.0" - } - }, - "node_modules/node-gyp/node_modules/is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "dev": true, - "dependencies": { - "number-is-nan": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/node-gyp/node_modules/isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "node_modules/node-gyp/node_modules/npmlog": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", - "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", - "dev": true, - "dependencies": { - "are-we-there-yet": "~1.1.2", - "console-control-strings": "~1.1.0", - "gauge": "~2.7.3", - "set-blocking": "~2.0.0" - } - }, - "node_modules/node-gyp/node_modules/readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, - "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "node_modules/node-gyp/node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true - }, - "node_modules/node-gyp/node_modules/string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "dependencies": { - "safe-buffer": "~5.1.0" - } - }, - "node_modules/node-gyp/node_modules/string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "dev": true, - "dependencies": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/node-gyp/node_modules/strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "dependencies": { - "ansi-regex": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/node-persist": { "version": "0.0.11", "resolved": "https://registry.npmjs.org/node-persist/-/node-persist-0.0.11.tgz", @@ -3788,7 +3643,7 @@ "version": "6.0.0", "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-6.0.0.tgz", "integrity": "sha512-03ppFRGlsyUaQFbGC2C8QWJN/C/K7PsfyD9aQdhVKAQIH4sQBc8WASqFBP7O+Ut4d2oo5LoeoboB3cGdBZSp6Q==", - "optional": true, + "devOptional": true, "dependencies": { "are-we-there-yet": "^2.0.0", "console-control-strings": "^1.1.0", @@ -3799,24 +3654,6 @@ "node": "^12.13.0 || ^14.15.0 || >=16" } }, - "node_modules/number-is-nan": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/object-inspect": { "version": "1.11.0", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.11.0.tgz", @@ -4117,12 +3954,6 @@ "node": ">=4" } }, - "node_modules/process-nextick-args": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", - "dev": true - }, "node_modules/progress": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", @@ -4293,7 +4124,7 @@ "version": "3.6.0", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "optional": true, + "devOptional": true, "dependencies": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", @@ -4477,6 +4308,7 @@ "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "devOptional": true, "funding": [ { "type": "github", @@ -4490,8 +4322,7 @@ "type": "consulting", "url": "https://feross.org/support" } - ], - "optional": true + ] }, "node_modules/safer-buffer": { "version": "2.1.2", @@ -4629,9 +4460,9 @@ } }, "node_modules/socks-proxy-agent": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-6.1.0.tgz", - "integrity": "sha512-57e7lwCN4Tzt3mXz25VxOErJKXlPfXmkMLnk310v/jwW20jWRVcgsOit+xNkN3eIEdB47GwnfAEBLacZ/wVIKg==", + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-6.1.1.tgz", + "integrity": "sha512-t8J0kG3csjA4g6FTbsMOWws+7R7vuRC8aQ/wy3/1OWmsgwA68zs/+cExQ0koSitUDXqhufF/YJr9wtNMZHw5Ew==", "dev": true, "dependencies": { "agent-base": "^6.0.2", @@ -4686,7 +4517,7 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "optional": true, + "devOptional": true, "dependencies": { "safe-buffer": "~5.2.0" } @@ -5618,9 +5449,9 @@ "dev": true }, "@types/node": { - "version": "16.11.9", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.9.tgz", - "integrity": "sha512-MKmdASMf3LtPzwLyRrFjtFFZ48cMf8jmX5VRYrDQiJa8Ybu5VAmkqBWqKU8fdCwD8ysw4mQ9nrEHvzg6gunR7A==", + "version": "16.11.10", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.10.tgz", + "integrity": "sha512-3aRnHa1KlOEEhJ6+CvyHKK5vE9BcLGjtUpwvqYLRvYNQKMfabu3BwfJaA/SLW8dxe28LsNDjtHwePTuzn3gmOA==", "dev": true }, "@typescript-eslint/eslint-plugin": { @@ -5817,13 +5648,13 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz", "integrity": "sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ==", - "optional": true + "devOptional": true }, "are-we-there-yet": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-2.0.0.tgz", "integrity": "sha512-Ci/qENmwHnsYo9xKIcUJN5LeDKdJ6R1Z1j9V/J5wyq8nh/mYPEpIKJbBZXtZjG04HiK7zV/p6Vs9952MrMeUIw==", - "optional": true, + "devOptional": true, "requires": { "delegates": "^1.0.0", "readable-stream": "^3.6.0" @@ -6095,9 +5926,9 @@ "dev": true }, "cli-table": { - "version": "0.3.8", - "resolved": "https://registry.npmjs.org/cli-table/-/cli-table-0.3.8.tgz", - "integrity": "sha512-5IO15fJRzgM+hHZjvQlqD6UPRuVGWR4Ny5ZzaM5VJxJEQqSIEVyVh9dMAUN6CBAVfMc4/6CFEzbhnRftLRCyug==", + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/cli-table/-/cli-table-0.3.9.tgz", + "integrity": "sha512-7eA6hFtAZwVx3dWAGoaBqTrzWko5jRUFKpHT64ZHkJpaA3y5wf5NlLjguqTRmqycatJZiwftODYYyGNLbQ7MuA==", "dev": true, "requires": { "colors": "1.0.3", @@ -6113,12 +5944,6 @@ "mimic-response": "^1.0.0" } }, - "code-point-at": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true - }, "color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -6138,7 +5963,7 @@ "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==", - "optional": true + "devOptional": true }, "colors": { "version": "1.0.3", @@ -6178,12 +6003,6 @@ "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", "devOptional": true }, - "core-util-is": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", - "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", - "dev": true - }, "create-require": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", @@ -6454,9 +6273,9 @@ "dev": true }, "eslint": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.2.0.tgz", - "integrity": "sha512-erw7XmM+CLxTOickrimJ1SiF55jiNlVSp2qqm0NuBWPtHYQCegD5ZMaW0c3i5ytPqL+SSLaCxdvQXFPLJn+ABw==", + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.3.0.tgz", + "integrity": "sha512-aIay56Ph6RxOTC7xyr59Kt3ewX185SaGnAr8eWukoPLeriCrvGjvAubxuvaXOfsxhtwV5g0uBOsyhAom4qJdww==", "dev": true, "requires": { "@eslint/eslintrc": "^1.0.4", @@ -6468,10 +6287,10 @@ "doctrine": "^3.0.0", "enquirer": "^2.3.5", "escape-string-regexp": "^4.0.0", - "eslint-scope": "^6.0.0", + "eslint-scope": "^7.1.0", "eslint-utils": "^3.0.0", - "eslint-visitor-keys": "^3.0.0", - "espree": "^9.0.0", + "eslint-visitor-keys": "^3.1.0", + "espree": "^9.1.0", "esquery": "^1.4.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", @@ -6500,9 +6319,9 @@ }, "dependencies": { "eslint-scope": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-6.0.0.tgz", - "integrity": "sha512-uRDL9MWmQCkaFus8RF5K9/L/2fn+80yoW3jkD53l4shjCh26fCtvJGasxjUqP5OT87SYTxCVA3BwTUzuELx9kA==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.0.tgz", + "integrity": "sha512-aWwkhnS0qAXqNOgKOK0dJ2nvzEbhEvpy8OlJ9kZ0FeZnA6zpjv1/Vei+puGFFX7zkPCkHHXb7IDX3A+7yPrRWg==", "dev": true, "requires": { "esrecurse": "^4.3.0", @@ -6557,14 +6376,14 @@ "dev": true }, "espree": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.0.0.tgz", - "integrity": "sha512-r5EQJcYZ2oaGbeR0jR0fFVijGOcwai07/690YRXLINuhmVeRY4UKSAsQPe/0BNuDgwP7Ophoc1PRsr2E3tkbdQ==", + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.1.0.tgz", + "integrity": "sha512-ZgYLvCS1wxOczBYGcQT9DDWgicXwJ4dbocr9uYN+/eresBAUuBu+O4WzB21ufQ/JqQT8gyp7hJ3z8SHii32mTQ==", "dev": true, "requires": { - "acorn": "^8.5.0", + "acorn": "^8.6.0", "acorn-jsx": "^5.3.1", - "eslint-visitor-keys": "^3.0.0" + "eslint-visitor-keys": "^3.1.0" } }, "esquery": { @@ -6798,7 +6617,7 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/gauge/-/gauge-4.0.0.tgz", "integrity": "sha512-F8sU45yQpjQjxKkm1UOAhf0U/O0aFt//Fl7hsrNVto+patMHjs7dPI9mFOGUKbhrgKm0S3EjW3scMFuQmWSROw==", - "optional": true, + "devOptional": true, "requires": { "ansi-regex": "^5.0.1", "aproba": "^1.0.3 || ^2.0.0", @@ -7002,9 +6821,9 @@ "dev": true }, "homebridge": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/homebridge/-/homebridge-1.3.6.tgz", - "integrity": "sha512-5kax/4ex1qYwF6lfIrNrH4c117zwcCXqqsSQ8qWg+dUYmTXapmtp8Iknsl3vzm5nHq9t/U9HUb5yHCSShmyXxQ==", + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/homebridge/-/homebridge-1.3.8.tgz", + "integrity": "sha512-LGX5qbLAWRfNpifaO2EN5+h78d70BctXryDN9QXXlPOQQziGMrvo9rBLQmihTNtJQut+P2JnUg+cBgcR1HYmIQ==", "dev": true, "requires": { "chalk": "^4.1.2", @@ -7836,9 +7655,9 @@ } }, "node-gyp": { - "version": "8.4.0", - "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-8.4.0.tgz", - "integrity": "sha512-Bi/oCm5bH6F+FmzfUxJpPaxMEyIhszULGR3TprmTeku8/dMFcdTcypk120NeZqEt54r1BrgEKtm2jJiuIKE28Q==", + "version": "8.4.1", + "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-8.4.1.tgz", + "integrity": "sha512-olTJRgUtAb/hOXG0E93wZDs5YiJlgbXxTwQAFHyNlRsXQnYzUaF2aGgujZbw+hR8aF4ZG/rST57bWMWD16jr9w==", "dev": true, "requires": { "env-paths": "^2.2.0", @@ -7846,128 +7665,11 @@ "graceful-fs": "^4.2.6", "make-fetch-happen": "^9.1.0", "nopt": "^5.0.0", - "npmlog": "^4.1.2", + "npmlog": "^6.0.0", "rimraf": "^3.0.2", "semver": "^7.3.5", "tar": "^6.1.2", "which": "^2.0.2" - }, - "dependencies": { - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true - }, - "aproba": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", - "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==", - "dev": true - }, - "are-we-there-yet": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.7.tgz", - "integrity": "sha512-nxwy40TuMiUGqMyRHgCSWZ9FM4VAoRP4xUYSTv5ImRog+h9yISPbVH7H8fASCIzYn9wlEv4zvFL7uKDMCFQm3g==", - "dev": true, - "requires": { - "delegates": "^1.0.0", - "readable-stream": "^2.0.6" - } - }, - "gauge": { - "version": "2.7.4", - "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", - "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", - "dev": true, - "requires": { - "aproba": "^1.0.3", - "console-control-strings": "^1.0.0", - "has-unicode": "^2.0.0", - "object-assign": "^4.1.0", - "signal-exit": "^3.0.0", - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", - "wide-align": "^1.1.0" - } - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "dev": true, - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "npmlog": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", - "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", - "dev": true, - "requires": { - "are-we-there-yet": "~1.1.2", - "console-control-strings": "~1.1.0", - "gauge": "~2.7.3", - "set-blocking": "~2.0.0" - } - }, - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - }, - "string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "dev": true, - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - } } }, "node-gyp-build": { @@ -8186,7 +7888,7 @@ "version": "6.0.0", "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-6.0.0.tgz", "integrity": "sha512-03ppFRGlsyUaQFbGC2C8QWJN/C/K7PsfyD9aQdhVKAQIH4sQBc8WASqFBP7O+Ut4d2oo5LoeoboB3cGdBZSp6Q==", - "optional": true, + "devOptional": true, "requires": { "are-we-there-yet": "^2.0.0", "console-control-strings": "^1.1.0", @@ -8194,18 +7896,6 @@ "set-blocking": "^2.0.0" } }, - "number-is-nan": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true - }, - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true - }, "object-inspect": { "version": "1.11.0", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.11.0.tgz", @@ -8414,12 +8104,6 @@ "integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=", "dev": true }, - "process-nextick-args": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", - "dev": true - }, "progress": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", @@ -8547,7 +8231,7 @@ "version": "3.6.0", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "optional": true, + "devOptional": true, "requires": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", @@ -8673,7 +8357,7 @@ "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "optional": true + "devOptional": true }, "safer-buffer": { "version": "2.1.2", @@ -8781,9 +8465,9 @@ } }, "socks-proxy-agent": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-6.1.0.tgz", - "integrity": "sha512-57e7lwCN4Tzt3mXz25VxOErJKXlPfXmkMLnk310v/jwW20jWRVcgsOit+xNkN3eIEdB47GwnfAEBLacZ/wVIKg==", + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-6.1.1.tgz", + "integrity": "sha512-t8J0kG3csjA4g6FTbsMOWws+7R7vuRC8aQ/wy3/1OWmsgwA68zs/+cExQ0koSitUDXqhufF/YJr9wtNMZHw5Ew==", "dev": true, "requires": { "agent-base": "^6.0.2", @@ -8826,7 +8510,7 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "optional": true, + "devOptional": true, "requires": { "safe-buffer": "~5.2.0" } diff --git a/package.json b/package.json index 76830a1c..b847dc2e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "displayName": "Homebridge SwitchBot", "name": "@switchbot/homebridge-switchbot", - "version": "1.2.0", + "version": "1.2.1", "description": "The [Homebridge](https://homebridge.io) SwitchBot plugin allows you to access your [SwitchBot](https://www.switch-bot.com) device(s) from HomeKit.", "author": "SwitchBot (https://github.com/SwitchBot)", "license": "ISC", @@ -13,7 +13,7 @@ "url": "https://github.com/OpenWonderLabs/homebridge-switchbot/issues" }, "engines": { - "homebridge": "^1.3.6", + "homebridge": "^1.3.8", "node": "^14.18.1 || ^16.13.0" }, "main": "dist/index.js", @@ -53,11 +53,11 @@ "rxjs": "^7.4.0" }, "devDependencies": { - "@types/node": "^16.11.9", + "@types/node": "^16.11.10", "@typescript-eslint/eslint-plugin": "^5.4.0", "@typescript-eslint/parser": "^5.4.0", - "eslint": "^8.2.0", - "homebridge": "^1.3.6", + "eslint": "^8.3.0", + "homebridge": "^1.3.8", "nodemon": "^2.0.15", "npm-check-updates": "^12.0.2", "rimraf": "^3.0.2", diff --git a/src/devices/bots.ts b/src/devices/bots.ts index f31cb2b0..86f66b9f 100644 --- a/src/devices/bots.ts +++ b/src/devices/bots.ts @@ -1,9 +1,11 @@ -import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge'; -import { SwitchBotPlatform } from '../platform'; + +import { AxiosResponse } from 'axios'; +import Switchbot from 'node-switchbot'; import { interval, Subject } from 'rxjs'; +import { SwitchBotPlatform } from '../platform'; import { debounceTime, skipWhile, tap } from 'rxjs/operators'; +import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge'; import { DeviceURL, device, devicesConfig, serviceData, ad, switchbot, deviceStatusResponse, payload } from '../settings'; -import { AxiosResponse } from 'axios'; /** * Platform Accessory @@ -17,7 +19,7 @@ export class Bot { private batteryService?: Service; // Characteristic Values - SwitchOn!: CharacteristicValue; + On!: CharacteristicValue; BatteryLevel!: CharacteristicValue; StatusLowBattery!: CharacteristicValue; @@ -49,7 +51,7 @@ export class Bot { + ` deviceType: ${device.bot?.deviceType})`); // default placeholders - this.SwitchOn = false; + this.On = false; this.BatteryLevel = 100; this.StatusLowBattery = 1; @@ -171,9 +173,12 @@ export class Bot { this.platform.debug(`Bot: ${this.accessory.displayName} BLE parseStatus`); // BLEmode (true if Switch Mode) | (false if Press Mode) if (this.mode) { - this.platform.device(`Bot: ${this.accessory.displayName} Switch Mode, mode: ${JSON.stringify(this.mode)}`); + this.On = Boolean(this.state); + this.platform.device(`Bot: ${this.accessory.displayName} Switch Mode, mode: ${JSON.stringify(this.mode)}, On: ${JSON.stringify(this.On)}`); + } else { + this.platform.device(`Bot: ${this.accessory.displayName} Press Mode, mode: ${JSON.stringify(this.mode)}, On: ${JSON.stringify(this.On)}`); } - this.SwitchOn = Boolean(this.state); + this.BatteryLevel = Number(this.battery); if (this.BatteryLevel < 10) { this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW; @@ -183,16 +188,16 @@ export class Bot { if (Number.isNaN(this.BatteryLevel)) { this.BatteryLevel = 100; } - this.platform.debug(`Bot: ${this.accessory.displayName} On: ${this.SwitchOn}, BatteryLevel: ${this.BatteryLevel}`); + this.platform.debug(`Bot: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`); } private async openAPIparseStatus() { if (this.platform.config.credentials?.openToken) { this.platform.debug(`Bot: ${this.accessory.displayName} OpenAPI parseStatus`); if (this.device.bot?.mode === 'press') { - this.SwitchOn = false; + this.On = false; } - this.platform.debug(`Bot ${this.accessory.displayName} On: ${this.SwitchOn}`); + this.platform.debug(`Bot ${this.accessory.displayName} On: ${this.On}`); } } @@ -208,12 +213,8 @@ export class Bot { } private connectBLE() { - // eslint-disable-next-line @typescript-eslint/no-var-requires - const Switchbot = require('node-switchbot'); const switchbot = new Switchbot(); - const colon = this.device.deviceId!.match(/.{1,2}/g); - const bleMac = colon!.join(':'); //returns 1A:23:B4:56:78:9A; - this.device.bleMac = bleMac.toLowerCase(); + this.device.bleMac = ((this.device.deviceId!.match(/.{1,2}/g))!.join(':')).toLowerCase(); this.platform.device(`Bot: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`); return switchbot; } @@ -258,6 +259,7 @@ export class Bot { this.platform.log.warn(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`); await this.openAPIRefreshStatus(); } + this.apiError(e); }); } @@ -314,7 +316,7 @@ export class Bot { if (this.device.bot?.mode === 'press') { this.platform.device(`Bot: ${this.accessory.displayName} Press Mode: ${this.device.bot?.mode}`); switchbot.discover({ model: 'H', quick: true, id: this.device.bleMac }).then((device_list) => { - this.platform.log.info(`Bot: ${this.accessory.displayName}, On: ${this.SwitchOn}`); + this.platform.log.info(`Bot: ${this.accessory.displayName}, On: ${this.On}`); return device_list[0].press({ id: this.device.bleMac }); }).then(() => { this.platform.device(`Bot: ${this.accessory.displayName} Done.`); @@ -332,11 +334,12 @@ export class Bot { this.platform.log.warn(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`); await this.openAPIpushChanges(); } + this.apiError(e); }); } else if (this.device.bot?.mode === 'switch') { this.platform.device(`Bot: ${this.accessory.displayName} Press Mode: ${this.device.bot?.mode}`); switchbot.discover({ model: 'H', quick: true, id: this.device.bleMac }).then((device_list: any) => { - this.platform.log.info(`Bot: ${this.accessory.displayName} On: ${this.SwitchOn}`); + this.platform.log.info(`Bot: ${this.accessory.displayName} On: ${this.On}`); return this.turnOnOff(device_list); }).then(() => { this.platform.device(`Bot: ${this.accessory.displayName} Done.`); @@ -354,6 +357,7 @@ export class Bot { this.platform.log.warn(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`); await this.openAPIpushChanges(); } + this.apiError(e); }); } else { this.platform.log.error(`Bot: ${this.accessory.displayName} Mode Not Set, mode: ${this.device.bot?.mode}`); @@ -361,7 +365,7 @@ export class Bot { } private turnOnOff(device_list: any) { - if (this.SwitchOn) { + if (this.On) { return device_list[0].turnOn({ id: this.device.bleMac }); } else { return device_list[0].turnOff({ id: this.device.bleMac }); @@ -377,18 +381,18 @@ export class Bot { parameter: 'default', } as payload; - if (this.device.bot?.mode === 'switch' && this.SwitchOn) { + if (this.device.bot?.mode === 'switch' && this.On) { payload.command = 'turnOn'; - this.SwitchOn = true; - this.platform.debug(`Bot: ${this.accessory.displayName} Switch Mode, Turning ${this.SwitchOn}`); - } else if (this.device.bot?.mode === 'switch' && !this.SwitchOn) { + this.On = true; + this.platform.debug(`Bot: ${this.accessory.displayName} Switch Mode, Turning ${this.On}`); + } else if (this.device.bot?.mode === 'switch' && !this.On) { payload.command = 'turnOff'; - this.SwitchOn = false; - this.platform.debug(`Bot: ${this.accessory.displayName} Switch Mode, Turning ${this.SwitchOn}`); + this.On = false; + this.platform.debug(`Bot: ${this.accessory.displayName} Switch Mode, Turning ${this.On}`); } else if (this.device.bot?.mode === 'press') { payload.command = 'press'; this.platform.debug(`Bot: ${this.accessory.displayName} Press Mode`); - this.SwitchOn = false; + this.On = false; } else { throw new Error(`Bot: ${this.accessory.displayName} Device Paramters not set for this Bot.`); } @@ -410,6 +414,7 @@ export class Bot { this.platform.log.error(`Bot: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`); } + this.apiError(e); } } } @@ -418,15 +423,15 @@ export class Bot { * Updates the status for each of the HomeKit Characteristics */ updateHomeKitCharacteristics() { - if (this.SwitchOn === undefined) { - this.platform.debug(`Bot: ${this.accessory.displayName} On: ${this.SwitchOn}`); + if (this.On === undefined) { + this.platform.debug(`Bot: ${this.accessory.displayName} On: ${this.On}`); } else { if (this.device.bot?.deviceType === 'switch') { - this.switchService!.updateCharacteristic(this.platform.Characteristic.On, this.SwitchOn); + this.switchService!.updateCharacteristic(this.platform.Characteristic.On, this.On); } else { - this.outletService!.updateCharacteristic(this.platform.Characteristic.On, this.SwitchOn); + this.outletService!.updateCharacteristic(this.platform.Characteristic.On, this.On); } - this.platform.device(`Bot: ${this.accessory.displayName} updateCharacteristic On: ${this.SwitchOn}`); + this.platform.device(`Bot: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`); } if (this.device.ble) { if (this.BatteryLevel === undefined) { @@ -490,7 +495,7 @@ export class Bot { */ private handleOnSet(value: CharacteristicValue) { this.platform.debug(`Bot: ${this.accessory.displayName} On: ${value}`); - this.SwitchOn = value; + this.On = value; this.doBotUpdate.next(); } } diff --git a/src/devices/colorbulb.ts b/src/devices/colorbulb.ts index 98c4d025..141c1297 100644 --- a/src/devices/colorbulb.ts +++ b/src/devices/colorbulb.ts @@ -1,9 +1,9 @@ -import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge'; -import { SwitchBotPlatform } from '../platform'; +import { AxiosResponse } from 'axios'; import { interval, Subject } from 'rxjs'; +import { SwitchBotPlatform } from '../platform'; import { debounceTime, skipWhile, tap } from 'rxjs/operators'; +import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge'; import { DeviceURL, device, devicesConfig, switchbot, deviceStatusResponse, payload, hs2rgb, rgb2hs } from '../settings'; -import { AxiosResponse } from 'axios'; /** * Platform Accessory @@ -344,6 +344,7 @@ export class ColorBulb { this.platform.log.error(`Color Bulb: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`); } + this.apiError(e); } } diff --git a/src/devices/contact.ts b/src/devices/contact.ts index bb462497..8333a84d 100644 --- a/src/devices/contact.ts +++ b/src/devices/contact.ts @@ -1,7 +1,8 @@ -import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge'; -import { SwitchBotPlatform } from '../platform'; +import Switchbot from 'node-switchbot'; import { interval, Subject } from 'rxjs'; import { skipWhile } from 'rxjs/operators'; +import { SwitchBotPlatform } from '../platform'; +import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge'; import { DeviceURL, device, devicesConfig, serviceData, switchbot, deviceStatusResponse } from '../settings'; /** @@ -222,12 +223,8 @@ export class Contact { } private connectBLE() { - // eslint-disable-next-line @typescript-eslint/no-var-requires - const Switchbot = require('node-switchbot'); const switchbot = new Switchbot(); - const colon = this.device.deviceId!.match(/.{1,2}/g); - const bleMac = colon!.join(':'); //returns 1A:23:B4:56:78:9A; - this.device.bleMac = bleMac.toLowerCase(); + this.device.bleMac = ((this.device.deviceId!.match(/.{1,2}/g))!.join(':')).toLowerCase(); this.platform.device(`Contact Sensor: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`); return switchbot; } @@ -273,6 +270,7 @@ export class Contact { this.platform.log.warn(`Contact Sensor: ${this.accessory.displayName} Using OpenAPI Connection`); await this.openAPIRefreshStatus(); } + this.apiError(e); }); } diff --git a/src/devices/curtains.ts b/src/devices/curtains.ts index dcbe5390..2db6f78a 100644 --- a/src/devices/curtains.ts +++ b/src/devices/curtains.ts @@ -1,9 +1,11 @@ -import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge'; -import { SwitchBotPlatform } from '../platform'; + +import { AxiosResponse } from 'axios'; +import Switchbot from 'node-switchbot'; import { interval, Subject } from 'rxjs'; +import { SwitchBotPlatform } from '../platform'; import { debounceTime, skipWhile, tap } from 'rxjs/operators'; +import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge'; import { DeviceURL, device, devicesConfig, serviceData, switchbot, deviceStatusResponse, payload } from '../settings'; -import { AxiosResponse } from 'axios'; export class Curtain { // Services @@ -21,13 +23,8 @@ export class Curtain { // OpenAPI Others deviceStatus!: deviceStatusResponse; - setNewTarget!: boolean; - setNewTargetTimer!: NodeJS.Timeout; // BLE Others - set_minLux!: number; - set_maxLux!: number; - spaceBetweenLevels!: number; switchbot!: switchbot; serviceData!: serviceData; calibration: serviceData['calibration']; @@ -35,9 +32,16 @@ export class Curtain { position: serviceData['position']; lightLevel: serviceData['lightLevel']; + // Target + setNewTarget!: boolean; + setNewTargetTimer!: NodeJS.Timeout; + // Config set_minStep!: number; refreshRate!: number; + set_minLux!: number; + set_maxLux!: number; + spaceBetweenLevels!: number; private readonly deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode; private readonly debugDebug = this.platform.config.options?.debug === 'debug' || this.platform.debugMode; @@ -186,12 +190,8 @@ export class Curtain { } private connectBLE() { - // eslint-disable-next-line @typescript-eslint/no-var-requires - const Switchbot = require('node-switchbot'); const switchbot = new Switchbot(); - const colon = this.device.deviceId!.match(/.{1,2}/g); - const bleMac = colon!.join(':'); //returns 1A:23:B4:56:78:9A; - this.device.bleMac = bleMac.toLowerCase(); + this.device.bleMac = ((this.device.deviceId!.match(/.{1,2}/g))!.join(':')).toLowerCase(); this.platform.device(`Curtain: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`); return switchbot; } @@ -245,6 +245,7 @@ export class Curtain { private async BLEparseStatus() { this.platform.debug(`Curtain: ${this.accessory.displayName} BLE parseStatus`); + this.setMinMax(); this.CurrentPosition = 100 - Number(this.position); this.platform.debug(`Curtain: ${this.accessory.displayName} CurrentPosition ${this.CurrentPosition}`); if (this.setNewTarget) { @@ -340,6 +341,7 @@ export class Curtain { if (this.platform.config.credentials?.openToken) { this.platform.debug(`Curtain: ${this.accessory.displayName} OpenAPI parseStatus`); // CurrentPosition + this.setMinMax(); this.CurrentPosition = 100 - this.deviceStatus.body.slidePosition!; this.platform.debug(`Curtain ${this.accessory.displayName} CurrentPosition: ${this.CurrentPosition}`); if (this.setNewTarget) { @@ -433,6 +435,7 @@ export class Curtain { this.platform.log.warn(`Curtain: ${this.accessory.displayName} Using OpenAPI Connection`); await this.openAPIRefreshStatus(); } + this.apiError(e); }); } @@ -490,6 +493,7 @@ export class Curtain { this.platform.log.warn(`Curtain: ${this.accessory.displayName} Using OpenAPI Connection`); await this.OpenAPIpushChanges(); } + this.apiError(e); }); } @@ -524,6 +528,7 @@ export class Curtain { this.platform.log.error(`Curtain: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`); } + this.apiError(e); } } } @@ -626,17 +631,18 @@ export class Curtain { if (value > this.CurrentPosition) { this.PositionState = this.platform.Characteristic.PositionState.INCREASING; this.setNewTarget = true; - //this.setMinMax(); + this.platform.debug(`Curtain: ${this.accessory.displayName} value: ${value}, CurrentPosition: ${this.CurrentPosition}`); } else if (value < this.CurrentPosition) { this.PositionState = this.platform.Characteristic.PositionState.DECREASING; this.setNewTarget = true; - //this.setMinMax(); + this.platform.debug(`Curtain: ${this.accessory.displayName} value: ${value}, CurrentPosition: ${this.CurrentPosition}`); } else { this.PositionState = this.platform.Characteristic.PositionState.STOPPED; this.setNewTarget = false; - //this.setMinMax(); + this.platform.debug(`Curtain: ${this.accessory.displayName} value: ${value}, CurrentPosition: ${this.CurrentPosition}`); } this.service.setCharacteristic(this.platform.Characteristic.PositionState, this.PositionState); + this.service.getCharacteristic(this.platform.Characteristic.PositionState).updateValue(this.PositionState); /** * If Curtain movement time is short, the moving flag from backend is always false. diff --git a/src/devices/humidifiers.ts b/src/devices/humidifiers.ts index d1e6160f..ad1d22b9 100644 --- a/src/devices/humidifiers.ts +++ b/src/devices/humidifiers.ts @@ -1,9 +1,10 @@ -import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge'; -import { SwitchBotPlatform } from '../platform'; +import { AxiosResponse } from 'axios'; +import Switchbot from 'node-switchbot'; import { interval, Subject } from 'rxjs'; +import { SwitchBotPlatform } from '../platform'; import { debounceTime, skipWhile, tap } from 'rxjs/operators'; +import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge'; import { DeviceURL, device, devicesConfig, serviceData, ad, deviceStatusResponse, payload } from '../settings'; -import { AxiosResponse } from 'axios'; /** * Platform Accessory @@ -290,12 +291,8 @@ export class Humidifier { } private connectBLE() { - // eslint-disable-next-line @typescript-eslint/no-var-requires - const Switchbot = require('node-switchbot'); const switchbot = new Switchbot(); - const colon = this.device.deviceId!.match(/.{1,2}/g); - const bleMac = colon!.join(':'); //returns 1A:23:B4:56:78:9A; - this.device.bleMac = bleMac.toLowerCase(); + this.device.bleMac = ((this.device.deviceId!.match(/.{1,2}/g))!.join(':')).toLowerCase(); this.platform.device(`Humidifier: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`); return switchbot; } @@ -340,6 +337,7 @@ export class Humidifier { this.platform.log.warn(`Humidifier: ${this.accessory.displayName} Using OpenAPI Connection`); await this.openAPIRefreshStatus(); } + this.apiError(e); }); } @@ -387,7 +385,7 @@ export class Humidifier { const switchbot = this.connectBLE(); switchbot.discover({ model: 'e', quick: true, id: this.device.bleMac }).then((device_list) => { this.platform.log.info(`${this.accessory.displayName} Target Position: ${this.Active}`); - return device_list[0].runToPos(100 - Number(this.Active)); + return device_list[0].percentage(this.RelativeHumidityHumidifierThreshold); }).then(() => { this.platform.device(`Humidifier: ${this.accessory.displayName} Done.`); }).catch(async (e: any) => { @@ -404,6 +402,7 @@ export class Humidifier { this.platform.log.warn(`Humidifier: ${this.accessory.displayName} Using OpenAPI Connection`); await this.OpenAPIpushChanges(); } + this.apiError(e); }); } diff --git a/src/devices/indoorcam.ts b/src/devices/indoorcam.ts index 88cd0455..0470dcc9 100644 --- a/src/devices/indoorcam.ts +++ b/src/devices/indoorcam.ts @@ -1,9 +1,9 @@ -import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge'; -import { SwitchBotPlatform } from '../platform'; +import { AxiosResponse } from 'axios'; import { interval, Subject } from 'rxjs'; +import { SwitchBotPlatform } from '../platform'; import { debounceTime, skipWhile, tap } from 'rxjs/operators'; +import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge'; import { DeviceURL, device, devicesConfig, deviceStatusResponse, payload } from '../settings'; -import { AxiosResponse } from 'axios'; export class IndoorCam { // Services diff --git a/src/devices/meters.ts b/src/devices/meters.ts index be11e239..927d20a5 100644 --- a/src/devices/meters.ts +++ b/src/devices/meters.ts @@ -1,7 +1,8 @@ -import { Service, PlatformAccessory, Units, CharacteristicValue } from 'homebridge'; -import { SwitchBotPlatform } from '../platform'; +import Switchbot from 'node-switchbot'; import { interval, Subject } from 'rxjs'; import { skipWhile } from 'rxjs/operators'; +import { SwitchBotPlatform } from '../platform'; +import { Service, PlatformAccessory, Units, CharacteristicValue } from 'homebridge'; import { DeviceURL, device, devicesConfig, serviceData, ad, switchbot, deviceStatusResponse } from '../settings'; /** @@ -189,7 +190,19 @@ export class Meter { // Current Temperature if (!this.device.meter?.hide_temperature) { - this.CurrentTemperature = Number(this.temperature); + if (this.device.meter?.unit === 1) { + this.CurrentTemperature = Number(this.temperature?.f); + } else if (this.device.meter?.unit === 0) { + this.CurrentTemperature = Number(this.temperature?.c); + } else { + if (this.fahrenheit) { + this.CurrentTemperature = Number(this.temperature?.f); + } else { + this.CurrentTemperature = Number(this.temperature?.c); + } + } + + this.CurrentTemperature = Number(); this.platform.debug(`Meter: ${this.accessory.displayName} Temperature: ${this.CurrentTemperature}°c, fahrenheit: ${this.fahrenheit}`); } } @@ -239,12 +252,8 @@ export class Meter { } private connectBLE() { - // eslint-disable-next-line @typescript-eslint/no-var-requires - const Switchbot = require('node-switchbot'); const switchbot = new Switchbot(); - const colon = this.device.deviceId!.match(/.{1,2}/g); - const bleMac = colon!.join(':'); //returns 1A:23:B4:56:78:9A; - this.device.bleMac = bleMac.toLowerCase(); + this.device.bleMac = ((this.device.deviceId!.match(/.{1,2}/g))!.join(':')).toLowerCase(); this.platform.device(`Meter: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`); return switchbot; } @@ -255,7 +264,7 @@ export class Meter { const switchbot = this.connectBLE(); // Start to monitor advertisement packets switchbot.startScan({ - model: 'e', + model: 'T', id: this.device.bleMac, }).then(() => { // Set an event hander @@ -267,8 +276,8 @@ export class Meter { this.battery = ad.serviceData.battery; this.platform.device(`Meter: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`); this.platform.device(`Meter: ${this.accessory.displayName} model: ${ad.serviceData.model}, modelName: ${ad.serviceData.modelName}, ` - + `temperature: ${ad.serviceData.temperature}, fahrenheit: ${ad.serviceData.fahrenheit}, humidity: ${ad.serviceData.humidity}, ` - + `battery: ${ad.serviceData.battery}`); + + `temperature: ${JSON.stringify(ad.serviceData.temperature)}, fahrenheit: ${ad.serviceData.fahrenheit}, ` + + `humidity: ${ad.serviceData.humidity}, battery: ${ad.serviceData.battery}`); }; // Wait 10 seconds return switchbot.wait(10000); @@ -291,6 +300,7 @@ export class Meter { this.platform.log.warn(`Meter: ${this.accessory.displayName} Using OpenAPI Connection`); await this.openAPIRefreshStatus(); } + this.apiError(e); }); } diff --git a/src/devices/motion.ts b/src/devices/motion.ts index df566507..8e37e8e5 100644 --- a/src/devices/motion.ts +++ b/src/devices/motion.ts @@ -1,7 +1,8 @@ -import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge'; -import { SwitchBotPlatform } from '../platform'; +import Switchbot from 'node-switchbot'; import { interval, Subject } from 'rxjs'; import { skipWhile } from 'rxjs/operators'; +import { SwitchBotPlatform } from '../platform'; +import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge'; import { DeviceURL, device, devicesConfig, serviceData, switchbot, deviceStatusResponse } from '../settings'; /** @@ -160,12 +161,8 @@ export class Motion { } private connectBLE() { - // eslint-disable-next-line @typescript-eslint/no-var-requires - const Switchbot = require('node-switchbot'); const switchbot = new Switchbot(); - const colon = this.device.deviceId!.match(/.{1,2}/g); - const bleMac = colon!.join(':'); //returns 1A:23:B4:56:78:9A; - this.device.bleMac = bleMac.toLowerCase(); + this.device.bleMac = ((this.device.deviceId!.match(/.{1,2}/g))!.join(':')).toLowerCase(); this.platform.device(`Motion Sensor: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`); return switchbot; } @@ -210,6 +207,7 @@ export class Motion { this.platform.log.warn(`Motion Sensor: ${this.accessory.displayName} Using OpenAPI Connection`); await this.openAPIRefreshStatus(); } + this.apiError(e); }); } diff --git a/src/devices/plugs.ts b/src/devices/plugs.ts index 4b1e6995..5a1876c6 100644 --- a/src/devices/plugs.ts +++ b/src/devices/plugs.ts @@ -1,9 +1,10 @@ -import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge'; -import { SwitchBotPlatform } from '../platform'; + +import { AxiosResponse } from 'axios'; import { interval, Subject } from 'rxjs'; +import { SwitchBotPlatform } from '../platform'; import { debounceTime, skipWhile, tap } from 'rxjs/operators'; +import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge'; import { DeviceURL, device, devicesConfig, deviceStatusResponse, payload } from '../settings'; -import { AxiosResponse } from 'axios'; export class Plug { // Services diff --git a/src/irdevices/airconditioners.ts b/src/irdevices/airconditioners.ts index 881e43be..aa4d1e6a 100644 --- a/src/irdevices/airconditioners.ts +++ b/src/irdevices/airconditioners.ts @@ -1,7 +1,7 @@ import { AxiosResponse } from 'axios'; -import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'; import { SwitchBotPlatform } from '../platform'; import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings'; +import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'; /** * Platform Accessory @@ -373,8 +373,8 @@ export class AirConditioner { this.platform.log.error(`Air Conditioner: ${this.accessory.displayName} Hub Device is offline.`); break; case 190: - this.platform.log.error(`Air Conditioner: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,` - + ` Or command: ${JSON.stringify(push.data)} format is invalid`); + this.platform.log.error(`Air Conditioner: ${this.accessory.displayName} Device internal error due to device states not synchronized` + + ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`); break; case 100: this.platform.debug(`Air Conditioner: ${this.accessory.displayName} Command successfully sent.`); diff --git a/src/irdevices/airpurifiers.ts b/src/irdevices/airpurifiers.ts index f02631f5..92c2c5d6 100644 --- a/src/irdevices/airpurifiers.ts +++ b/src/irdevices/airpurifiers.ts @@ -1,7 +1,7 @@ import { AxiosResponse } from 'axios'; -import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'; import { SwitchBotPlatform } from '../platform'; import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings'; +import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'; /** * Platform Accessory @@ -242,8 +242,8 @@ export class AirPurifier { this.platform.log.error(`Air Purifier: ${this.accessory.displayName} Hub Device is offline.`); break; case 190: - this.platform.log.error(`Air Purifier: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,` - + ` Or command: ${JSON.stringify(push.data)} format is invalid`); + this.platform.log.error(`Air Purifier: ${this.accessory.displayName} Device internal error due to device states not synchronized` + + ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`); break; case 100: this.platform.debug(`Air Purifier: ${this.accessory.displayName} Command successfully sent.`); diff --git a/src/irdevices/cameras.ts b/src/irdevices/cameras.ts index 99f33458..fe2e79bd 100644 --- a/src/irdevices/cameras.ts +++ b/src/irdevices/cameras.ts @@ -1,7 +1,7 @@ import { AxiosResponse } from 'axios'; -import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'; import { SwitchBotPlatform } from '../platform'; import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings'; +import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'; /** * Platform Accessory @@ -142,8 +142,8 @@ export class Camera { this.platform.log.error(`Camera: ${this.accessory.displayName} Hub Device is offline.`); break; case 190: - this.platform.log.error(`Camera: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,` - + ` Or command: ${JSON.stringify(push.data)} format is invalid`); + this.platform.log.error(`Camera: ${this.accessory.displayName} Device internal error due to device states not synchronized` + + ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`); break; case 100: this.platform.debug(`Camera: ${this.accessory.displayName} Command successfully sent.`); diff --git a/src/irdevices/fans.ts b/src/irdevices/fans.ts index f46063f4..88060613 100644 --- a/src/irdevices/fans.ts +++ b/src/irdevices/fans.ts @@ -1,6 +1,6 @@ import { AxiosResponse } from 'axios'; -import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'; import { SwitchBotPlatform } from '../platform'; +import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'; import { DeviceURL, irdevice, deviceStatusResponse, irDevicesConfig, payload } from '../settings'; /** @@ -264,8 +264,8 @@ export class Fan { this.platform.log.error(`Fan: ${this.accessory.displayName} Hub Device is offline.`); break; case 190: - this.platform.log.error(`Fan: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,` - + ` Or command: ${JSON.stringify(push.data)} format is invalid`); + this.platform.log.error(`Fan: ${this.accessory.displayName} Device internal error due to device states not synchronized` + + ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`); break; case 100: this.platform.debug(`Fan: ${this.accessory.displayName} Command successfully sent.`); diff --git a/src/irdevices/lights.ts b/src/irdevices/lights.ts index 9a5f2579..7d1f060b 100644 --- a/src/irdevices/lights.ts +++ b/src/irdevices/lights.ts @@ -1,7 +1,7 @@ import { AxiosResponse } from 'axios'; -import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'; import { SwitchBotPlatform } from '../platform'; import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings'; +import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'; /** * Platform Accessory @@ -176,8 +176,8 @@ export class Light { this.platform.log.error(`Light: ${this.accessory.displayName} Hub Device is offline.`); break; case 190: - this.platform.log.error(`Light: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,` - + ` Or command: ${JSON.stringify(push.data)} format is invalid`); + this.platform.log.error(`Light: ${this.accessory.displayName} Device internal error due to device states not synchronized` + + ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`); break; case 100: this.platform.debug(`Light: ${this.accessory.displayName} Command successfully sent.`); diff --git a/src/irdevices/others.ts b/src/irdevices/others.ts index 277f0ec2..5d08038b 100644 --- a/src/irdevices/others.ts +++ b/src/irdevices/others.ts @@ -1,7 +1,7 @@ import { AxiosResponse } from 'axios'; -import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'; import { SwitchBotPlatform } from '../platform'; import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings'; +import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'; /** * Platform Accessory @@ -163,8 +163,8 @@ export class Others { this.platform.log.error(`Other: ${this.accessory.displayName} Hub Device is offline.`); break; case 190: - this.platform.log.error(`Other: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,` - + ` Or command: ${JSON.stringify(push.data)} format is invalid`); + this.platform.log.error(`Other: ${this.accessory.displayName} Device internal error due to device states not synchronized` + + ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`); break; case 100: this.platform.debug(`Other: ${this.accessory.displayName} Command successfully sent.`); diff --git a/src/irdevices/tvs.ts b/src/irdevices/tvs.ts index d2981117..43c4d96f 100644 --- a/src/irdevices/tvs.ts +++ b/src/irdevices/tvs.ts @@ -1,6 +1,6 @@ import { AxiosResponse } from 'axios'; -import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'; import { SwitchBotPlatform } from '../platform'; +import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'; import { DeviceURL, irdevice, deviceStatusResponse, irDevicesConfig, payload } from '../settings'; /** diff --git a/src/irdevices/vacuumcleaners.ts b/src/irdevices/vacuumcleaners.ts index ff70a1b7..a7940eae 100644 --- a/src/irdevices/vacuumcleaners.ts +++ b/src/irdevices/vacuumcleaners.ts @@ -1,7 +1,7 @@ import { AxiosResponse } from 'axios'; -import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'; import { SwitchBotPlatform } from '../platform'; import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings'; +import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'; /** * Platform Accessory diff --git a/src/irdevices/waterheaters.ts b/src/irdevices/waterheaters.ts index b97cb2aa..f07d4d30 100644 --- a/src/irdevices/waterheaters.ts +++ b/src/irdevices/waterheaters.ts @@ -1,7 +1,7 @@ import { AxiosResponse } from 'axios'; -import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'; import { SwitchBotPlatform } from '../platform'; import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings'; +import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'; /** * Platform Accessory @@ -156,8 +156,8 @@ export class WaterHeater { this.platform.log.error(`Water Heater: ${this.accessory.displayName} Hub Device is offline.`); break; case 190: - this.platform.log.error(`Water Heater: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,` - + ` Or command: ${JSON.stringify(push.data)} format is invalid`); + this.platform.log.error(`Water Heater: ${this.accessory.displayName} Device internal error due to device states not synchronized` + + ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`); break; case 100: this.platform.debug(`Water Heater: ${this.accessory.displayName} Command successfully sent.`); diff --git a/src/platform.ts b/src/platform.ts index 49b2eb4f..8a696add 100644 --- a/src/platform.ts +++ b/src/platform.ts @@ -1,15 +1,4 @@ -import { API, DynamicPlatformPlugin, Logger, PlatformAccessory, Service, Characteristic } from 'homebridge'; -import axios, { AxiosInstance, AxiosRequestConfig } from 'axios'; -import { - PLATFORM_NAME, - PLUGIN_NAME, - DeviceURL, - irdevice, - device, - SwitchBotPlatformConfig, - deviceResponses, - devicesConfig, -} from './settings'; + import { Bot } from './devices/bots'; import { Plug } from './devices/plugs'; import { Meter } from './devices/meters'; @@ -28,6 +17,9 @@ import { AirPurifier } from './irdevices/airpurifiers'; import { WaterHeater } from './irdevices/waterheaters'; import { VacuumCleaner } from './irdevices/vacuumcleaners'; import { AirConditioner } from './irdevices/airconditioners'; +import axios, { AxiosInstance, AxiosRequestConfig } from 'axios'; +import { API, DynamicPlatformPlugin, Logger, PlatformAccessory, Service, Characteristic } from 'homebridge'; +import { PLATFORM_NAME, PLUGIN_NAME, DeviceURL, irdevice, device, SwitchBotPlatformConfig, deviceResponses, devicesConfig } from './settings'; /** * HomebridgePlatform @@ -444,7 +436,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin { accessory.context.model = device.deviceType; accessory.context.deviceID = device.deviceId; accessory.context.firmwareRevision = this.version; - await this.connectionTypeExistingAccessory(device, accessory); + await this.connectionTypeNewAccessory(device, accessory); // create the accessory handler for the newly create accessory // this is imported from `platformAccessory.ts` new Humidifier(this, accessory, device); @@ -501,7 +493,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin { accessory.context.model = device.deviceType; accessory.context.deviceID = device.deviceId; accessory.context.firmwareRevision = this.version; - await this.connectionTypeExistingAccessory(device, accessory); + await this.connectionTypeNewAccessory(device, accessory); // accessory.context.firmwareRevision = findaccessories.accessoryAttribute.softwareRevision; // create the accessory handler for the newly create accessory // this is imported from `platformAccessory.ts` @@ -555,7 +547,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin { accessory.context.model = device.deviceType; accessory.context.deviceID = device.deviceId; accessory.context.firmwareRevision = this.version; - await this.connectionTypeExistingAccessory(device, accessory); + await this.connectionTypeNewAccessory(device, accessory); // create the accessory handler for the newly create accessory // this is imported from `platformAccessory.ts` new Meter(this, accessory, device); @@ -586,6 +578,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin { existingAccessory.context.deviceID = device.deviceId; existingAccessory.displayName = device.deviceName; existingAccessory.context.firmwareRevision = this.version; + await this.connectionTypeExistingAccessory(device, existingAccessory); this.api.updatePlatformAccessories([existingAccessory]); // create the accessory handler for the restored accessory // this is imported from `platformAccessory.ts` @@ -607,6 +600,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin { accessory.context.model = device.deviceType; accessory.context.deviceID = device.deviceId; accessory.context.firmwareRevision = this.version; + await this.connectionTypeNewAccessory(device, accessory); // create the accessory handler for the newly create accessory // this is imported from `platformAccessory.ts` new Motion(this, accessory, device); @@ -637,6 +631,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin { existingAccessory.context.deviceID = device.deviceId; existingAccessory.displayName = device.deviceName; existingAccessory.context.firmwareRevision = this.version; + await this.connectionTypeExistingAccessory(device, existingAccessory); this.api.updatePlatformAccessories([existingAccessory]); // create the accessory handler for the restored accessory // this is imported from `platformAccessory.ts` @@ -658,6 +653,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin { accessory.context.model = device.deviceType; accessory.context.deviceID = device.deviceId; accessory.context.firmwareRevision = this.version; + await this.connectionTypeNewAccessory(device, accessory); // create the accessory handler for the newly create accessory // this is imported from `platformAccessory.ts` new Contact(this, accessory, device); @@ -720,7 +716,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin { accessory.context.model = device.deviceType; accessory.context.deviceID = device.deviceId; accessory.context.firmwareRevision = this.version; - await this.connectionTypeExistingAccessory(device, accessory); + await this.connectionTypeNewAccessory(device, accessory); // create the accessory handler for the newly create accessory // this is imported from `platformAccessory.ts` new Curtain(this, accessory, device); @@ -786,7 +782,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin { accessory.context.model = device.deviceType; accessory.context.deviceID = device.deviceId; accessory.context.firmwareRevision = this.version; - await this.connectionTypeExistingAccessory(device, accessory); + await this.connectionTypeNewAccessory(device, accessory); // create the accessory handler for the newly create accessory // this is imported from `platformAccessory.ts` new Plug(this, accessory, device); @@ -839,7 +835,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin { accessory.context.model = device.deviceType; accessory.context.deviceID = device.deviceId; accessory.context.firmwareRevision = this.version; - await this.connectionTypeExistingAccessory(device, accessory); + await this.connectionTypeNewAccessory(device, accessory); // create the accessory handler for the newly create accessory // this is imported from `platformAccessory.ts` new ColorBulb(this, accessory, device); @@ -892,7 +888,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin { accessory.context.model = device.deviceType; accessory.context.deviceID = device.deviceId; accessory.context.firmwareRevision = this.version; - await this.connectionTypeExistingAccessory(device, accessory); + await this.connectionTypeNewAccessory(device, accessory); // create the accessory handler for the newly create accessory // this is imported from `platformAccessory.ts` new IndoorCam(this, accessory, device); @@ -921,7 +917,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin { existingAccessory.context.deviceID = device.deviceId; existingAccessory.displayName = device.deviceName; existingAccessory.context.firmwareRevision = this.version; - existingAccessory.context.connectionType = 'OpenAPI'; + await this.connectionTypeExistingAccessory(device, existingAccessory); this.api.updatePlatformAccessories([existingAccessory]); // create the accessory handler for the restored accessory // this is imported from `platformAccessory.ts` @@ -940,7 +936,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin { accessory.context.model = device.remoteType; accessory.context.deviceID = device.deviceId; accessory.context.firmwareRevision = this.version; - accessory.context.connectionType = 'OpenAPI'; + await this.connectionTypeNewAccessory(device, accessory); // create the accessory handler for the newly create accessory // this is imported from `platformAccessory.ts` new TV(this, accessory, device); @@ -976,7 +972,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin { existingAccessory.context.deviceID = device.deviceId; existingAccessory.displayName = device.deviceName; existingAccessory.context.firmwareRevision = this.version; - existingAccessory.context.connectionType = 'OpenAPI'; + await this.connectionTypeExistingAccessory(device, existingAccessory); this.api.updatePlatformAccessories([existingAccessory]); // create the accessory handler for the restored accessory // this is imported from `platformAccessory.ts` @@ -998,7 +994,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin { accessory.context.model = device.remoteType; accessory.context.deviceID = device.deviceId; accessory.context.firmwareRevision = this.version; - accessory.context.connectionType = 'OpenAPI'; + await this.connectionTypeNewAccessory(device, accessory); // create the accessory handler for the newly create accessory // this is imported from `platformAccessory.ts` new Fan(this, accessory, device); @@ -1029,7 +1025,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin { existingAccessory.context.deviceID = device.deviceId; existingAccessory.displayName = device.deviceName; existingAccessory.context.firmwareRevision = this.version; - existingAccessory.context.connectionType = 'OpenAPI'; + await this.connectionTypeExistingAccessory(device, existingAccessory); this.api.updatePlatformAccessories([existingAccessory]); // create the accessory handler for the restored accessory // this is imported from `platformAccessory.ts` @@ -1051,7 +1047,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin { accessory.context.model = device.remoteType; accessory.context.deviceID = device.deviceId; accessory.context.firmwareRevision = this.version; - accessory.context.connectionType = 'OpenAPI'; + await this.connectionTypeNewAccessory(device, accessory); // create the accessory handler for the newly create accessory // this is imported from `platformAccessory.ts` new Light(this, accessory, device); @@ -1082,7 +1078,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin { existingAccessory.context.deviceID = device.deviceId; existingAccessory.displayName = device.deviceName; existingAccessory.context.firmwareRevision = this.version; - existingAccessory.context.connectionType = 'OpenAPI'; + await this.connectionTypeExistingAccessory(device, existingAccessory); this.api.updatePlatformAccessories([existingAccessory]); // create the accessory handler for the restored accessory // this is imported from `platformAccessory.ts` @@ -1104,7 +1100,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin { accessory.context.model = device.remoteType; accessory.context.deviceID = device.deviceId; accessory.context.firmwareRevision = this.version; - accessory.context.connectionType = 'OpenAPI'; + await this.connectionTypeNewAccessory(device, accessory); // create the accessory handler for the newly create accessory // this is imported from `platformAccessory.ts` new AirConditioner(this, accessory, device); @@ -1135,7 +1131,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin { existingAccessory.context.deviceID = device.deviceId; existingAccessory.displayName = device.deviceName; existingAccessory.context.firmwareRevision = this.version; - existingAccessory.context.connectionType = 'OpenAPI'; + await this.connectionTypeExistingAccessory(device, existingAccessory); this.api.updatePlatformAccessories([existingAccessory]); // create the accessory handler for the restored accessory // this is imported from `platformAccessory.ts` @@ -1157,7 +1153,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin { accessory.context.model = device.remoteType; accessory.context.deviceID = device.deviceId; accessory.context.firmwareRevision = this.version; - accessory.context.connectionType = 'OpenAPI'; + await this.connectionTypeNewAccessory(device, accessory); // create the accessory handler for the newly create accessory // this is imported from `platformAccessory.ts` new AirPurifier(this, accessory, device); @@ -1188,7 +1184,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin { existingAccessory.context.deviceID = device.deviceId; existingAccessory.displayName = device.deviceName; existingAccessory.context.firmwareRevision = this.version; - existingAccessory.context.connectionType = 'OpenAPI'; + await this.connectionTypeExistingAccessory(device, existingAccessory); this.api.updatePlatformAccessories([existingAccessory]); // create the accessory handler for the restored accessory // this is imported from `platformAccessory.ts` @@ -1210,7 +1206,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin { accessory.context.model = device.remoteType; accessory.context.deviceID = device.deviceId; accessory.context.firmwareRevision = this.version; - accessory.context.connectionType = 'OpenAPI'; + await this.connectionTypeNewAccessory(device, accessory); // create the accessory handler for the newly create accessory // this is imported from `platformAccessory.ts` new WaterHeater(this, accessory, device); @@ -1241,7 +1237,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin { existingAccessory.context.deviceID = device.deviceId; existingAccessory.displayName = device.deviceName; existingAccessory.context.firmwareRevision = this.version; - existingAccessory.context.connectionType = 'OpenAPI'; + await this.connectionTypeExistingAccessory(device, existingAccessory); this.api.updatePlatformAccessories([existingAccessory]); // create the accessory handler for the restored accessory // this is imported from `platformAccessory.ts` @@ -1263,7 +1259,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin { accessory.context.model = device.remoteType; accessory.context.deviceID = device.deviceId; accessory.context.firmwareRevision = this.version; - accessory.context.connectionType = 'OpenAPI'; + await this.connectionTypeNewAccessory(device, accessory); // create the accessory handler for the newly create accessory // this is imported from `platformAccessory.ts` new VacuumCleaner(this, accessory, device); @@ -1294,7 +1290,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin { existingAccessory.context.deviceID = device.deviceId; existingAccessory.displayName = device.deviceName; existingAccessory.context.firmwareRevision = this.version; - existingAccessory.context.connectionType = 'OpenAPI'; + await this.connectionTypeExistingAccessory(device, existingAccessory); this.api.updatePlatformAccessories([existingAccessory]); // create the accessory handler for the restored accessory // this is imported from `platformAccessory.ts` @@ -1316,7 +1312,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin { accessory.context.model = device.remoteType; accessory.context.deviceID = device.deviceId; accessory.context.firmwareRevision = this.version; - accessory.context.connectionType = 'OpenAPI'; + await this.connectionTypeNewAccessory(device, accessory); // create the accessory handler for the newly create accessory // this is imported from `platformAccessory.ts` new Camera(this, accessory, device); @@ -1347,7 +1343,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin { existingAccessory.context.deviceID = device.deviceId; existingAccessory.displayName = device.deviceName; existingAccessory.context.firmwareRevision = this.version; - existingAccessory.context.connectionType = 'OpenAPI'; + await this.connectionTypeExistingAccessory(device, existingAccessory); this.api.updatePlatformAccessories([existingAccessory]); // create the accessory handler for the restored accessory // this is imported from `platformAccessory.ts` @@ -1369,7 +1365,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin { accessory.context.model = device.remoteType; accessory.context.deviceID = device.deviceId; accessory.context.firmwareRevision = this.version; - accessory.context.connectionType = 'OpenAPI'; + await this.connectionTypeNewAccessory(device, accessory); // create the accessory handler for the newly create accessory // this is imported from `platformAccessory.ts` new Others(this, accessory, device);