node-switchbot 1.1.3-beta.0 → 1.1.3-beta.4

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.
@@ -1,9 +1,8 @@
1
- 'use strict';
2
- const SwitchbotDevice = require('./switchbot-device.js');
1
+ import SwitchbotDevice from "./switchbot-device.js";
3
2
 
4
3
  class SwitchbotDeviceWoHand extends SwitchbotDevice {
5
4
 
6
- /* ------------------------------------------------------------------
5
+ /* ------------------------------------------------------------------
7
6
  * press()
8
7
  * - Press
9
8
  *
@@ -14,11 +13,11 @@ class SwitchbotDeviceWoHand extends SwitchbotDevice {
14
13
  * - Promise object
15
14
  * Nothing will be passed to the `resolve()`.
16
15
  * ---------------------------------------------------------------- */
17
- press() {
18
- return this._operateBot([0x57, 0x01, 0x00]);
19
- }
16
+ press() {
17
+ return this._operateBot([0x57, 0x01, 0x00]);
18
+ }
20
19
 
21
- /* ------------------------------------------------------------------
20
+ /* ------------------------------------------------------------------
22
21
  * turnOn()
23
22
  * - Turn on
24
23
  *
@@ -29,11 +28,11 @@ class SwitchbotDeviceWoHand extends SwitchbotDevice {
29
28
  * - Promise object
30
29
  * Nothing will be passed to the `resolve()`.
31
30
  * ---------------------------------------------------------------- */
32
- turnOn() {
33
- return this._operateBot([0x57, 0x01, 0x01]);
34
- }
31
+ turnOn() {
32
+ return this._operateBot([0x57, 0x01, 0x01]);
33
+ }
35
34
 
36
- /* ------------------------------------------------------------------
35
+ /* ------------------------------------------------------------------
37
36
  * turnOff()
38
37
  * - Turn off
39
38
  *
@@ -44,11 +43,11 @@ class SwitchbotDeviceWoHand extends SwitchbotDevice {
44
43
  * - Promise object
45
44
  * Nothing will be passed to the `resolve()`.
46
45
  * ---------------------------------------------------------------- */
47
- turnOff() {
48
- return this._operateBot([0x57, 0x01, 0x02]);
49
- }
46
+ turnOff() {
47
+ return this._operateBot([0x57, 0x01, 0x02]);
48
+ }
50
49
 
51
- /* ------------------------------------------------------------------
50
+ /* ------------------------------------------------------------------
52
51
  * down()
53
52
  * - Down
54
53
  *
@@ -59,11 +58,11 @@ class SwitchbotDeviceWoHand extends SwitchbotDevice {
59
58
  * - Promise object
60
59
  * Nothing will be passed to the `resolve()`.
61
60
  * ---------------------------------------------------------------- */
62
- down() {
63
- return this._operateBot([0x57, 0x01, 0x03]);
64
- }
61
+ down() {
62
+ return this._operateBot([0x57, 0x01, 0x03]);
63
+ }
65
64
 
66
- /* ------------------------------------------------------------------
65
+ /* ------------------------------------------------------------------
67
66
  * up()
68
67
  * - Up
69
68
  *
@@ -74,26 +73,26 @@ class SwitchbotDeviceWoHand extends SwitchbotDevice {
74
73
  * - Promise object
75
74
  * Nothing will be passed to the `resolve()`.
76
75
  * ---------------------------------------------------------------- */
77
- up() {
78
- return this._operateBot([0x57, 0x01, 0x04]);
79
- }
76
+ up() {
77
+ return this._operateBot([0x57, 0x01, 0x04]);
78
+ }
80
79
 
81
- _operateBot(bytes) {
82
- return new Promise((resolve, reject) => {
83
- let req_buf = Buffer.from(bytes);
84
- this._command(req_buf).then((res_buf) => {
85
- let code = res_buf.readUInt8(0);
86
- if (res_buf.length === 3 && (code === 0x01 || code === 0x05)) {
87
- resolve();
88
- } else {
89
- reject(new Error('The device returned an error: 0x' + res_buf.toString('hex')));
90
- }
91
- }).catch((error) => {
92
- reject(error);
93
- });
94
- });
95
- }
80
+ _operateBot(bytes) {
81
+ return new Promise((resolve, reject) => {
82
+ let req_buf = Buffer.from(bytes);
83
+ this._command(req_buf).then((res_buf) => {
84
+ let code = res_buf.readUInt8(0);
85
+ if (res_buf.length === 3 && (code === 0x01 || code === 0x05)) {
86
+ resolve();
87
+ } else {
88
+ reject(new Error("The device returned an error: 0x" + res_buf.toString("hex")));
89
+ }
90
+ }).catch((error) => {
91
+ reject(error);
92
+ });
93
+ });
94
+ }
96
95
 
97
96
  }
98
97
 
99
- module.exports = SwitchbotDeviceWoHand;
98
+ export default SwitchbotDeviceWoHand;
@@ -1,9 +1,8 @@
1
- 'use strict';
2
- const SwitchbotDevice = require('./switchbot-device.js');
1
+ import SwitchbotDevice from "./switchbot-device.js";
3
2
 
