@switchbot/homebridge-switchbot 1.1.1-beta.7 → 1.2.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -1
- package/README.md +67 -28
- package/config.schema.json +46 -43
- package/dist/devices/bots.d.ts +2 -0
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +118 -68
- package/dist/devices/bots.js.map +1 -1
- package/dist/devices/colorbulb.d.ts +19 -3
- package/dist/devices/colorbulb.d.ts.map +1 -1
- package/dist/devices/colorbulb.js +190 -31
- package/dist/devices/colorbulb.js.map +1 -1
- package/dist/devices/contact.d.ts +2 -0
- package/dist/devices/contact.d.ts.map +1 -1
- package/dist/devices/contact.js +22 -5
- package/dist/devices/contact.js.map +1 -1
- package/dist/devices/curtains.d.ts +5 -3
- package/dist/devices/curtains.d.ts.map +1 -1
- package/dist/devices/curtains.js +76 -26
- package/dist/devices/curtains.js.map +1 -1
- package/dist/devices/humidifiers.d.ts +2 -0
- package/dist/devices/humidifiers.d.ts.map +1 -1
- package/dist/devices/humidifiers.js +84 -27
- package/dist/devices/humidifiers.js.map +1 -1
- package/dist/devices/indoorcam.d.ts +2 -0
- package/dist/devices/indoorcam.d.ts.map +1 -1
- package/dist/devices/indoorcam.js +23 -7
- package/dist/devices/indoorcam.js.map +1 -1
- package/dist/devices/meters.d.ts +2 -0
- package/dist/devices/meters.d.ts.map +1 -1
- package/dist/devices/meters.js +21 -3
- package/dist/devices/meters.js.map +1 -1
- package/dist/devices/motion.d.ts +2 -0
- package/dist/devices/motion.d.ts.map +1 -1
- package/dist/devices/motion.js +21 -3
- package/dist/devices/motion.js.map +1 -1
- package/dist/devices/plugs.d.ts +2 -0
- package/dist/devices/plugs.d.ts.map +1 -1
- package/dist/devices/plugs.js +23 -7
- package/dist/devices/plugs.js.map +1 -1
- package/dist/irdevices/airconditioners.d.ts +2 -0
- package/dist/irdevices/airconditioners.d.ts.map +1 -1
- package/dist/irdevices/airconditioners.js +14 -5
- package/dist/irdevices/airconditioners.js.map +1 -1
- package/dist/irdevices/airpurifiers.d.ts +2 -0
- package/dist/irdevices/airpurifiers.d.ts.map +1 -1
- package/dist/irdevices/airpurifiers.js +14 -5
- package/dist/irdevices/airpurifiers.js.map +1 -1
- package/dist/irdevices/cameras.d.ts +2 -0
- package/dist/irdevices/cameras.d.ts.map +1 -1
- package/dist/irdevices/cameras.js +14 -5
- package/dist/irdevices/cameras.js.map +1 -1
- package/dist/irdevices/fans.d.ts +2 -0
- package/dist/irdevices/fans.d.ts.map +1 -1
- package/dist/irdevices/fans.js +13 -5
- package/dist/irdevices/fans.js.map +1 -1
- package/dist/irdevices/lights.d.ts +2 -0
- package/dist/irdevices/lights.d.ts.map +1 -1
- package/dist/irdevices/lights.js +14 -5
- package/dist/irdevices/lights.js.map +1 -1
- package/dist/irdevices/others.d.ts +2 -0
- package/dist/irdevices/others.d.ts.map +1 -1
- package/dist/irdevices/others.js +20 -11
- package/dist/irdevices/others.js.map +1 -1
- package/dist/irdevices/tvs.d.ts +2 -0
- package/dist/irdevices/tvs.d.ts.map +1 -1
- package/dist/irdevices/tvs.js +14 -4
- package/dist/irdevices/tvs.js.map +1 -1
- package/dist/irdevices/vacuumcleaners.d.ts +2 -0
- package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
- package/dist/irdevices/vacuumcleaners.js +14 -5
- package/dist/irdevices/vacuumcleaners.js.map +1 -1
- package/dist/irdevices/waterheaters.d.ts +2 -0
- package/dist/irdevices/waterheaters.d.ts.map +1 -1
- package/dist/irdevices/waterheaters.js +14 -5
- package/dist/irdevices/waterheaters.js.map +1 -1
- package/dist/platform.d.ts +1 -0
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +35 -26
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +4 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +557 -1
- package/dist/settings.js.map +1 -1
- package/package.json +6 -6
- package/src/devices/bots.ts +118 -69
- package/src/devices/colorbulb.ts +218 -33
- package/src/devices/contact.ts +23 -5
- package/src/devices/curtains.ts +80 -31
- package/src/devices/humidifiers.ts +85 -29
- package/src/devices/indoorcam.ts +24 -7
- package/src/devices/meters.ts +22 -3
- package/src/devices/motion.ts +22 -3
- package/src/devices/plugs.ts +24 -7
- package/src/irdevices/airconditioners.ts +15 -5
- package/src/irdevices/airpurifiers.ts +15 -5
- package/src/irdevices/cameras.ts +15 -5
- package/src/irdevices/fans.ts +13 -5
- package/src/irdevices/lights.ts +15 -5
- package/src/irdevices/others.ts +21 -11
- package/src/irdevices/tvs.ts +15 -4
- package/src/irdevices/vacuumcleaners.ts +15 -5
- package/src/irdevices/waterheaters.ts +15 -5
- package/src/platform.ts +36 -26
- package/src/settings.ts +557 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,12 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/)
|
|
4
4
|
|
|
5
|
-
## [
|
|
5
|
+
## [Version 1.2.0](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v1.2.0) (2021-11-19)
|
|
6
6
|
|
|
7
7
|
## What's Changed
|
|
8
|
+
* Added option to be able to do Bluetooth Low Energy (BLE) Only Connection.
|
|
9
|
+
* Must supply `Device ID` & `Device Name` to the Device Config
|
|
10
|
+
* Must Check `Enable Bluetooth Low Energy (BLE) Connection`
|
|
8
11
|
* Fixed Bug: Air conditioner temperature not able to change. [#43](https://github.com/OpenWonderLabs/homebridge-switchbot/issues/43)
|
|
9
12
|
* Add option to set Min Lux and Max Lux for Curtain's Light Sensor.
|
|
10
13
|
* Add `updateHomeKitCharacteristics` to IR Devices to contain all `updateCharacteristics` in one spot.
|
|
14
|
+
* Add `Saturation` and `Hue` to Colorbulb.
|
|
11
15
|
* Housekeeping and updated dependencies.
|
|
12
16
|
|
|
13
17
|
**Full Changelog**: https://github.com/OpenWonderLabs/homebridge-switchbot/compare/v1.1.0...v1.2.0
|
package/README.md
CHANGED
|
@@ -23,16 +23,25 @@ plugin allows you to access your SwitchBot Device(s) from HomeKit with
|
|
|
23
23
|
3. Click **Install**
|
|
24
24
|
|
|
25
25
|
## Configuration
|
|
26
|
+
* ### If using OpenAPI Connection
|
|
27
|
+
1. Download SwitchBot App on App Store or Google Play Store
|
|
28
|
+
2. Register a SwitchBot account and log in into your account
|
|
29
|
+
3. Generate an Open Token within the App
|
|
30
|
+
- Click Bottom Profile Tab
|
|
31
|
+
- Click Preference
|
|
32
|
+
- Click App version 10 Times, this will enable Developer Options
|
|
33
|
+
- Click Developer Options
|
|
34
|
+
- Click Copy to Clipboard
|
|
35
|
+
4. Input your `openToken` into the config paramter
|
|
36
|
+
* ### If using BLE Connection
|
|
37
|
+
1. Download SwitchBot App on App Store or Google Play Store
|
|
38
|
+
2. Register a SwitchBot account and log in into your account
|
|
39
|
+
3. Click on Device wanting to connect too plugin
|
|
40
|
+
- Click the Settings Gear
|
|
41
|
+
- Click Device Info
|
|
42
|
+
- Copy BLE Mac aka `deviceId`
|
|
43
|
+
4. Input your `deviceId` into the Device Config
|
|
26
44
|
|
|
27
|
-
1. Download SwitchBot App on App Store or Google Play Store
|
|
28
|
-
2. Register a SwitchBot account and log in into your account
|
|
29
|
-
3. Generate an Open Token within the App
|
|
30
|
-
- Click Bottom Profile Tab
|
|
31
|
-
- Click Preference
|
|
32
|
-
- Click App version 10 Times, this will enable Developer Options
|
|
33
|
-
- Click Developer Options
|
|
34
|
-
- Click Copy to Clipboard
|
|
35
|
-
4. Input your `Token` into the config paramter
|
|
36
45
|
|
|
37
46
|
<p align="center">
|
|
38
47
|
|
|
@@ -43,38 +52,68 @@ plugin allows you to access your SwitchBot Device(s) from HomeKit with
|
|
|
43
52
|
## Supported SwitchBot Devices
|
|
44
53
|
|
|
45
54
|
- [SwitchBot Humidifier](https://www.switch-bot.com/products/switchbot-smart-humidifier)
|
|
46
|
-
-
|
|
47
|
-
|
|
55
|
+
- Supports OpenAPI & Bluetooth Low Energy (BLE) Connections
|
|
56
|
+
- Can Push Updates over OpenAPI
|
|
57
|
+
- Can Receive Udpates over BLE and OpenAPI
|
|
48
58
|
- [SwitchBot Meter](https://www.switch-bot.com/products/switchbot-meter)
|
|
49
|
-
-
|
|
50
|
-
-
|
|
59
|
+
- Supports OpenAPI & Bluetooth Low Energy (BLE) Connections
|
|
60
|
+
- If using OpenAPI:
|
|
61
|
+
- [SwitchBot Hub Mini](https://www.switch-bot.com/products/switchbot-hub-mini) or [SwitchBot Hub Plus](https://www.switch-bot.com/products/switchbot-hub-plus) Required
|
|
62
|
+
- Enable Cloud Services for Device on SwitchBot App
|
|
63
|
+
- If using Bluetooth Low Energy (BLE) only:
|
|
64
|
+
- Must supply `deviceId` & `deviceName` to Device Config
|
|
65
|
+
- Check `Enable Bluetooth Low Energy (BLE) Connection` on Device Config
|
|
51
66
|
- [SwitchBot Motion Sensor](https://www.switch-bot.com/products/motion-sensor)
|
|
52
|
-
-
|
|
53
|
-
-
|
|
67
|
+
- Supports OpenAPI & Bluetooth Low Energy (BLE) Connections
|
|
68
|
+
- If using OpenAPI:
|
|
69
|
+
- [SwitchBot Hub Mini](https://www.switch-bot.com/products/switchbot-hub-mini) or [SwitchBot Hub Plus](https://www.switch-bot.com/products/switchbot-hub-plus) Required
|
|
70
|
+
- Enable Cloud Services for Device on SwitchBot App
|
|
71
|
+
- If using Bluetooth Low Energy (BLE) only:
|
|
72
|
+
- Must supply `deviceId` & `deviceName` to Device Config
|
|
73
|
+
- Check `Enable Bluetooth Low Energy (BLE) Connection` on Device Config
|
|
54
74
|
- [SwitchBot Contact Sensor](https://www.switch-bot.com/products/contact-sensor)
|
|
55
|
-
-
|
|
56
|
-
-
|
|
75
|
+
- Supports OpenAPI & Bluetooth Low Energy (BLE) Connections
|
|
76
|
+
- If using OpenAPI:
|
|
77
|
+
- [SwitchBot Hub Mini](https://www.switch-bot.com/products/switchbot-hub-mini) or [SwitchBot Hub Plus](https://www.switch-bot.com/products/switchbot-hub-plus) Required
|
|
78
|
+
- Enable Cloud Services for Device on SwitchBot App
|
|
79
|
+
- If using Bluetooth Low Energy (BLE) only:
|
|
80
|
+
- Must supply `deviceId` & `deviceName` to Device Config
|
|
81
|
+
- Check `Enable Bluetooth Low Energy (BLE) Connection` on Device Config
|
|
57
82
|
- [SwitchBot Curtain](https://www.switch-bot.com/products/switchbot-curtain)
|
|
58
|
-
-
|
|
59
|
-
-
|
|
83
|
+
- Supports OpenAPI & Bluetooth Low Energy (BLE) Connections
|
|
84
|
+
- If using OpenAPI:
|
|
85
|
+
- [SwitchBot Hub Mini](https://www.switch-bot.com/products/switchbot-hub-mini) or [SwitchBot Hub Plus](https://www.switch-bot.com/products/switchbot-hub-plus) Required
|
|
86
|
+
- Enable Cloud Services for Device on SwitchBot App
|
|
87
|
+
- If using Bluetooth Low Energy (BLE) only:
|
|
88
|
+
- Must supply `deviceId` & `deviceName` to Device Config
|
|
89
|
+
- Check `Enable Bluetooth Low Energy (BLE) Connection` on Device Config
|
|
60
90
|
- [SwitchBot Bulb](https://www.switch-bot.com/products/switchbot-color-bulb)
|
|
61
|
-
-
|
|
62
|
-
-
|
|
91
|
+
- Supports OpenAPI Connection Only
|
|
92
|
+
- If using OpenAPI:
|
|
93
|
+
- [SwitchBot Hub Mini](https://www.switch-bot.com/products/switchbot-hub-mini) or [SwitchBot Hub Plus](https://www.switch-bot.com/products/switchbot-hub-plus) Required
|
|
94
|
+
- Enable Cloud Services for Device on SwitchBot App
|
|
63
95
|
- [SwitchBot Bot](https://www.switch-bot.com/products/switchbot-bot)
|
|
64
|
-
-
|
|
65
|
-
-
|
|
66
|
-
|
|
67
|
-
-
|
|
68
|
-
-
|
|
69
|
-
-
|
|
70
|
-
-
|
|
96
|
+
- Supports OpenAPI & Bluetooth Low Energy (BLE) Connections
|
|
97
|
+
- If using OpenAPI:
|
|
98
|
+
- [SwitchBot Hub Mini](https://www.switch-bot.com/products/switchbot-hub-mini) or [SwitchBot Hub Plus](https://www.switch-bot.com/products/switchbot-hub-plus) Required
|
|
99
|
+
- Enable Cloud Services for Device on SwitchBot App
|
|
100
|
+
- You must set your Bot's Device ID in the Press Mode or Switch Mode Bot Settings (Advanced Settings > Device Settings > Bot Settings)
|
|
101
|
+
- Press Mode - Turns on then instantly turn it off
|
|
102
|
+
- Switch Mode - Turns on and keep it on until it is turned off
|
|
103
|
+
- This can get out of sync, since API doesn't give me a status
|
|
104
|
+
- To Correct you must go into the SwitchBot App and correct the status of either `On` or `Off`
|
|
105
|
+
- If using Bluetooth Low Energy (BLE) only:
|
|
106
|
+
- Must supply `deviceId` & `deviceName` to Device Config
|
|
107
|
+
- Check `Enable Bluetooth Low Energy (BLE) Connection` on Device Config
|
|
71
108
|
- SwitchBot Plug
|
|
109
|
+
- Supports OpenAPI Connection Only
|
|
72
110
|
|
|
73
111
|
## Supported IR Devices
|
|
74
112
|
### _(All IR Devices require [Hub Plus](https://www.switch-bot.com/products/switchbot-hub-plus) or [Hub Mini](https://www.switch-bot.com/products/switchbot-hub-mini))_
|
|
75
113
|
|
|
76
114
|
- TV
|
|
77
115
|
- Allows for On/Off and Volume Controls
|
|
116
|
+
- Optional Disable Sending Power Command
|
|
78
117
|
- Projector (Displayed as TV)
|
|
79
118
|
- Allows for On/Off and Volume Controls
|
|
80
119
|
- Set Top Box (Displayed as Set Top Box)
|
package/config.schema.json
CHANGED
|
@@ -47,6 +47,14 @@
|
|
|
47
47
|
"type": "string",
|
|
48
48
|
"placeholder": "81F3UT59513F"
|
|
49
49
|
},
|
|
50
|
+
"configDeviceName": {
|
|
51
|
+
"title": "Device Name",
|
|
52
|
+
"type": "string",
|
|
53
|
+
"placeholder": "Bot",
|
|
54
|
+
"condition": {
|
|
55
|
+
"functionBody": "return (model.options && model.options.devices && model.options.devices[arrayIndices].deviceId && model.options.devices[arrayIndices].ble);"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
50
58
|
"hide_device": {
|
|
51
59
|
"title": "Hide Device",
|
|
52
60
|
"type": "boolean",
|
|
@@ -117,14 +125,6 @@
|
|
|
117
125
|
"functionBody": "return (model.options && model.options.devices && model.options.devices[arrayIndices].deviceId && !model.options.devices[arrayIndices].hide_device);"
|
|
118
126
|
}
|
|
119
127
|
},
|
|
120
|
-
"configDeviceName": {
|
|
121
|
-
"title": "Device Name",
|
|
122
|
-
"type": "string",
|
|
123
|
-
"placeholder": "Bot",
|
|
124
|
-
"condition": {
|
|
125
|
-
"functionBody": "return (model.options && model.options.devices && model.options.devices[arrayIndices].deviceId && model.options.devices[arrayIndices].ble);"
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
128
|
"ble": {
|
|
129
129
|
"title": "Enable Bluetooth Low Energy (BLE) Connection",
|
|
130
130
|
"type": "boolean",
|
|
@@ -243,34 +243,31 @@
|
|
|
243
243
|
"curtain": {
|
|
244
244
|
"type": "object",
|
|
245
245
|
"properties": {
|
|
246
|
-
"
|
|
247
|
-
"title": "
|
|
248
|
-
"type": "
|
|
249
|
-
"
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
},
|
|
253
|
-
"hide_lightsensor": {
|
|
254
|
-
"title": "Hide Curtain's Light Sensor",
|
|
255
|
-
"type": "boolean",
|
|
246
|
+
"set_minStep": {
|
|
247
|
+
"title": "Set Minimum Step",
|
|
248
|
+
"type": "number",
|
|
249
|
+
"placeholder": "1",
|
|
250
|
+
"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",
|
|
256
251
|
"condition": {
|
|
257
252
|
"functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType === 'Curtain' && model.options.devices[arrayIndices].deviceId);"
|
|
258
253
|
}
|
|
259
254
|
},
|
|
260
|
-
"
|
|
261
|
-
"title": "Set
|
|
255
|
+
"set_min": {
|
|
256
|
+
"title": "Set Minimum Open State",
|
|
262
257
|
"type": "number",
|
|
263
|
-
"placeholder": "
|
|
258
|
+
"placeholder": "0",
|
|
259
|
+
"description": "Sets the minimum percentage before needed to set Curtain to Open",
|
|
264
260
|
"condition": {
|
|
265
|
-
"functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType === 'Curtain' && model.options.devices[arrayIndices].deviceId
|
|
261
|
+
"functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType === 'Curtain' && model.options.devices[arrayIndices].deviceId);"
|
|
266
262
|
}
|
|
267
263
|
},
|
|
268
|
-
"
|
|
269
|
-
"title": "Set
|
|
264
|
+
"set_max": {
|
|
265
|
+
"title": "Set Maximum Close State",
|
|
270
266
|
"type": "number",
|
|
271
|
-
"placeholder": "
|
|
267
|
+
"placeholder": "100",
|
|
268
|
+
"description": "Sets the maximum percentage before needing to set Curtain to Closed",
|
|
272
269
|
"condition": {
|
|
273
|
-
"functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType === 'Curtain' && model.options.devices[arrayIndices].deviceId
|
|
270
|
+
"functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType === 'Curtain' && model.options.devices[arrayIndices].deviceId);"
|
|
274
271
|
}
|
|
275
272
|
},
|
|
276
273
|
"refreshRate": {
|
|
@@ -283,28 +280,34 @@
|
|
|
283
280
|
"functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType === 'Curtain' && model.options.devices[arrayIndices].deviceId);"
|
|
284
281
|
}
|
|
285
282
|
},
|
|
286
|
-
"
|
|
287
|
-
"title": "
|
|
288
|
-
"type": "
|
|
289
|
-
"placeholder": "1",
|
|
283
|
+
"disable_group": {
|
|
284
|
+
"title": "Disable Grouping",
|
|
285
|
+
"type": "boolean",
|
|
290
286
|
"condition": {
|
|
291
287
|
"functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType === 'Curtain' && model.options.devices[arrayIndices].deviceId);"
|
|
292
288
|
}
|
|
293
289
|
},
|
|
294
|
-
"
|
|
295
|
-
"title": "
|
|
296
|
-
"type": "
|
|
297
|
-
"placeholder": "0",
|
|
290
|
+
"hide_lightsensor": {
|
|
291
|
+
"title": "Hide Curtain's Light Sensor",
|
|
292
|
+
"type": "boolean",
|
|
298
293
|
"condition": {
|
|
299
294
|
"functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType === 'Curtain' && model.options.devices[arrayIndices].deviceId);"
|
|
300
295
|
}
|
|
301
296
|
},
|
|
302
|
-
"
|
|
303
|
-
"title": "Set
|
|
297
|
+
"set_minlux": {
|
|
298
|
+
"title": "Set Min Lux",
|
|
304
299
|
"type": "number",
|
|
305
|
-
"placeholder": "
|
|
300
|
+
"placeholder": "1",
|
|
306
301
|
"condition": {
|
|
307
|
-
"functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType === 'Curtain' && model.options.devices[arrayIndices].deviceId);"
|
|
302
|
+
"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);"
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
"set_maxlux": {
|
|
306
|
+
"title": "Set Max Lux",
|
|
307
|
+
"type": "number",
|
|
308
|
+
"placeholder": "6001",
|
|
309
|
+
"condition": {
|
|
310
|
+
"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);"
|
|
308
311
|
}
|
|
309
312
|
}
|
|
310
313
|
}
|
|
@@ -701,10 +704,10 @@
|
|
|
701
704
|
"displayFlex": true,
|
|
702
705
|
"flex-direction": "column",
|
|
703
706
|
"items": [
|
|
707
|
+
"options.devices[].configDeviceName",
|
|
704
708
|
"options.devices[].deviceId",
|
|
705
709
|
"options.devices[].hide_device",
|
|
706
710
|
"options.devices[].ble",
|
|
707
|
-
"options.devices[].configDeviceName",
|
|
708
711
|
"options.devices[].configDeviceType",
|
|
709
712
|
"options.devices[].bot.mode",
|
|
710
713
|
"options.devices[].bot.deviceType",
|
|
@@ -713,14 +716,14 @@
|
|
|
713
716
|
"options.devices[].meter.unit",
|
|
714
717
|
"options.devices[].humidifier.set_minStep",
|
|
715
718
|
"options.devices[].humidifier.hide_temperature",
|
|
719
|
+
"options.devices[].curtain.set_minStep",
|
|
720
|
+
"options.devices[].curtain.set_min",
|
|
721
|
+
"options.devices[].curtain.set_max",
|
|
722
|
+
"options.devices[].curtain.refreshRate",
|
|
716
723
|
"options.devices[].curtain.disable_group",
|
|
717
724
|
"options.devices[].curtain.hide_lightsensor",
|
|
718
725
|
"options.devices[].curtain.set_minlux",
|
|
719
726
|
"options.devices[].curtain.set_maxlux",
|
|
720
|
-
"options.devices[].curtain.refreshRate",
|
|
721
|
-
"options.devices[].curtain.set_minStep",
|
|
722
|
-
"options.devices[].curtain.set_min",
|
|
723
|
-
"options.devices[].curtain.set_max",
|
|
724
727
|
"options.devices[].contact.hide_lightsensor",
|
|
725
728
|
"options.devices[].contact.hide_motionsensor",
|
|
726
729
|
"options.devices[].colorbulb.set_minStep"
|
package/dist/devices/bots.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ export declare class Bot {
|
|
|
23
23
|
mode: serviceData['mode'];
|
|
24
24
|
state: serviceData['state'];
|
|
25
25
|
battery: serviceData['battery'];
|
|
26
|
+
private readonly deviceDebug;
|
|
27
|
+
private readonly debugDebug;
|
|
26
28
|
botUpdateInProgress: boolean;
|
|
27
29
|
doBotUpdate: Subject<void>;
|
|
28
30
|
constructor(platform: SwitchBotPlatform, accessory: PlatformAccessory, device: device & devicesConfig);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bots.d.ts","sourceRoot":"","sources":["../../src/devices/bots.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAY,OAAO,EAAE,MAAM,MAAM,CAAC;AAEzC,OAAO,EAAa,MAAM,EAAE,aAAa,EAAE,WAAW,EAAM,SAAS,EAAE,oBAAoB,EAAW,MAAM,aAAa,CAAC;AAG1H;;;;GAIG;AACH,qBAAa,GAAG;
|
|
1
|
+
{"version":3,"file":"bots.d.ts","sourceRoot":"","sources":["../../src/devices/bots.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAY,OAAO,EAAE,MAAM,MAAM,CAAC;AAEzC,OAAO,EAAa,MAAM,EAAE,aAAa,EAAE,WAAW,EAAM,SAAS,EAAE,oBAAoB,EAAW,MAAM,aAAa,CAAC;AAG1H;;;;GAIG;AACH,qBAAa,GAAG;IA8BZ,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,SAAS;IACV,MAAM,EAAE,MAAM,GAAG,aAAa;IA9BvC,OAAO,CAAC,aAAa,CAAC,CAAU;IAChC,OAAO,CAAC,aAAa,CAAC,CAAU;IAChC,OAAO,CAAC,cAAc,CAAC,CAAU;IAGjC,QAAQ,EAAG,mBAAmB,CAAC;IAC/B,YAAY,EAAG,mBAAmB,CAAC;IACnC,gBAAgB,EAAG,mBAAmB,CAAC;IAGvC,YAAY,EAAG,oBAAoB,CAAC;IAGpC,SAAS,EAAG,SAAS,CAAC;IACtB,WAAW,EAAG,WAAW,CAAC;IAC1B,IAAI,EAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3B,KAAK,EAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IAC7B,OAAO,EAAG,WAAW,CAAC,SAAS,CAAC,CAAC;IAGjC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA+E;IAC3G,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA8E;IAGzG,mBAAmB,EAAG,OAAO,CAAC;IAC9B,WAAW,EAAG,OAAO,CAAC,IAAI,CAAC,CAAC;gBAGT,QAAQ,EAAE,iBAAiB,EACpC,SAAS,EAAE,iBAAiB,EAC7B,MAAM,EAAE,MAAM,GAAG,aAAa;IAkHvC;;OAEG;IACG,WAAW;YAQH,cAAc;YAmBd,kBAAkB;IAUhC;;OAEG;IACG,aAAa;IAQnB,OAAO,CAAC,UAAU;YAWJ,gBAAgB;YA2ChB,oBAAoB;IA+BlC;;;;;;OAMG;IACG,WAAW;YASH,cAAc;IAoD5B,OAAO,CAAC,SAAS;YAQH,kBAAkB;IA8ChC;;OAEG;IACH,4BAA4B;IA2BrB,QAAQ,CAAC,CAAC,EAAE,GAAG;IAYtB,OAAO,CAAC,UAAU;IA6BlB;;OAEG;IACH,OAAO,CAAC,WAAW;CAKpB"}
|
package/dist/devices/bots.js
CHANGED
|
@@ -14,6 +14,9 @@ class Bot {
|
|
|
14
14
|
this.platform = platform;
|
|
15
15
|
this.accessory = accessory;
|
|
16
16
|
this.device = device;
|
|
17
|
+
// Config
|
|
18
|
+
this.deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode;
|
|
19
|
+
this.debugDebug = this.platform.config.options?.debug === 'debug' || this.platform.debugMode;
|
|
17
20
|
// Bot Config
|
|
18
21
|
this.platform.device(`Bot: ${this.accessory.displayName} Config: (ble: ${device.ble}, mode: ${device.bot?.mode},`
|
|
19
22
|
+ ` deviceType: ${device.bot?.deviceType})`);
|
|
@@ -34,35 +37,33 @@ class Bot {
|
|
|
34
37
|
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId);
|
|
35
38
|
// get the LightBulb service if it exists, otherwise create a new LightBulb service
|
|
36
39
|
// you can create multiple services for each accessory
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
(this.
|
|
47
|
-
accessory.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
this.platform.log.info(`Bot: ${this.accessory.displayName} Displaying as Outlet`);
|
|
65
|
-
this.outletService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
40
|
+
if (device.bot?.deviceType === 'switch') {
|
|
41
|
+
// If outletService still pressent, then remove first
|
|
42
|
+
if (this.outletService) {
|
|
43
|
+
this.platform.device(`Bot: ${this.accessory.displayName} Removing Leftover outletService first`);
|
|
44
|
+
}
|
|
45
|
+
this.outletService = this.accessory.getService(this.platform.Service.Outlet);
|
|
46
|
+
accessory.removeService(this.outletService);
|
|
47
|
+
// Add switchService
|
|
48
|
+
(this.switchService =
|
|
49
|
+
accessory.getService(this.platform.Service.Switch) ||
|
|
50
|
+
accessory.addService(this.platform.Service.Switch)), `${accessory.displayName} Switch`;
|
|
51
|
+
this.platform.log.info(`Bot: ${this.accessory.displayName} Displaying as Switch`);
|
|
52
|
+
this.switchService?.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
// If switchService still pressent, then remove first
|
|
56
|
+
if (this.switchService) {
|
|
57
|
+
this.platform.device(`Bot: ${this.accessory.displayName} Removing Leftover switchService first`);
|
|
58
|
+
}
|
|
59
|
+
this.switchService = this.accessory.getService(this.platform.Service.Switch);
|
|
60
|
+
accessory.removeService(this.switchService);
|
|
61
|
+
// Add outletService
|
|
62
|
+
(this.outletService =
|
|
63
|
+
accessory.getService(this.platform.Service.Outlet) ||
|
|
64
|
+
accessory.addService(this.platform.Service.Outlet)), `${accessory.displayName} Outlet`;
|
|
65
|
+
this.platform.log.info(`Bot: ${this.accessory.displayName} Displaying as Outlet`);
|
|
66
|
+
this.outletService?.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
66
67
|
}
|
|
67
68
|
if (device.ble) {
|
|
68
69
|
(this.batteryService =
|
|
@@ -98,10 +99,15 @@ class Bot {
|
|
|
98
99
|
await this.pushChanges();
|
|
99
100
|
}
|
|
100
101
|
catch (e) {
|
|
101
|
-
this.platform.log.error(`Bot: ${this.accessory.displayName} failed
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
this.platform.log.error(`Bot: ${this.accessory.displayName} failed pushChanges`);
|
|
103
|
+
if (this.deviceDebug) {
|
|
104
|
+
this.platform.log.error(`Bot: ${this.accessory.displayName} failed pushChanges,`
|
|
105
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
106
|
+
}
|
|
107
|
+
if (this.debugDebug) {
|
|
108
|
+
this.platform.log.error(`Bot: ${this.accessory.displayName} failed pushChanges,`
|
|
109
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
110
|
+
}
|
|
105
111
|
}
|
|
106
112
|
this.botUpdateInProgress = false;
|
|
107
113
|
});
|
|
@@ -193,7 +199,15 @@ class Bot {
|
|
|
193
199
|
this.parseStatus();
|
|
194
200
|
this.updateHomeKitCharacteristics();
|
|
195
201
|
}).catch(async (e) => {
|
|
196
|
-
this.platform.log.error(`Bot: ${this.accessory.displayName}
|
|
202
|
+
this.platform.log.error(`Bot: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
|
|
203
|
+
if (this.deviceDebug) {
|
|
204
|
+
this.platform.log.error(`Bot: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
|
|
205
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
206
|
+
}
|
|
207
|
+
if (this.debugDebug) {
|
|
208
|
+
this.platform.log.error(`Bot: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
|
|
209
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
210
|
+
}
|
|
197
211
|
if (this.platform.config.credentials?.openToken) {
|
|
198
212
|
this.platform.log.warn(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
199
213
|
await this.openAPIRefreshStatus();
|
|
@@ -218,8 +232,15 @@ class Bot {
|
|
|
218
232
|
this.updateHomeKitCharacteristics();
|
|
219
233
|
}
|
|
220
234
|
catch (e) {
|
|
221
|
-
this.platform.log.error(`Bot: ${this.accessory.displayName} failed
|
|
222
|
-
|
|
235
|
+
this.platform.log.error(`Bot: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
|
|
236
|
+
if (this.deviceDebug) {
|
|
237
|
+
this.platform.log.error(`Bot: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
|
|
238
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
239
|
+
}
|
|
240
|
+
if (this.debugDebug) {
|
|
241
|
+
this.platform.log.error(`Bot: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
|
|
242
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
243
|
+
}
|
|
223
244
|
this.apiError(e);
|
|
224
245
|
}
|
|
225
246
|
}
|
|
@@ -251,7 +272,15 @@ class Bot {
|
|
|
251
272
|
}).then(() => {
|
|
252
273
|
this.platform.device(`Bot: ${this.accessory.displayName} Done.`);
|
|
253
274
|
}).catch(async (e) => {
|
|
254
|
-
this.platform.log.error(`Bot: ${this.accessory.displayName}
|
|
275
|
+
this.platform.log.error(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
|
|
276
|
+
if (this.deviceDebug) {
|
|
277
|
+
this.platform.log.error(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
|
|
278
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
279
|
+
}
|
|
280
|
+
if (this.debugDebug) {
|
|
281
|
+
this.platform.log.error(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
|
|
282
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
283
|
+
}
|
|
255
284
|
if (this.platform.config.credentials?.openToken) {
|
|
256
285
|
this.platform.log.warn(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
257
286
|
await this.openAPIpushChanges();
|
|
@@ -266,7 +295,15 @@ class Bot {
|
|
|
266
295
|
}).then(() => {
|
|
267
296
|
this.platform.device(`Bot: ${this.accessory.displayName} Done.`);
|
|
268
297
|
}).catch(async (e) => {
|
|
269
|
-
this.platform.log.error(`Bot: ${this.accessory.displayName}
|
|
298
|
+
this.platform.log.error(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
|
|
299
|
+
if (this.deviceDebug) {
|
|
300
|
+
this.platform.log.error(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
|
|
301
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
302
|
+
}
|
|
303
|
+
if (this.debugDebug) {
|
|
304
|
+
this.platform.log.error(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
|
|
305
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
306
|
+
}
|
|
270
307
|
if (this.platform.config.credentials?.openToken) {
|
|
271
308
|
this.platform.log.warn(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
272
309
|
await this.openAPIpushChanges();
|
|
@@ -274,7 +311,7 @@ class Bot {
|
|
|
274
311
|
});
|
|
275
312
|
}
|
|
276
313
|
else {
|
|
277
|
-
this.platform.log.error(`Bot: ${this.accessory.displayName} Mode Not Set
|
|
314
|
+
this.platform.log.error(`Bot: ${this.accessory.displayName} Mode Not Set, mode: ${this.device.bot?.mode}`);
|
|
278
315
|
}
|
|
279
316
|
}
|
|
280
317
|
turnOnOff(device_list) {
|
|
@@ -287,35 +324,48 @@ class Bot {
|
|
|
287
324
|
}
|
|
288
325
|
async openAPIpushChanges() {
|
|
289
326
|
if (this.platform.config.credentials?.openToken) {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
327
|
+
try {
|
|
328
|
+
this.platform.debug(`Bot: ${this.accessory.displayName} OpenAPI pushChanges`);
|
|
329
|
+
const payload = {
|
|
330
|
+
commandType: 'command',
|
|
331
|
+
parameter: 'default',
|
|
332
|
+
};
|
|
333
|
+
if (this.device.bot?.mode === 'switch' && this.SwitchOn) {
|
|
334
|
+
payload.command = 'turnOn';
|
|
335
|
+
this.SwitchOn = true;
|
|
336
|
+
this.platform.debug(`Bot: ${this.accessory.displayName} Switch Mode, Turning ${this.SwitchOn}`);
|
|
337
|
+
}
|
|
338
|
+
else if (this.device.bot?.mode === 'switch' && !this.SwitchOn) {
|
|
339
|
+
payload.command = 'turnOff';
|
|
340
|
+
this.SwitchOn = false;
|
|
341
|
+
this.platform.debug(`Bot: ${this.accessory.displayName} Switch Mode, Turning ${this.SwitchOn}`);
|
|
342
|
+
}
|
|
343
|
+
else if (this.device.bot?.mode === 'press') {
|
|
344
|
+
payload.command = 'press';
|
|
345
|
+
this.platform.debug(`Bot: ${this.accessory.displayName} Press Mode`);
|
|
346
|
+
this.SwitchOn = false;
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
throw new Error(`Bot: ${this.accessory.displayName} Device Paramters not set for this Bot.`);
|
|
350
|
+
}
|
|
351
|
+
this.platform.log.info(`Bot: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
|
|
352
|
+
+ ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`);
|
|
353
|
+
// Make the API request
|
|
354
|
+
const push = (await this.platform.axios.post(`${settings_1.DeviceURL}/${this.device.deviceId}/commands`, payload));
|
|
355
|
+
this.platform.debug(`Bot ${this.accessory.displayName} pushchanges: ${JSON.stringify(push.data)}`);
|
|
356
|
+
this.statusCode(push);
|
|
309
357
|
}
|
|
310
|
-
|
|
311
|
-
|
|
358
|
+
catch (e) {
|
|
359
|
+
this.platform.log.error(`Bot: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
|
|
360
|
+
if (this.deviceDebug) {
|
|
361
|
+
this.platform.log.error(`Bot: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
362
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
363
|
+
}
|
|
364
|
+
if (this.debugDebug) {
|
|
365
|
+
this.platform.log.error(`Bot: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
366
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
367
|
+
}
|
|
312
368
|
}
|
|
313
|
-
this.platform.log.info(`Bot: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
|
|
314
|
-
+ ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`);
|
|
315
|
-
// Make the API request
|
|
316
|
-
const push = (await this.platform.axios.post(`${settings_1.DeviceURL}/${this.device.deviceId}/commands`, payload));
|
|
317
|
-
this.platform.debug(`Bot ${this.accessory.displayName} pushchanges: ${JSON.stringify(push.data)}`);
|
|
318
|
-
this.statusCode(push);
|
|
319
369
|
}
|
|
320
370
|
}
|
|
321
371
|
/**
|
|
@@ -381,8 +431,8 @@ class Bot {
|
|
|
381
431
|
this.platform.log.error(`Bot: ${this.accessory.displayName} Hub Device is offline.`);
|
|
382
432
|
break;
|
|
383
433
|
case 190:
|
|
384
|
-
|
|
385
|
-
|
|
434
|
+
this.platform.log.error(`Bot: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
|
|
435
|
+
+ ` Or command: ${JSON.stringify(push.data)} format is invalid`);
|
|
386
436
|
break;
|
|
387
437
|
case 100:
|
|
388
438
|
this.platform.debug(`Bot: ${this.accessory.displayName} Command successfully sent.`);
|