Skip to content

Commit 122b974

Browse files
committed
v3.0.1
## [3.0.1](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v3.0.1) (2024-10-05) ### What's Changed - Hot Fix for `baseURL` which is used for sending `OpenAPI` commands - Housekeeping and update dependencies **Full Changelog**: v3.0.0...v3.0.1
1 parent 6087873 commit 122b974

File tree

155 files changed

+417
-341
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+417
-341
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ jobs:
3232
Version `v${{ needs.publish.outputs.NPM_VERSION }}`
3333
url: "https://github.com/homebridge/camera-utils/releases/tag/v${{ needs.publish.outputs.NPM_VERSION }}"
3434
secrets:
35-
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL_BETA || secrets.DISCORD_WEBHOOK_URL_LATEST }}
35+
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL_LATEST }}

BLE.md

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ To use the `SwitchBotBLE` class in `node-switchbot`, you need to import it and c
7575
import { SwitchBotBLE } from 'node-switchbot'
7676

7777
// Example usage
78-
const switchbotBLE = new SwitchBotBLE()
78+
const switchBotBLE = new SwitchBotBLE()
7979

8080
try {
81-
await switchbotBLE.startScan()
81+
await switchBotBLE.startScan()
8282
} catch (e: any) {
8383
console.error(`Failed to start BLE scanning. Error:${e}`)
8484
}
@@ -100,7 +100,7 @@ The sample code below shows how to pass a `Noble` object to the `Switchbot` cons
100100
// Create a Noble object
101101
const noble = require('@stoprocent/noble');
102102