4
3
  class SwitchbotDeviceWoHumi extends SwitchbotDevice {
5
4
 
6
- /* ------------------------------------------------------------------
5
+ /* ------------------------------------------------------------------
7
6
  * Auto()
8
7
  * - Set Mode to Auto
9
8
  *
@@ -14,11 +13,11 @@ class SwitchbotDeviceWoHumi extends SwitchbotDevice {
14
13
  * - Promise object
15
14
  * Nothing will be passed to the `resolve()`.
16
15
  * ---------------------------------------------------------------- */
17
- Auto() {
18
- return this._operateHumi([0x57, 0x01, 0x80]);
19
- }
16
+ Auto() {
17
+ return this._operateHumi([0x57, 0x01, 0x80]);
18
+ }
20
19
 
21
- /* ------------------------------------------------------------------
20
+ /* ------------------------------------------------------------------
22
21
  * First()
23
22
  * - Set Mode to First
24
23
  *
@@ -29,11 +28,11 @@ class SwitchbotDeviceWoHumi extends SwitchbotDevice {
29
28
  * - Promise object
30
29
  * Nothing will be passed to the `resolve()`.
31
30
  * ---------------------------------------------------------------- */
32
- First() {
33
- return this._operateHumi([0x57, 0x01, 0x65]);
34
- }
31
+ First() {
32
+ return this._operateHumi([0x57, 0x01, 0x65]);
33
+ }
35
34
 
36
- /* ------------------------------------------------------------------
35
+ /* ------------------------------------------------------------------
37
36
  * Second()
38
37
  * - Set Mode to Second
39
38
  *
@@ -44,11 +43,11 @@ class SwitchbotDeviceWoHumi extends SwitchbotDevice {
44
43
  * - Promise object
45
44
  * Nothing will be passed to the `resolve()`.
46
45
  * ---------------------------------------------------------------- */
47
- Second() {
48
- return this._operateHumi([0x57, 0x01, 0x66]);
49
- }
46
+ Second() {
47
+ return this._operateHumi([0x57, 0x01, 0x66]);
48
+ }
50
49
 
51
- /* ------------------------------------------------------------------
50
+ /* ------------------------------------------------------------------
52
51
  * Third()
53
52
  * - Set Mode to Third
54
53
  *
@@ -59,11 +58,11 @@ class SwitchbotDeviceWoHumi extends SwitchbotDevice {
59
58
  * - Promise object
60
59
  * Nothing will be passed to the `resolve()`.
61
60
  * ---------------------------------------------------------------- */
62
- Third() {
63
- return this._operateHumi([0x57, 0x01, 0x67]);
64
- }
61
+ Third() {
62
+ return this._operateHumi([0x57, 0x01, 0x67]);
63
+ }
65
64
 
66
- /* ------------------------------------------------------------------
65
+ /* ------------------------------------------------------------------
67
66
  * up()
68
67
  * - Up
69
68
  *
@@ -74,11 +73,11 @@ class SwitchbotDeviceWoHumi extends SwitchbotDevice {
74
73
  * - Promise object
75
74
  * Nothing will be passed to the `resolve()`.
76
75
  * ---------------------------------------------------------------- */
77
- percentage() {
78
- return this._operateHumi([0x57, 0x01, 0x01]);
79
- }
76
+ percentage() {
77
+ return this._operateHumi([0x57, 0x01, 0x01]);
78
+ }
80
79
 
81
- /* ------------------------------------------------------------------
80
+ /* ------------------------------------------------------------------
82
81
  * turnOff()
83
82
  * - Turn off
84
83
  *
@@ -89,26 +88,26 @@ class SwitchbotDeviceWoHumi extends SwitchbotDevice {
89
88
  * - Promise object
90
89
  * Nothing will be passed to the `resolve()`.
91
90
  * ---------------------------------------------------------------- */
92
- turnOff() {
93
- return this._operateHumi([0x57, 0x01, 0x02]);
94
- }
91
+ turnOff() {
92
+ return this._operateHumi([0x57, 0x01, 0x02]);
93
+ }
95
94
 
96
- _operateHumi(bytes) {
97
- return new Promise((resolve, reject) => {
98
- let req_buf = Buffer.from(bytes);
99
- this._command(req_buf).then((res_buf) => {
100
- let code = res_buf.readUInt8(0);
101
- if (res_buf.length === 3 && (code === 0x01 || code === 0x05)) {
102
- resolve();
103
- } else {
104
- reject(new Error('The device returned an error: 0x' + res_buf.toString('hex')));
105
- }
106
- }).catch((error) => {
107
- reject(error);
108
- });
109
- });
110
- }
95
+ _operateHumi(bytes) {
96
+ return new Promise((resolve, reject) => {
97
+ let req_buf = Buffer.from(bytes);
98
+ this._command(req_buf).then((res_buf) => {
99
+ let code = res_buf.readUInt8(0);
100
+ if (res_buf.length === 3 && (code === 0x01 || code === 0x05)) {
101
+ resolve();
102
+ } else {
103
+ reject(new Error("The device returned an error: 0x" + res_buf.toString("hex")));
104
+ }
105
+ }).catch((error) => {
106
+ reject(error);
107
+ });
108
+ });
109
+ }
111
110
 
112
111
  }
113
112
 
114
- module.exports = SwitchbotDeviceWoHumi;
113
+ export default SwitchbotDeviceWoHumi;
@@ -1,9 +1,8 @@
1
- 'use strict';
2
- const SwitchbotDevice = require('./switchbot-device.js');
1
+ import SwitchbotDevice from "./switchbot-device.js";
3
2
 
4
3
  class SwitchbotDeviceWoPresence extends SwitchbotDevice {
5
4
 
6
5
 
7
6
  }
8
7
 
9
- module.exports = SwitchbotDeviceWoPresence;
8
+ export default SwitchbotDeviceWoPresence;
@@ -1,9 +1,8 @@
1
- 'use strict';
2
- const SwitchbotDevice = require('./switchbot-device.js');
1
+ import SwitchbotDevice from "./switchbot-device.js";
3
2
 
4
3
  class SwitchbotDeviceWoSensorTH extends SwitchbotDevice {
5
4
 
6
5
 
7
6
  }
8
7
 
9
- module.exports = SwitchbotDeviceWoSensorTH;
8
+ export default SwitchbotDeviceWoSensorTH;