node-switchbot 1.4.2-beta.9 → 1.5.0-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.
@@ -361,20 +361,20 @@ class SwitchbotAdvertising {
361
361
  return null;
362
362
  }
363
363
  const byte9 = buf.readUInt8(9); // byte9: color bulb state; 0x00=off, 0x80=on & lightLevel: 1~100%
364
- const byte10 = buf.readUInt8(10); // byte10: bit0: 0=no delay,1=delay, bit1:0=no timer, 1=timer; bit2:0=no sync time, 1=sync'ed time
365
- const byte11 = buf.readUInt8(11); // byte11: wifi rssi
366
- const byte12 = buf.readUInt8(12); // byte12: bit7: overload?
367
- const byte13 = buf.readUInt8(13); // byte12[bit0~6] + byte13: current power value
364
+ //const byte10 = buf.readUInt8(10); // byte10: bit0: 0=no delay,1=delay, bit1:0=no timer, 1=timer; bit2:0=no sync time, 1=sync'ed time
365
+ //const byte11 = buf.readUInt8(11); // byte11: wifi rssi
366
+ //const byte12 = buf.readUInt8(12); // byte12: bit7: overload?
367
+ //const byte13 = buf.readUInt8(13); // byte12[bit0~6] + byte13: current power value
368
368
 
369
369
  const state = byte9 === 0x01 ? "off" : byte9 === 0x80 ? "on" : null;
370
370
  const lightLevel = byte9 & 0b00000011;
371
- const delay = !!(byte10 & 0b00000001);
372
- const networkStatus = !!(byte10 & 0b00000001);
373
- const statePreset = !!(byte10 & 0b00000010);
374
- const lightState = !!(byte10 & 0b00000100);
375
- const wifiRssi = byte11;
376
- const dynamicRate = !!(byte12 & 0b10000000);
377
- const loopIndex = (((byte12 & 0b01111111) << 8) + byte13) / 10; // in watt
371
+ //const delay = !!(byte10 & 0b00000001);
372
+ //const networkStatus = !!(byte10 & 0b00000001);
373
+ //const statePreset = !!(byte10 & 0b00000010);
374
+ //const lightState = !!(byte10 & 0b00000100);
375
+ //const wifiRssi = byte11;
376
+ //const dynamicRate = !!(byte12 & 0b10000000);
377
+ //const loopIndex = (((byte12 & 0b01111111) << 8) + byte13) / 10; // in watt
378
378
 
