node-switchbot 1.1.0 → 1.1.3-beta.1
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 +28 -16
- package/README.md +12 -12
- package/lib/switchbot-device-wohumi.js +34 -19
- package/lib/switchbot.js +1 -1
- package/package.json +40 -40
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,19 @@
|
|
|
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
|
-
## [Version 1.1.
|
|
5
|
+
## [Version 1.1.2](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.1.2) (2021-11-13)
|
|
6
|
+
|
|
7
|
+
### Changes
|
|
8
|
+
|
|
9
|
+
- Housekeeping and update dependencies
|
|
10
|
+
|
|
11
|
+
## [Version 1.1.1](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.1.1) (2021-11-02)
|
|
12
|
+
|
|
13
|
+
### Changes
|
|
14
|
+
|
|
15
|
+
- Change back from @node/noble to @abandonware/noble
|
|
16
|
+
|
|
17
|
+
## [Version 1.1.0](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.1.0) (2021-10-26)
|
|
6
18
|
|
|
7
19
|
### Changes
|
|
8
20
|
|
|
@@ -10,94 +22,94 @@ All notable changes to this project will be documented in this file. This projec
|
|
|
10
22
|
- Add Humidifier advertisement
|
|
11
23
|
- Correct Model for advertisement
|
|
12
24
|
|
|
13
|
-
## [Version 1.0.8](https://github.com/OpenWonderLabs/
|
|
25
|
+
## [Version 1.0.8](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.0.8) (2021-09-30)
|
|
14
26
|
|
|
15
27
|
### Changes
|
|
16
28
|
|
|
17
29
|
- fix extra trace of old noble from @abandonware/noble
|
|
18
30
|
|
|
19
|
-
## [Version 1.0.7](https://github.com/OpenWonderLabs/
|
|
31
|
+
## [Version 1.0.7](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.0.7) (2021-09-24)
|
|
20
32
|
|
|
21
33
|
### Changes
|
|
22
34
|
|
|
23
35
|
- Change from @abandonware/noble to @homebridge/noble
|
|
24
36
|
|
|
25
|
-
## [Version 1.0.6](https://github.com/OpenWonderLabs/
|
|
37
|
+
## [Version 1.0.6](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.0.6) (2021-08-29)
|
|
26
38
|
|
|
27
39
|
### Changes
|
|
28
40
|
|
|
29
41
|
- Fixes FATAL ERROR: ad_id is not defined
|
|
30
42
|
|
|
31
|
-
## [Version 1.0.5](https://github.com/OpenWonderLabs/
|
|
43
|
+
## [Version 1.0.5](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.0.5) (2021-08-04)
|
|
32
44
|
|
|
33
45
|
### Changes
|
|
34
46
|
|
|
35
47
|
- Adding code for Contact and Motion Sensors
|
|
36
48
|
- Not Ready to be used yet though
|
|
37
49
|
|
|
38
|
-
## [Version 1.0.4](https://github.com/OpenWonderLabs/
|
|
50
|
+
## [Version 1.0.4](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.0.4) (2021-08-03)
|
|
39
51
|
|
|
40
52
|
### Changes
|
|
41
53
|
|
|
42
54
|
- Support for the discover method with id on macOS
|
|
43
55
|
|
|
44
|
-
## [Version 1.0.3](https://github.com/OpenWonderLabs/
|
|
56
|
+
## [Version 1.0.3](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.0.3) (2021-07-30)
|
|
45
57
|
|
|
46
58
|
### Changes
|
|
47
59
|
|
|
48
60
|
- Fixed misspelling.
|
|
49
61
|
|
|
50
|
-
## [Version 1.0.2](https://github.com/OpenWonderLabs/
|
|
62
|
+
## [Version 1.0.2](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.0.2) (2021-07-29)
|
|
51
63
|
|
|
52
64
|
### Changes
|
|
53
65
|
|
|
54
66
|
- Housekeeping and update dependencies
|
|
55
67
|
|
|
56
|
-
## [Version 1.0.1](https://github.com/OpenWonderLabs/
|
|
68
|
+
## [Version 1.0.1](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.0.1) (2021-07-29)
|
|
57
69
|
|
|
58
70
|
### Changes
|
|
59
71
|
|
|
60
72
|
- Fixed issue where after switching Bluetooth off and on, would not work properly.
|
|
61
73
|
|
|
62
|
-
## [Version 1.0.0](https://github.com/OpenWonderLabs/
|
|
74
|
+
## [Version 1.0.0](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.0.0) (2021-01-21)
|
|
63
75
|
|
|
64
76
|
### Changes
|
|
65
77
|
|
|
66
78
|
- * fix "No device was found" in MacOS
|
|
67
79
|
|
|
68
|
-
## [Version 0.2.0](https://github.com/OpenWonderLabs/
|
|
80
|
+
## [Version 0.2.0](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v0.2.0) (2020-11-05)
|
|
69
81
|
|
|
70
82
|
### Changes
|
|
71
83
|
|
|
72
84
|
- Modify Curtain's action command to support group and running mode. (Thanks to [@SwitchBot-Wonderlabs](https://github.com/OpenWonderLabs/node-switchbot/pull/7/))
|
|
73
85
|
|
|
74
|
-
## [Version 0.1.0](https://github.com/OpenWonderLabs/
|
|
86
|
+
## [Version 0.1.0](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v0.1.0) (2020-10-28)
|
|
75
87
|
|
|
76
88
|
### Changes
|
|
77
89
|
|
|
78
90
|
- Added support for SwitchBot Curtain. (Thanks to [@SwitchBot-Wonderlabs](https://github.com/OpenWonderLabs/node-switchbot/pull/6/))
|
|
79
91
|
- Added support for running on the Raspberry Pi Zero W. (Thanks to [@zizi4n5](https://github.com/OpenWonderLabs/node-switchbot/pull/5))
|
|
80
92
|
|
|
81
|
-
## [Version 0.0.5](https://github.com/OpenWonderLabs/
|
|
93
|
+
## [Version 0.0.5](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v0.0.5) (2020-02-19)
|
|
82
94
|
|
|
83
95
|
### Changes
|
|
84
96
|
|
|
85
97
|
- Improved the stability of discovering the BLE characteristics. (Thanks to [@dnicolson](https://github.com/OpenWonderLabs/node-switchbot/issues/3))
|
|
86
98
|
|
|
87
|
-
## [Version 0.0.4](https://github.com/OpenWonderLabs/
|
|
99
|
+
## [Version 0.0.4](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v0.0.4) (2020-02-11)
|
|
88
100
|
|
|
89
101
|
### Changes
|
|
90
102
|
|
|
91
103
|
- Fixed the bug that temperature value lower than 0 degC could not be handled. (Thanks to [@musimasami](https://github.com/OpenWonderLabs/node-switchbot/issues/2))
|
|
92
104
|
|
|
93
|
-
## [Version 0.0.3](https://github.com/OpenWonderLabs/
|
|
105
|
+
## [Version 0.0.3](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v0.0.3) (2020-02-10)
|
|
94
106
|
|
|
95
107
|
### Changes
|
|
96
108
|
|
|
97
109
|
- Now the characteristic UUID `0x2a00` (Device Name) is not mandatory. Some models of Bot don't seem to support the characteristic. (Thanks to [@dnicolson](https://github.com/OpenWonderLabs/node-switchbot/issues/1))
|
|
98
110
|
- Fixed the bug that the `turnOn()` method returns an error if the "Press mode" is selected on the Bot.
|
|
99
111
|
|
|
100
|
-
## [Version 0.0.2](https://github.com/OpenWonderLabs/
|
|
112
|
+
## [Version 0.0.2](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v0.0.2) (2019-11-20)
|
|
101
113
|
|
|
102
114
|
### Changes
|
|
103
115
|
|
package/README.md
CHANGED
|
@@ -60,33 +60,33 @@ This module is unofficial. It was developed by reference to [the official python
|
|
|
60
60
|
|
|
61
61
|
## Supported OS
|
|
62
62
|
|
|
63
|
-
The node-switchbot supports only Linux-based OSes, such as Raspbian, Ubuntu, and so on. This module does not support Windows and macOS for now. (If [@
|
|
63
|
+
The node-switchbot supports only Linux-based OSes, such as Raspbian, Ubuntu, and so on. This module does not support Windows and macOS for now. (If [@abandonware/noble](https://github.com/abandonware/noble) is installed properly, this module might work well on such OSes.)
|
|
64
64
|
|
|
65
65
|
## Dependencies
|
|
66
66
|
|
|
67
67
|
* [Node.js](https://nodejs.org/en/) 10 +
|
|
68
|
-
* [@
|
|
68
|
+
* [@abandonware/noble](https://github.com/abandonware/noble)
|
|
69
69
|
|
|
70
70
|
|
|
71
|
-
See the document of the [@
|
|
71
|
+
See the document of the [@abandonware/noble](https://github.com/abandonware/noble) for details on installing the [@abandonware/noble](https://github.com/abandonware/noble).
|
|
72
72
|
|
|
73
|
-
Note that the noble must be run as root on most of Linux environments. See the document of the [@
|
|
73
|
+
Note that the noble must be run as root on most of Linux environments. See the document of the [@abandonware/noble](https://github.com/abandonware/noble) for details.
|
|
74
74
|
|
|
75
75
|
## Installation
|
|
76
76
|
|
|
77
|
-
Before installing the [@
|
|
77
|
+
Before installing the [@abandonware/noble](https://github.com/abandonware/noble), some linux libraries related Bluetooth as follows if the OS is Ubuntu/Debian/Raspbian.
|
|
78
78
|
|
|
79
79
|
```
|
|
80
80
|
$ sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
-
If you use other OS, follow the instructions described in the document of the [@
|
|
83
|
+
If you use other OS, follow the instructions described in the document of the [@abandonware/noble](https://github.com/abandonware/noble).
|
|
84
84
|
|
|
85
|
-
After installing the libraries above, install the [@
|
|
85
|
+
After installing the libraries above, install the [@abandonware/noble](https://github.com/abandonware/noble) and the node-switchbot (this module) as follows:
|
|
86
86
|
|
|
87
87
|
```
|
|
88
88
|
$ cd ~
|
|
89
|
-
$ npm install @
|
|
89
|
+
$ npm install @abandonware/noble
|
|
90
90
|
$ npm install node-switchbot
|
|
91
91
|
```
|
|
92
92
|
|
|
@@ -244,15 +244,15 @@ The `Switchbot` constructor takes an argument optionally. It must be a hash obje
|
|
|
244
244
|
|
|
245
245
|
Property | Type | Required | Description
|
|
246
246
|
:--------|:-------|:---------|:-----------
|
|
247
|
-
`noble` | Noble | option | a Noble object of the [`@
|
|
247
|
+
`noble` | Noble | option | a Noble object of the [`@abandonware/noble`](https://github.com/abandonware/noble) module
|
|
248
248
|
|
|
249
|
-
The node-switchbot module uses the [`@
|
|
249
|
+
The node-switchbot module uses the [`@abandonware/noble`](https://github.com/abandonware/noble) module in order to interact with BLE devices. If you want to interact other BLE devices using the `@abandonware/noble` module, you can create an `Noble` object by yourself, then pass it to this module. If you don't specify a `Noble` object to the `noble` property, this module automatically create a `Noble` object internally.
|
|
250
250
|
|
|
251
251
|
The sample code below shows how to pass a `Nobel` object to the `Switchbot` constructor.
|
|
252
252
|
|
|
253
253
|
```JavaScript
|
|
254
254
|
// Create a Noble object
|
|
255
|
-
const noble = require('@
|
|
255
|
+
const noble = require('@abandonware/noble');
|
|
256
256
|
|
|
257
257
|
// Create a Switchbot object
|
|
258
258
|
const Switchbot = require('node-switchbot');
|
|
@@ -379,7 +379,7 @@ The `serviceData` property depends on the model of the device. See the section "
|
|
|
379
379
|
|
|
380
380
|
### `stopScan()` method
|
|
381
381
|
|
|
382
|
-
The `stopScan()` method stops to scan advertising packets coming from devices. This
|
|
382
|
+
The `stopScan()` method stops to scan advertising packets coming from devices. This method returns nothing. Note that this method is *not* asynchronous but synchronous unlike the other methods. See the section "[`startScan()` method](#startscan-method)" for details.
|
|
383
383
|
|
|
384
384
|
### `onadvertisement` event handler
|
|
385
385
|
|
|
@@ -4,8 +4,8 @@ const SwitchbotDevice = require('./switchbot-device.js');
|
|
|
4
4
|
class SwitchbotDeviceWoHumi extends SwitchbotDevice {
|
|
5
5
|
|
|
6
6
|
/* ------------------------------------------------------------------
|
|
7
|
-
*
|
|
8
|
-
* -
|
|
7
|
+
* Auto()
|
|
8
|
+
* - Set Mode to Auto
|
|
9
9
|
*
|
|
10
10
|
* [Arguments]
|
|
11
11
|
* - none
|
|
@@ -14,13 +14,13 @@ class SwitchbotDeviceWoHumi extends SwitchbotDevice {
|
|
|
14
14
|
* - Promise object
|
|
15
15
|
* Nothing will be passed to the `resolve()`.
|
|
16
16
|
* ---------------------------------------------------------------- */
|
|
17
|
-
|
|
18
|
-
return this.
|
|
17
|
+
Auto() {
|
|
18
|
+
return this._operateHumi([0x57, 0x01, 0x80]);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
/* ------------------------------------------------------------------
|
|
22
|
-
*
|
|
23
|
-
* -
|
|
22
|
+
* First()
|
|
23
|
+
* - Set Mode to First
|
|
24
24
|
*
|
|
25
25
|
* [Arguments]
|
|
26
26
|
* - none
|
|
@@ -29,13 +29,13 @@ class SwitchbotDeviceWoHumi extends SwitchbotDevice {
|
|
|
29
29
|
* - Promise object
|
|
30
30
|
* Nothing will be passed to the `resolve()`.
|
|
31
31
|
* ---------------------------------------------------------------- */
|
|
32
|
-
|
|
33
|
-
return this.
|
|
32
|
+
First() {
|
|
33
|
+
return this._operateHumi([0x57, 0x01, 0x65]);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/* ------------------------------------------------------------------
|
|
37
|
-
*
|
|
38
|
-
* -
|
|
37
|
+
* Second()
|
|
38
|
+
* - Set Mode to Second
|
|
39
39
|
*
|
|
40
40
|
* [Arguments]
|
|
41
41
|
* - none
|
|
@@ -44,13 +44,13 @@ class SwitchbotDeviceWoHumi extends SwitchbotDevice {
|
|
|
44
44
|
* - Promise object
|
|
45
45
|
* Nothing will be passed to the `resolve()`.
|
|
46
46
|
* ---------------------------------------------------------------- */
|
|
47
|
-
|
|
48
|
-
return this.
|
|
47
|
+
Second() {
|
|
48
|
+
return this._operateHumi([0x57, 0x01, 0x66]);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
/* ------------------------------------------------------------------
|
|
52
|
-
*
|
|
53
|
-
* -
|
|
52
|
+
* Third()
|
|
53
|
+
* - Set Mode to Third
|
|
54
54
|
*
|
|
55
55
|
* [Arguments]
|
|
56
56
|
* - none
|
|
@@ -59,8 +59,8 @@ class SwitchbotDeviceWoHumi extends SwitchbotDevice {
|
|
|
59
59
|
* - Promise object
|
|
60
60
|
* Nothing will be passed to the `resolve()`.
|
|
61
61
|
* ---------------------------------------------------------------- */
|
|
62
|
-
|
|
63
|
-
return this.
|
|
62
|
+
Third() {
|
|
63
|
+
return this._operateHumi([0x57, 0x01, 0x67]);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
/* ------------------------------------------------------------------
|
|
@@ -74,11 +74,26 @@ class SwitchbotDeviceWoHumi extends SwitchbotDevice {
|
|
|
74
74
|
* - Promise object
|
|
75
75
|
* Nothing will be passed to the `resolve()`.
|
|
76
76
|
* ---------------------------------------------------------------- */
|
|
77
|
-
|
|
78
|
-
return this.
|
|
77
|
+
percentage() {
|
|
78
|
+
return this._operateHumi([0x57, 0x01, 0x01]);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
/* ------------------------------------------------------------------
|
|
82
|
+
* turnOff()
|
|
83
|
+
* - Turn off
|
|
84
|
+
*
|
|
85
|
+
* [Arguments]
|
|
86
|
+
* - none
|
|
87
|
+
*
|
|
88
|
+
* [Returen value]
|
|
89
|
+
* - Promise object
|
|
90
|
+
* Nothing will be passed to the `resolve()`.
|
|
91
|
+
* ---------------------------------------------------------------- */
|
|
92
|
+
turnOff() {
|
|
93
|
+
return this._operateHumi([0x57, 0x01, 0x02]);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
_operateHumi(bytes) {
|
|
82
97
|
return new Promise((resolve, reject) => {
|
|
83
98
|
let req_buf = Buffer.from(bytes);
|
|
84
99
|
this._command(req_buf).then((res_buf) => {
|
package/lib/switchbot.js
CHANGED
package/package.json
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
2
|
+
"name": "node-switchbot",
|
|
3
|
+
"version": "1.1.3-beta.1",
|
|
4
|
+
"description": "The node-switchbot is a Node.js module which allows you to move your Switchbot (Bot)'s arm and Switchbot Curtain(Curtain), also monitor the temperature/humidity from SwitchBot Thermometer & Hygrometer (Meter).",
|
|
5
|
+
"main": "./lib/switchbot.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"lib"
|
|
8
|
+
],
|
|
9
|
+
"directories": {
|
|
10
|
+
"lib": "./lib"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"check": "npm install && npm outdated",
|
|
14
|
+
"update": "ncu -u && npm update && npm install"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"switchbot",
|
|
18
|
+
"bot",
|
|
19
|
+
"meter",
|
|
20
|
+
"temperature",
|
|
21
|
+
"humidity",
|
|
22
|
+
"curtain",
|
|
23
|
+
"BLE",
|
|
24
|
+
"Bluetooth Low Energy",
|
|
25
|
+
"Bluetooth smart",
|
|
26
|
+
"Bluetooth"
|
|
27
|
+
],
|
|
28
|
+
"homepage": "https://github.com/OpenWonderLabs",
|
|
29
|
+
"author": "OpenWonderLabs (https://github.com/OpenWonderLabs)",
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://github.com/OpenWonderLabs/node-switchbot.git"
|
|
34
|
+
},
|
|
35
|
+
"readmeFilename": "README.md",
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@abandonware/noble": "^1.9.2-15"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"npm-check-updates": "^12.0.5"
|
|
41
|
+
}
|
|
42
42
|
}
|