103-
const switchbotBLE = new SwitchBotBLE({ 'noble': Noble })
103+
const switchBotBLE = new SwitchBotBLE({ 'noble': Noble })
104104
```
105105

106106
In the code snippet above, the variable `switchbot` is an `SwitchBotBLE` object. The `SwitchBotBLE` object has a lot of methods as described in sections below.
@@ -119,7 +119,7 @@ The `discover` method finds devices. This method returns a `Promise` object. Thi
119119
In the code snippet below, no parameter is passed to the method:
120120

121121
```Typescript
122-
switchbotBLE.discover().then((device_list) => {
122+
switchBotBLE.discover().then((device_list) => {
123123
// Do something...
124124
}).catch((error) => {
125125
console.error(error);
@@ -131,7 +131,7 @@ If no parameter is passed to the method as the code above, an `Array` object wil
131131
If you want a quick response, you can set the `quick` property to `true`.
132132

133133
```Typescript
134-
switchbotBLE.discover({
134+
switchBotBLE.discover({
135135
duration: 5000,
136136
quick: true
137137
}).then((device_list) => {
@@ -148,11 +148,11 @@ As the `quick` property is set to `true`, the `resolve()` function will be calle
148148
The `ondiscover` property on the [`Switchbot`](#Switchbot-object) object is an event handler called whenever a device is newly found in the discovery process. A [`SwitchbotDevice`](#SwitchbotDevice-object) object is passed to the callback function set to the `ondiscover` property.
149149

150150
```Typescript
151-
switchbotBLE.ondiscover = (device) => {
151+
switchBotBLE.ondiscover = (device) => {
152152
console.log(device.id + ' (' + device.modelName + ')');
153153
};
154154

155-
switchbotBLE.discover().then(() => {
155+
switchBotBLE.discover().then(() => {
156156
console.log('The discovery process was finished.');
157157
}).catch((error) => {
158158
console.error(error);
@@ -180,19 +180,19 @@ Whenever a packet is received, the callback function set to the [`onadvertisemen
180180

181181
```Typescript
182182
// Set a callback function called when a packet is received
183-
switchbotBLE.onadvertisement = (ad) => {
183+
switchBotBLE.onadvertisement = (ad) => {
184184
console.log(ad);
185185
};
186186

187187
// Start to scan advertising packets
188-
switchbotBLE.startScan({
188+
switchBotBLE.startScan({
189189
id: 'cb:4e:b9:03:c9:6d',
190190
}).then(() => {
191191
// Wait for 30 seconds
192-
return switchbotBLE.wait(30000);
192+
return switchBotBLE.wait(30000);
193193
}).then(() => {
194194
// Stop to scan
195-
switchbotBLE.stopScan();
195+
switchBotBLE.stopScan();
196196
process.exit();
197197
}).catch((error) => {
198198
console.error(error);
@@ -226,7 +226,7 @@ The `serviceData` property depends on the model of the device. See the section "
226226
If a callback function is set to the `onadvertisement` property, the callback function will be called whenever an advertising packet is received from a device during the scan is active (from the moment when the [`startScan()`](#startscan-method) method is called, to the moment when the [`stopScan()`](#Switchbot-stopScan-method) method is called).
227227

228228
```typescript
229-
switchbotBLE.onadvertisement = async (ad: any) => {
229+
switchBotBLE.onadvertisement = async (ad: any) => {
230230
try {
231231
this.bleEventHandler[ad.address]?.(ad.serviceData)
232232
} catch (e: any) {
@@ -243,7 +243,7 @@ The `stopScan()` method stops to scan advertising packets coming from devices. T
243243

244244
```typescript
245245
try {
246-
switchbotBLE.stopScan()
246+
switchBotBLE.stopScan()
247247
console.log('Stopped BLE scanning to close listening.')
248248
} catch (e: any) {
249249
console.error(`Failed to stop BLE scanning, error:${e.message}`)
@@ -257,12 +257,12 @@ The `wait()` method waits for the specified milliseconds. This method takes an i
257257
This method has nothing to do with Switchbot devices. It's just a utility method. See the section "[Quick Start](#Quick-Start)" for details of the usage of this method.
258258

259259
```typescript
260-
await switchbotBLE.wait(1000)
260+
await switchBotBLE.wait(1000)
261261
```
262262

263263
### `SwitchBotDevice` Object
264264

265-
The `SwitchbotDevice` object represents a Switchbot device (Bot, Meter, Curtain, Contact or Motion), which is created through the discovery process triggered by the [`switchbotBLE.discover()`](#Switchbot-discover-method) method.
265+
The `SwitchbotDevice` object represents a Switchbot device (Bot, Meter, Curtain, Contact or Motion), which is created through the discovery process triggered by the [`switchBotBLE.discover()`](#discover-method) method.
266266

267267
Actually, the `SwitchbotDevice` object is a super class of the [`WoHand`](#SwitchbotDeviceWoHand-object) and `WoSensorTH` objects. The [`WoHand`](#SwitchbotDeviceWoHand-object) object represents a Bot, the `WoSensorTH` object represents a Meter.
268268

@@ -367,7 +367,7 @@ switchbot
367367
})
368368
.then(() => {
369369
console.log("Waiting for 5 seconds...");
370-
return switchbotBLE.wait(5000);
370+
return switchBotBLE.wait(5000);
371371
})
372372
.then(() => {
373373
console.log("Putting the arm up...");
@@ -461,7 +461,7 @@ The `ondisconnect` event handler will be called when the connection with the dev
461461

462462
### `WoHand` Object
463463

464-
The `WoHand` object represents a Bot, which is created through the discovery process triggered by the [`switchbotBLE.discover()`](#Switchbot-discover-method) method.
464+
The `WoHand` object represents a Bot, which is created through the discovery process triggered by the [`switchBotBLE.discover()`](#discover-method) method.
465465

466466
Actually, the `WoHand` is an object inherited from the [`SwitchbotDevice`](#SwitchbotDevice-object). You can use not only the method described in this section but also the properties and methods implemented in the [`SwitchbotDevice`](#SwitchbotDevice-object) object.
467467

@@ -589,7 +589,7 @@ switchbot
589589

590590
### `WoCurtain` Object
591591

592-
The `WoCurtain` object represents a Curtain, which is created through the discovery process triggered by the [`switchbotBLE.discover()`](#Switchbot-discover-method) method.
592+
The `WoCurtain` object represents a Curtain, which is created through the discovery process triggered by the [`switchBotBLE.discover()`](#discover-method) method.
593593

594594
Actually, the `WoCurtain` is an object inherited from the [`SwitchbotDevice`](#SwitchbotDevice-object). You can use not only the method described in this section but also the properties and methods implemented in the [`SwitchbotDevice`](#SwitchbotDevice-object) object.
595595

@@ -698,7 +698,7 @@ switchbot
698698

699699
### `WoPlugMini` Object
700700

701-
The `WoPlugMini ` object represents a PlugMini, which is created through the discovery process triggered by the [`switchbotBLE.discover()`](#Switchbot-discover-method) method.
701+
The `WoPlugMini ` object represents a PlugMini, which is created through the discovery process triggered by the [`switchBotBLE.discover()`](#discover-method) method.
702702

703703
Actually, the `WoPlugMini ` is an object inherited from the [`SwitchbotDevice`](#SwitchbotDevice-object). You can use not only the method described in this section but also the properties and methods implemented in the [`SwitchbotDevice`](#SwitchbotDevice-object) object.
704704

@@ -722,7 +722,7 @@ If no connection is established with the device, this method automatically estab
722722

723723
### `WoSmartLock` Object
724724

725-
The `WoSmartLock ` object represents a SmartLock, which is created through the discovery process triggered by the [`switchbotBLE.discover()`](#Switchbot-discover-method) method.
725+
The `WoSmartLock ` object represents a SmartLock, which is created through the discovery process triggered by the [`switchBotBLE.discover()`](#discover-method) method.
726726

727727
Actually, the `WoSmartLock ` is an object inherited from the [`SwitchbotDevice`](#SwitchbotDevice-object). You can use not only the method described in this section but also the properties and methods implemented in the [`SwitchbotDevice`](#SwitchbotDevice-object) object.
728728

@@ -769,19 +769,19 @@ After the [`startScan()`](#startscan-method) method is invoked, the [`onadvertis
769769
// Load the node-switchbot and get a `Switchbot` constructor object
770770
import { SwitchBotBLE } from 'node-switchbot';
771771
// Create a `Switchbot` object
772-
const switchbotBLE = new SwitchBotBLE();
772+
const switchBotBLE = new SwitchBotBLE();
773773

774774
(async () => {
775775
// Start to monitor advertisement packets
776-
await switchbotBLE.startScan();
776+
await switchBotBLE.startScan();
777777
// Set an event handler
778-
switchbotBLE.onadvertisement = (ad) => {
778+
switchBotBLE.onadvertisement = (ad) => {
779779
console.log(JSON.stringify(ad, null, ' '));
780780
};
781781
// Wait 10 seconds
782-
await switchbotBLE.wait(10000);
782+
await switchBotBLE.wait(10000);
783783
// Stop to monitor
784-
switchbotBLE.stopScan();
784+
switchBotBLE.stopScan();
785785
process.exit();
786786
})();
787787
```
@@ -1062,11 +1062,11 @@ This sample discovers a Bot (WoHand), then put the Bot's arm down, finally put i
10621062
// Load the node-switchbot and get a `Switchbot` constructor object
10631063
import { SwitchBotBLE } from 'node-switchbot';
10641064
// Create a `Switchbot` object
1065-
const switchbotBLE = new SwitchBotBLE();
1065+
const switchBotBLE = new SwitchBotBLE();
10661066

10671067
(async () => {
10681068
// Find a Bot (WoHand)
1069-
const bot_list = await switchbotBLE.discover({ model: "H", quick: true });
1069+
const bot_list = await switchBotBLE.discover({ model: "H", quick: true });
10701070
if (bot_list.length === 0) {
10711071
throw new Error("No device was found.");
10721072
}
@@ -1075,14 +1075,14 @@ const switchbotBLE = new SwitchBotBLE();
10751075
// Put the Bot's arm down (stretch the arm)
10761076
await device.down();
10771077
// Wait for 5 seconds
1078-
await switchbotBLE.wait(5000);
1078+
await switchBotBLE.wait(5000);
10791079
// Put the Bot's arm up (retract the arm)
10801080
await device.up();
10811081
process.exit();
10821082
})();
10831083
```
10841084

1085-
In order to manipulate the arm of your Bot, you have to discover your Bot using the [`discover()`](#Switchbot-discover-method) method. The object `{ model: 'H' }` passed to the method means that only Bots will be discovered. That is, Meters will be ignored.
1085+
In order to manipulate the arm of your Bot, you have to discover your Bot using the [`discover()`](#discover-method) method. The object `{ model: 'H' }` passed to the method means that only Bots will be discovered. That is, Meters will be ignored.
10861086

10871087
In this code, you can get a [`WoHand`](#SwitchbotDeviceWoHand-object) object representing the found Bot. Using the [`down()`](#SwitchbotDeviceWoHand-down-method) and [`up()`](#SwitchbotDeviceWoHand-up-method) methods of the object, you can move the arm. In addition to these methods, you can use the [`press()`](#SwitchbotDeviceWoHand-press-method), [`turnOn()`](#SwitchbotDeviceWoHand-turnOn-method), and [`turnOff()`](#SwitchbotDeviceWoHand-turnOff-method) methods as well.
10881088

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/)
44

5+
## [3.0.1](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v3.0.1) (2024-10-05)
6+
7+
### What's Changed
8+
- Hot Fix for `baseURL` which is used for sending `OpenAPI` commands
9+
- Housekeeping and update dependencies
10+
11+
**Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v3.0.0...v3.0.1
12+
513
## [3.0.0](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v3.0.0) (2024-10-05)
614

715
### What's Changed

docs/assets/navigation.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)