379
379
  const data = {
380
380
  model: "u",
@@ -540,25 +540,49 @@ class SwitchbotAdvertising {
540
540
  return data;
541
541
  }
542
542
 
543
- _parseServiceDataForWoLEDStripLight(buf, onlog) {
544
- if (buf.length !== 6) {
543
+ _parseServiceDataForWoStrip(buf, onlog) {
544
+ if (buf.length !== 18) {
545
545
  if (onlog && typeof onlog === "function") {
546
546
  onlog(
547
- `[_parseServiceDataForWoLEDStripLight] Buffer length ${buf.length} !== 6!`
547
+ `[_parseServiceDataForWoStrip] Buffer length ${buf.length} !== 18!`
548
548
  );
549
549
  }
550
550
  return null;
551
551
  }
552
- let byte1 = buf.readUInt8(1);
553
- let byte2 = buf.readUInt8(2);
554
- // let byte3 = buf.readUInt8(3);
555
- // let byte4 = buf.readUInt8(4);
556
- let byte5 = buf.readUInt8(5);
552
+ const byte9 = buf.readUInt8(9); // byte9: color bulb state; 0x00=off, 0x80=on & lightLevel: 1~100%
553
+ //const byte10 = buf.readUInt8(10); // byte10: bit0: 0=no delay,1=delay, bit1:0=no timer, 1=timer; bit2:0=no sync time, 1=sync'ed time
554
+ //const byte11 = buf.readUInt8(11); // byte11: wifi rssi
555
+ //const byte12 = buf.readUInt8(12); // byte12: bit7: overload?
556
+ //const byte13 = buf.readUInt8(13); // byte12[bit0~6] + byte13: current power value
557
557
 
558
- let data = {
558
+ const state = byte9 === 0x01 ? "off" : byte9 === 0x80 ? "on" : null;
559
+ //const lightLevel = byte9 & 0b00000011;
560
+ //const delay = !!(byte10 & 0b00000001);
561
+ //const networkStatus = !!(byte10 & 0b00000001);
562
+ //const statePreset = !!(byte10 & 0b00000010);
563
+ //const lightState = !!(byte10 & 0b00000100);
564
+ //const wifiRssi = byte11;
565
+ //const dynamicRate = !!(byte12 & 0b10000000);
566
+ //const loopIndex = (((byte12 & 0b01111111) << 8) + byte13) / 10; // in watt
567
+
568
+ const data = {
559
569
  model: "r",
560
- modelName: "WoLEDStripLight",
570
+ modelName: "WoStrip",
571
+ state: state,
561
572
  };
573
+ /* const data = {
574
+ model: "u",
575
+ modelName: "WoBulb",
576
+ state: state,
577
+ lightLevel: lightLevel,
578
+ delay: delay,
579
+ networkStatus: networkStatus,
580
+ statePreset: statePreset,
581
+ lightState: lightState,
582
+ wifiRssi: wifiRssi,
583
+ dynamicRate: dynamicRate,
584
+ loopIndex: loopIndex,
585
+ };*/
562
586
 
563
587
  return data;
564
588
  }
@@ -9,14 +9,14 @@ class SwitchbotDeviceWoStrip extends SwitchbotDevice {
9
9
  * @returns {Promise<boolean>} resolves with a boolean that tells whether the plug in ON(true) or OFF(false)
10
10
  */
11
11
  readState() {
12
- return this._operateBot([0x57, 0x0f, 0x48, 0x01]);
12
+ return this._operateBot([0x57, 0x0f, 0x4A, 0x01]);
13
13
  }
14
14
 
15
15
  /**
16
16
  * @private
17
17
  */
18
18
  _setState(reqByteArray) {
19
- const base = [0x57, 0x0f, 0x47, 0x01];
19
+ const base = [0x57, 0x0f, 0x49, 0x01];
20
20
  return this._operateBot([].concat(base, reqByteArray));
21
21
  }
22
22
 
package/package.json CHANGED
@@ -1,42 +1,42 @@
1
1
  {
2
- "name": "node-switchbot",
3
- "version": "1.4.2-beta.9",
4
- "description": "The node-switchbot is a Node.js module which allows you to control your Switchbot Devices through Bluetooth (BLE).",
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/node-switchbot",
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": "^16.2.1"
41
- }
2
+ "name": "node-switchbot",
3
+ "version": "1.5.0-beta.1",
4
+ "description": "The node-switchbot is a Node.js module which allows you to control your Switchbot Devices through Bluetooth (BLE).",
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/node-switchbot",
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": "^16.3.8"
41
+ }
42
42
  }
package/CHANGELOG.md DELETED
@@ -1,187 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/)
4
-
5
- ## [Version 1.4.1](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.4.1) (2022-08-27)
6
-
7
- ## What's Changed
8
-
9
- - Fix Plug Mini (US) implimentation
10
- - Housekeeping and update dependencies
11
-
12
- **Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v1.4.0...v1.4.1
13
-
14
- ## [Version 1.4.0](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.4.0) (2022-08-19)
15
-
16
- ## What's Changed
17
-
18
- - Added support for Plug Mini (j) & (g)
19
- - Housekeeping and update dependencies
20
-
21
- **Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v1.3.0...v1.4.0
22
-
23
- ## [Version 1.3.0](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.3.0) (2022-06-25)
24
-
25
- ## What's Changed
26
-
27
- - Added more Device Types, not all supported though.
28
- - Housekeeping and update dependencies
29
-
30
- **Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v1.2.0...v1.3.0
31
-
32
- ## [Version 1.2.0](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.2.0) (2022-03-04)
33
-
34
- ## What's Changed
35
-
36
- - Added support for SwitchBot "Contact" and "Motion"
37
- - Fix for Curtains on Firmware v3.3 and above
38
- - Housekeeping and update dependencies
39
-
40
- **Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v1.1.2...v1.2.0
41
-
42
- ## [Version 1.1.2](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.1.2) (2021-11-13)
43
-
44
- ## What's Changed
45
-
46
- - Housekeeping and update dependencies
47
-
48
- **Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v1.1.1...v1.1.2
49
-
50
- ## [Version 1.1.1](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.1.1) (2021-11-02)
51
-
52
- ## What's Changed
53
-
54
- - Change back from @node/noble to @abandonware/noble
55
-
56
- **Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v1.1.0...v1.1.1
57
-
58
- ## [Version 1.1.0](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.1.0) (2021-10-26)
59
-
60
- ## What's Changed
61
-
62
- - Add Contact/Motion Sensor advertisement
63
- - Add Humidifier advertisement
64
- - Correct Model for advertisement
65
-
66
- **Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v1.0.8...v1.1.0
67
-
68
- ## [Version 1.0.8](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.0.8) (2021-09-30)
69
-
70
- ## What's Changed
71
-
72
- - fix extra trace of old noble from @abandonware/noble
73
-
74
- **Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v1.0.7...v1.0.8
75
-
76
- ## [Version 1.0.7](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.0.7) (2021-09-24)
77
-
78
- ## What's Changed
79
-
80
- - Change from @abandonware/noble to @homebridge/noble
81
-
82
- **Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v1.0.6...v1.0.7
83
-
84
- ## [Version 1.0.6](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.0.6) (2021-08-29)
85
-
86
- ## What's Changed
87
-
88
- - Fixes FATAL ERROR: ad_id is not defined
89
-
90
- **Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v1.0.5...v1.0.6
91
-
92
- ## [Version 1.0.5](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.0.5) (2021-08-04)
93
-
94
- ## What's Changed
95
-
96
- - Adding code for Contact and Motion Sensors
97
- - Not Ready to be used yet though
98
-
99
- **Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v1.0.4...v1.0.5
100
-
101
- ## [Version 1.0.4](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.0.4) (2021-08-03)
102
-
103
- ## What's Changed
104
-
105
- - Support for the discover method with id on macOS
106
-
107
- **Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v1.0.3...v1.0.4
108
-
109
- ## [Version 1.0.3](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.0.3) (2021-07-30)
110
-
111
- ## What's Changed
112
-
113
- - Fixed misspelling.
114
-
115
- **Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v1.0.2...v1.0.3
116
-
117
- ## [Version 1.0.2](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.0.2) (2021-07-29)
118
-
119
- ## What's Changed
120
-
121
- - Housekeeping and update dependencies
122
-
123
- **Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v1.0.1...v1.0.2
124
-
125
- ## [Version 1.0.1](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.0.1) (2021-07-29)
126
-
127
- ## What's Changed
128
-
129
- - Fixed issue where after switching Bluetooth off and on, would not work properly.
130
-
131
- **Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v1.0.0...v1.0.1
132
-
133
- ## [Version 1.0.0](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.0.0) (2021-01-21)
134
-
135
- ## What's Changed
136
-
137
- - - fix "No device was found" in MacOS
138
-
139
- **Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v0.2.0...v1.0.0
140
-
141
- ## [Version 0.2.0](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v0.2.0) (2020-11-05)
142
-
143
- ## What's Changed
144
-
145
- - Modify Curtain's action command to support group and running mode. (Thanks to [@SwitchBot-Wonderlabs](https://github.com/OpenWonderLabs/node-switchbot/pull/7/))
146
-
147
- **Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v0.1.0...v0.2.0
148
-
149
- ## [Version 0.1.0](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v0.1.0) (2020-10-28)
150
-
151
- ## What's Changed
152
-
153
- - Added support for SwitchBot Curtain. (Thanks to [@SwitchBot-Wonderlabs](https://github.com/OpenWonderLabs/node-switchbot/pull/6/))
154
- - Added support for running on the Raspberry Pi Zero W. (Thanks to [@zizi4n5](https://github.com/OpenWonderLabs/node-switchbot/pull/5))
155
-
156
- **Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v0.0.5...v0.1.0
157
-
158
- ## [Version 0.0.5](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v0.0.5) (2020-02-19)
159
-
160
- ## What's Changed
161
-
162
- - Improved the stability of discovering the BLE characteristics. (Thanks to [@dnicolson](https://github.com/OpenWonderLabs/node-switchbot/issues/3))
163
-
164
- **Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v0.0.4...v0.0.5
165
-
166
- ## [Version 0.0.4](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v0.0.4) (2020-02-11)
167
-
168
- ## What's Changed
169
-
170
- - 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))
171
-
172
- **Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v0.0.3...v0.0.4
173
-
174
- ## [Version 0.0.3](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v0.0.3) (2020-02-10)
175
-
176
- ## What's Changed
177
-
178
- - 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))
179
- - Fixed the bug that the `turnOn()` method returns an error if the "Press mode" is selected on the Bot.
180
-
181
- **Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v0.0.2...v0.0.3
182
-
183
- ## [Version 0.0.2](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v0.0.2) (2019-11-20)
184
-
185
- ## What's Changed
186
-
187
- - First public release