Skip to content

Commit 217d0a4

Browse files
committed
Released v0.0.3
1 parent 7ab7028 commit 217d0a4

File tree

5 files changed

+24
-11
lines changed

5 files changed

+24
-11
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 Futomi Hatano
3+
Copyright (c) 2019-2020 Futomi Hatano
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,9 @@ The `battery` is *experimental* for now. I'm not sure whether the value is corre
750750
---------------------------------------
751751
## <a id="Release-Note">Release Note</a>
752752

753+
* v0.0.3 (2020-02-10)
754+
* Now the characteristic UUID `0x2a00` (Device Name) is not mandatory. Some models of Bot don't seem to support the characteristic.
755+
* Fixed the bug that the `turnOn()` method returns an error if the "Light switch Add-on" is set to "Disabled" on the Bot.
753756
* v0.0.2 (2019-11-20)
754757
* First public release
755758

@@ -764,7 +767,7 @@ The `battery` is *experimental* for now. I'm not sure whether the value is corre
764767

765768
The MIT License (MIT)
766769

767-
Copyright (c) 2019 Futomi Hatano
770+
Copyright (c) 2019-2020 Futomi Hatano
768771

769772
Permission is hereby granted, free of charge, to any person obtaining a copy
770773
of this software and associated documentation files (the "Software"), to deal

lib/switchbot-device-wohand.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* ------------------------------------------------------------------
22
* node-linking - switchbot-device-wohand.js
33
*
4-
* Copyright (c) 2019, Futomi Hatano, All rights reserved.
4+
* Copyright (c) 2019-2020, Futomi Hatano, All rights reserved.
55
* Released under the MIT license
6-
* Date: 2019-11-20
6+
* Date: 2020-02-10
77
* ---------------------------------------------------------------- */
88
'use strict';
99
const SwitchbotDevice = require('./switchbot-device.js');
@@ -89,10 +89,11 @@ class SwitchbotDeviceWoHand extends SwitchbotDevice {
8989
return new Promise((resolve, reject) => {
9090
let req_buf = Buffer.from(bytes);
9191
this._command(req_buf).then((res_buf) => {
92-
if (res_buf.length === 3 && res_buf.readUInt8(0) === 0x01) {
92+
let code = res_buf.readUInt8(0);
93+
if (res_buf.length === 3 && (code === 0x01 || code === 0x05)) {
9394
resolve();
9495
} else {
95-
reject(new Error('The device returned an error: 0x' + hex));
96+
reject(new Error('The device returned an error: 0x' + res_buf.toString('hex')));
9697
}
9798
}).catch((error) => {
9899
reject(error);

lib/switchbot-device.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* ------------------------------------------------------------------
22
* node-linking - switchbot-device.js
33
*
4-
* Copyright (c) 2019, Futomi Hatano, All rights reserved.
4+
* Copyright (c) 2019-2020, Futomi Hatano, All rights reserved.
55
* Released under the MIT license
6-
* Date: 2019-11-20
6+
* Date: 2020-02-10
77
* ---------------------------------------------------------------- */
88
'use strict';
99
const parameterChecker = require('./parameter-checker.js');
@@ -188,11 +188,12 @@ class SwitchbotDevice {
188188
} else if (c.uuid === this._CHAR_UUID_NOTIFY) {
189189
char_notify = c;
190190
} else if (c.uuid === this._CHAR_UUID_DEVICE) {
191+
// Some models of Bot don't seem to support this characteristic UUID
191192
char_device = c;
192193
}
193194
});
194-
if (!(char_write && char_notify && char_device)) {
195-
reject(new Error('No characteristic was found'));
195+
if (!(char_write && char_notify)) {
196+
reject(new Error('No characteristic was found.'));
196197
return;
197198
}
198199

@@ -298,6 +299,10 @@ class SwitchbotDevice {
298299
return new Promise((resolve, reject) => {
299300
let name = '';
300301
this._connect().then(() => {
302+
if (!this._chars.device) {
303+
// Some models of Bot don't seem to support this characteristic UUID
304+
throw new Error('The device does not support the characteristic UUID 0x' + this._CHAR_UUID_DEVICE + '.');
305+
}
301306
return this._read(this._chars.device);
302307
}).then((buf) => {
303308
name = buf.toString('utf8');
@@ -336,6 +341,10 @@ class SwitchbotDevice {
336341

337342
let buf = Buffer.from(name, 'utf8');
338343
this._connect().then(() => {
344+
if (!this._chars.device) {
345+
// Some models of Bot don't seem to support this characteristic UUID
346+
throw new Error('The device does not support the characteristic UUID 0x' + this._CHAR_UUID_DEVICE + '.');
347+
}
339348
return this._write(this._chars.device, buf);
340349
}).then(() => {
341350
return this._disconnect();

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-switchbot",
3-
"version": "0.0.2",
3+
"version": "0.0.3",
44
"description": "The node-switchbot is a Node.js module which allows you to move your Switchbot (Bot)'s arm and to monitor the temperature/humidity from SwitchBot Thermometer & Hygrometer (Meter).",
55
"main": "./lib/switchbot.js",
66
"files": [

0 commit comments

Comments
 (0)