Skip to content

Commit 88fce02

Browse files
v2.1.0 (#243)
## [2.1.0](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v2.1.0) (2024-05-14) ### What's Changed - Add Full Switchbot Lock Support [#232](#232), Thanks [@brozef](https://github.com/brozef) - Fix TypeScript issues & warnings [#239](#239) [#240](#240) [#241](#241), Thanks [@dnicolson](https://github.com/dnicolson) - Update Noble [#242](#242), Thanks [@dnicolson](https://github.com/dnicolson) dnicolson - Housekeeping and update dependencies **Full Changelog**: v2.0.3...v2.1.0
1 parent c0a3668 commit 88fce02

17 files changed

+640
-346
lines changed

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,6 @@
7878
"@typescript-eslint/explicit-function-return-type": "off",
7979
"@typescript-eslint/no-non-null-assertion": "off",
8080
"@typescript-eslint/explicit-module-boundary-types": "off",
81-
"@typescript-eslint/no-explicit-any": "off"
81+
"@typescript-eslint/no-explicit-any": "error"
8282
}
8383
}

CHANGELOG.md

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

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

5+
## [2.1.0](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v2.1.0) (2024-05-14)
6+
7+
### What's Changed
8+
- Add Full Switchbot Lock Support [#232](https://github.com/OpenWonderLabs/node-switchbot/pull/232), Thanks [@brozef](https://github.com/brozef)
9+
- Fix TypeScript issues & warnings [#239](https://github.com/OpenWonderLabs/node-switchbot/pull/239) [#240](https://github.com/OpenWonderLabs/node-switchbot/pull/240) [#241](https://github.com/OpenWonderLabs/node-switchbot/pull/241), Thanks [@dnicolson](https://github.com/dnicolson)
10+
- Update Noble [#242](https://github.com/OpenWonderLabs/node-switchbot/pull/242), Thanks [@dnicolson](https://github.com/dnicolson)
11+
dnicolson
12+
- Housekeeping and update dependencies
13+
14+
**Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v2.0.3...v2.1.0
15+
516
## [2.0.3](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v2.0.3) (2024-02-11)
617

718
### What's Changed

README.md

Lines changed: 99 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</span>
99

1010
The node-switchbot is a Node.js module which allows you to move your [Switchbot (Bot)'s](https://www.switch-bot.com/bot) arm
11-
and [Switchbot Curtain](https://www.switch-bot.com/products/switchbot-curtain),
11+
and [Switchbot Curtain](https://www.switch-bot.com/products/switchbot-curtain), operate your [Switchbot Lock](https://www.switch-bot.com/products/switchbot-lock),
1212
also monitor the temperature/humidity from [SwitchBot Thermometer & Hygrometer (Meter)](https://www.switch-bot.com/meter)
1313
as well as the status from [SwitchBot Motion Sensor](https://www.switch-bot.com/products/motion-sensor)
1414
and [SwitchBot Contact Sensor](https://www.switch-bot.com/products/contact-sensor)
@@ -43,21 +43,26 @@ But some functionalities of this module were developed through trial and error.
4343
- [`disconnect()` method](#disconnect-method)
4444
- [`onconnect` event handler](#onconnect-event-handler)
4545
- [`ondisconnect` event handler](#ondisconnect-event-handler)
46-
- [`WoHand` object](#switchbotdevicewohand-object)
46+
- [`WoHand` object](#wohand-object)
4747
- [`press()` method](#press-method)
4848
- [`turnOn()` method](#turnon-method)
4949
- [`turnOff()` method](#turnoff-method)
5050
- [`down()` method](#down-method)
5151
- [`up()` method](#up-method)
52-
- [`WoCurtain` object](#switchbotdevicewocurtain-object)
52+
- [`WoCurtain` object](#wocurtain-object)
5353
- [`open()` method](#open-method)
5454
- [`close()` method](#close-method)
5555
- [`pause()` method](#pause-method)
5656
- [`runToPos()` method](#runtopos-method)
57-
- [`WoPlugMini` object](#switchbotdevicewoplugmini-object)
57+
- [`WoPlugMini` object](#woplugmini-object)
5858
- [`turnOn()` method](#turnon-method)
5959
- [`turnOff()` method](#turnoff-method)
6060
- [`toggle()` method](#toggle-method)
61+
- [`WoSmartLock` object](#wosmartlock-object)
62+
- [`lock()` method](#lock-method)
63+
- [`unlock()` method](#unlock-method)
64+
- [`unlock_no_unlatch()` method](#unlock_no_unlatch-method)
65+
- [`info()` method](#info-method)
6166
- [Advertisement data](#advertisement-data)
6267
- [Bot (WoHand)](#bot-wohand)
6368
- [Meter (WoSensorTH)](#meter-wosensorth)
@@ -876,6 +881,49 @@ If no connection is established with the device, this method automatically estab
876881

877882
---
878883

884+
---
885+
## `WoSmartLock` object
886+
887+
The `WoSmartLock ` object represents a SmartLock, which is created through the discovery process triggered by the [`Switchbot.discover()`](#Switchbot-discover-method) method.
888+
889+
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.
890+
891+
### `setKey()` method
892+
893+
The `setKey()` method initialises the key information required for encrypted communication with the SmartLock
894+
895+
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.
896+
897+
| Property | Type | Description |
898+
| :--------------- | :------ | :------------------------------------------------------------------------------------------------------------------------------------- |
899+
| `keyId` | String | unique2 character ID for the key. (e.g., `"ff"`) returned from the SwitchBot api for your device |
900+
| `encryptionKey` | String | the unique encryption key returned from the SwitchBot api for your device |
901+
902+
### `lock()` method
903+
904+
The `lock()` method sends a lock command to the SmartLock. This method returns a `Promise` object. A `boolean` value indicating whether the SmartLock is locked (`true`), is passed to the `resolve()` method of the Promise.
905+
906+
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.
907+
908+
### `unlock()` method
909+
910+
The `unlock()` method sends an unlock command to the SmartLock. This method returns a `Promise` object. A `boolean` value indicating whether the SmartLock is locked (`false`), is passed to the `resolve()` method of the Promise.
911+
912+
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.
913+
914+
### `unlockNoUnlatch()` method
915+
916+
The `unlockNoUnlatch()` method sends a partial unlock command to the SmartLock, unlocking without the full unlatch.
917+
918+
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.
919+
920+
### `info()` method
921+
922+
The `info()` method retreieves state information from the SmartLock, This method returns a `Promise` object. An `object` value indicating with the state infor, is passed to the `resolve()` method of the Promise.
923+
924+
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+
926+
879927
## Advertisement data
880928

881929
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:
@@ -1101,6 +1149,53 @@ Structure of the `serviceData`:
11011149

11021150
---
11031151

1152+
### SmartLock (WoSmartLock)
1153+
1154+
Example of the advertisement data:
1155+
1156+
```json
1157+
{
1158+
"id: 'd30864110b8c',
1159+
"address": 'd3:08:64:11:0b:8c',
1160+
"rssi": -52,
1161+
"serviceData": {
1162+
"model": "o",
1163+
"modelName": "WoSmartLock",
1164+
"battery": 100,
1165+
"calibration": true,
1166+
"status": "LOCKED",
1167+
"update_from_secondary_lock": false,
1168+
"door_open": false,
1169+
"double_lock_mode": false,
1170+
"unclosed_alarm": false,
1171+
"unlocked_alarm": false,
1172+
"auto_lock_paused": false
1173+
}
1174+
}
1175+
1176+
```
1177+
1178+
Structure of the `serviceData`:
1179+
1180+
| Property | Type | Description |
1181+
| :---------------------------- | :------ | :---------------------------------------------------------------------------------- |
1182+
| `model` | String | This value is `"o"`, which means "Lock (WoSmartLock)". |
1183+
| `modelName` | String | This value is always `"WoSmartLock"`, which means "Lock". |
1184+
| `battery` | Integer | This value indicates the battery level (`1-100`, `%`). |
1185+
| `calibration` | Boolean | This value indicates the calibration status (`true` or `false`). |
1186+
| `status` | String | This value indicates the current locked state. Possible values: |
1187+
| | | `"LOCKED"`, `"UNLOCKED"`, `"LOCKING"`, `"UNLOCKING"` |
1188+
| | | `"LOCKING_STOP"`, `"UNLOCKING_STOP"` (stuck when locking or unlocking respectively) |
1189+
| | | `"NOT_FULLY_LOCKED"` (eu model only), `"UNKNOWN"` (fallback: must be some error) |
1190+
| `update_from_secondary_lock` | Boolean | ?? |
1191+
| `door_open` | Boolean | door open status - whether the door is not detecting the sensor magnet |
1192+
| `double_lock_mode` | Boolean | dual lock mode enabled status - two locks working simultaneously |
1193+
| `unclosed_alarm` | Boolean | enabled status for door ajar alarm function |
1194+
| `unlocked_alarm` | Boolean | whether the alarm function is enabled for door left unlocked |
1195+
| `auto_lock_paused` | Boolean | auto lock mode paused |
1196+
| `night_latch` | Boolean | night latch mode enabled (eu firmware only) |
1197+
1198+
11041199
## References
11051200

11061201
- [Switchbot official global site](https://www.switch-bot.com/)

0 commit comments

Comments
 (0)