You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+49-42Lines changed: 49 additions & 42 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -179,6 +179,9 @@ The sample codes above will output the result as follows:
179
179
"battery": 100
180
180
}
181
181
}
182
+
```
183
+
184
+
```json
182
185
{
183
186
"id": "cb4eb903c96d",
184
187
"address": "cb:4e:b9:03:c9:6d",
@@ -195,6 +198,9 @@ The sample codes above will output the result as follows:
195
198
"battery": 100
196
199
}
197
200
}
201
+
```
202
+
203
+
```json
198
204
{
199
205
"id": "ec58c5d00111",
200
206
"address": "ec:58:c5:d0:01:11",
@@ -257,7 +263,8 @@ import { SwitchBot } from 'node-switchbot';
257
263
You can get an `SwitchBot` constructor from the code above. Then you have to create a `SwitchBot` object from the `SwitchBot` constructor as follows:
258
264
259
265
```typescript
260
-
const switchbot =newSwitchBot();
266
+
const switchbot =newSwitchBot()
267
+
switchbot.startScan()
261
268
```
262
269
263
270
The `SwitchBot` constructor takes an argument optionally. It must be a hash object containing the properties as follows:
@@ -347,10 +354,10 @@ The discovery process was finished.
347
354
348
355
The `startScan()` method starts to scan advertising packets coming from devices. This method takes an argument which is a hash object containing the parameters as follows:
|`model`| String | Optional |`"H"`, `"T"`, `"c"`, `"g"` or `"j"`. If `"H"` is specified, this method will discover only Bots. If `"T"` is specified, this method will discover only Meters. If `"c"` is specified, this method will discover only Curtains. If `"g"` or `"j"` is specified, this method will discover only (US/JP) Plug Minis. |
353
-
|`id`| String | Optional | If this value is set, this method will discover only a device whose ID is as same as this value. The ID is identical to the MAC address. This value is case-insensitive, and colons are ignored. |
360
+
|`id`| String | Optional | If this value is set, this method will discover only a device whose ID is as same as this value. The ID is identical to the MAC address. This value is case-insensitive, and colons are ignored. |
354
361
355
362
Whenever a packet is received, the callback function set to the [`onadvertisement`](#Switchbot-onadvertisement-event-handler) property of the [`Switchbot`](#Switchbot-object) object will be called. When a packet is received, a hash object representing the packet will be passed to the callback function.
356
363
@@ -385,8 +392,9 @@ The code snippet above will output the result as follows:
385
392
serviceData: {
386
393
model: 'T',
387
394
modelName: 'WoSensorTH',
388
-
temperature: { c: 25.8, f: 78.4 },
389
-
fahrenheit: false,
395
+
celsius: 25.8,
396
+
fahrenheit: 78.4,
397
+
fahrenheit_mode: false,
390
398
humidity: 43,
391
399
battery: 100
392
400
}
@@ -855,6 +863,7 @@ switchbot
855
863
```
856
864
857
865
---
866
+
858
867
## `WoPlugMini` object
859
868
860
869
The `WoPlugMini ` object represents a PlugMini, which is created through the discovery process triggered by the [`Switchbot.discover()`](#Switchbot-discover-method) method.
@@ -882,6 +891,7 @@ If no connection is established with the device, this method automatically estab
882
891
---
883
892
884
893
---
894
+
885
895
## `WoSmartLock` object
886
896
887
897
The `WoSmartLock ` object represents a SmartLock, which is created through the discovery process triggered by the [`Switchbot.discover()`](#Switchbot-discover-method) method.
@@ -894,10 +904,10 @@ The `setKey()` method initialises the key information required for encrypted com
894
904
895
905
This must be set before any control commands are sent to the device. To obtain the key information you will need to use an external tool - see [`pySwitchbot`](https://github.com/Danielhiversen/pySwitchbot/tree/master?tab=readme-ov-file#obtaining-locks-encryption-key) project for an example script.
|`keyId`| String | unique2 character ID for the key. (e.g., `"ff"`) returned from the SwitchBot api for your device |
910
+
|`encryptionKey`| String | the unique encryption key returned from the SwitchBot api for your device |
901
911
902
912
### `lock()` method
903
913
@@ -923,7 +933,6 @@ The `info()` method retreieves state information from the SmartLock, This method
923
933
924
934
If no connection is established with the device, this method automatically establishes a connection with the device, then finally closes the connection. You don't have to call the [`connect()`](#SwitchbotDevice-connect-method) method in advance.
925
935
926
-
927
936
## Advertisement data
928
937
929
938
After the [`startScan()`](#startscan-method) method is invoked, the [`onadvertisement`](#Switchbot-onadvertisement-event-handler) event handler will be called whenever an advertising packet comes from the switchbot devices. An object containing the properties as follows will be passed to the event handler:
@@ -1136,16 +1145,16 @@ Example of the advertisement data:
0 commit comments