Skip to content

Commit ce2d3f1

Browse files
committed
Released v0.0.4
1 parent 217d0a4 commit ce2d3f1

File tree

4 files changed

+27
-21
lines changed

4 files changed

+27
-21
lines changed

README.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -572,13 +572,13 @@ The `turnOn()` method sends a turn-on command to the Bot. This method returns a
572572

573573
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.
574574

575-
When the Bot receives this command, the Bot's arm will be put down (stretched) or put up (retracted) depending on the settings.
575+
When the Bot receives this command, the Bot's arm will be put down (stretched) or put up (retracted) depending on the mode setting.
576576

577-
Light switch Add-on | Inverse the on/off direction | Physical position of the arm
577+
Mode | Inverse the on/off direction | Physical position of the arm
578578
:-------------------|:-----------------------------|:----------------------------
579-
Disabled | N/A | Down (stretched), then Up (retracted)
580-
Enabled | Disabled | Down (stretched)
581-
Enabled | Enabled | Up (retracted)
579+
Press mode | N/A | Down (stretched), then Up (retracted)
580+
Switch mode | Disabled | Down (stretched)
581+
  | Enabled | Up (retracted)
582582

583583
```javascript
584584
switchbot.discover({ model: 'H', quick: true }).then((device_list) => {
@@ -596,13 +596,13 @@ The `turnOff()` method sends a turn-off command to the Bot. This method returns
596596

597597
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.
598598

599-
When the Bot receives this command, the Bot's arm will be put down (stretched) or put up (retracted) depending on the settings.
599+
When the Bot receives this command, the Bot's arm will be put down (stretched) or put up (retracted) depending on the mode setting.
600600

601-
Light switch Add-on | Inverse the on/off direction | Physical position of the arm
601+
Mode | Inverse the on/off direction | Physical position of the arm
602602
:-------------------|:-----------------------------|:----------------------------
603-
Disabled | N/A | Down (stretched), then Up (retracted)
604-
Enabled | Disabled | Up (retracted)
605-
Enabled | Enabled | Down (stretched)
603+
Press mode | N/A | Down (stretched), then Up (retracted)
604+
Switch mode | Disabled | Up (retracted)
605+
  | Enabled | Down (stretched)
606606

607607
```javascript
608608
switchbot.discover({ model: 'H', quick: true }).then((device_list) => {
@@ -620,7 +620,7 @@ The `down()` method sends a down command to the Bot. This method returns a `Prom
620620

621621
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.
622622

623-
When the Bot receives this command, the Bot's arm will be put down (stretched) regardless of the settings.
623+
When the Bot receives this command, the Bot's arm will be put down (stretched) regardless of the mode setting.
624624

625625
```javascript
626626
switchbot.discover({ model: 'H', quick: true }).then((device_list) => {
@@ -638,7 +638,7 @@ The `up()` method sends an up command to the Bot. This method returns a `Promise
638638

639639
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.
640640

641-
When the Bot receives this command, the Bot's arm will be put up (retracted) regardless of the settings.
641+
When the Bot receives this command, the Bot's arm will be put up (retracted) regardless of the mode setting.
642642

643643
```javascript
644644
switchbot.discover({ model: 'H', quick: true }).then((device_list) => {
@@ -689,13 +689,13 @@ Property | Type | Description
689689
:-----------|:--------|:-----------
690690
`model` | String | This value is always `"H"`, which means "Bot (WoHand)".
691691
`modelName` | String | This value is always `"WoHand"`, which means "Bot".
692-
`mode` | Boolean | This indicates whether the light switch Add-on is used (`true`) or not (`false`)
692+
`mode` | Boolean | This indicates the mode setting. When the mode is "Switch mode", this value is `true`. When the mode is "Press mode", this value is `false`.
693693
`state` | Boolean | This value indicates whether the switch status is ON or OFF.
694694
`battery` | Integer | (**experimental**) This value indicates the battery level (`%`).
695695

696696
The `mode` can be changed only using the official smartphone app. The node-switchbot does not support changing the mode because the BLE protocol is non-public.
697697

698-
If the `mode` is `false`, which means the light switch Add-on is not used, the `state` is always `false`. If the `mode` is `true`, which means the light switch Add-on is used, the `state` represents the logical state (ON or OFF). Note that it does *not* mean the physical arm position. The physical arm position depends on the setting "Inverse the on/off direction" on the official smartphone app.
698+
If the `mode` is `false`, which means the "Press mode" is selected, the `state` is always `false`. If the `mode` is `true`, which means the "Switch mode" is selected, the `state` represents the logical state (ON or OFF). Note that it does *not* mean the physical arm position. The physical arm position depends on the setting "Inverse the on/off direction" on the official smartphone app.
699699

700700
"Inverse the on/off direction" | Value of the `state` | Logical state | Physical arm position
701701
:------------------------------|:---------------------|:--------------|:------------
@@ -750,9 +750,11 @@ 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.4 (2020-02-11)
754+
* Fixed the bug that temperature value lower than 0 degC could not be handled. (Thanks to [@musimasami](https://github.com/futomi/node-switchbot/issues/2))
753755
* 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.
756+
* 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/futomi/node-switchbot/issues/1))
757+
* Fixed the bug that the `turnOn()` method returns an error if the "Press mode" is selected on the Bot.
756758
* v0.0.2 (2019-11-20)
757759
* First public release
758760

lib/switchbot-advertising.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2019, Futomi Hatano, All rights reserved.
55
* Released under the MIT license
6-
* Date: 2019-11-18
6+
* Date: 2020-02-11
77
* ---------------------------------------------------------------- */
88
'use strict';
99

@@ -111,12 +111,16 @@ class SwitchbotAdvertising {
111111
}
112112

113113
_parseServiceDataForWoSensorTH(buf) {
114+
if (buf.length !== 6) {
115+
return null;
116+
}
114117
let byte2 = buf.readUInt8(2);
115118
let byte3 = buf.readUInt8(3);
116119
let byte4 = buf.readUInt8(4);
117120
let byte5 = buf.readUInt8(5);
118121

119-
let temp_c = (byte4 - 128) + (byte3 / 10);
122+
let temp_sign = (byte4 & 0b10000000) ? 1 : -1;
123+
let temp_c = temp_sign * ((byte4 & 0b01111111) + (byte3 / 10));
120124
let temp_f = (temp_c * 9 / 5) + 32;
121125
temp_f = Math.round(temp_f * 10) / 10;
122126

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.3",
3+
"version": "0.0.4",
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": [

test/scan.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ switchbot.onadvertisement = (ad) => {
99

1010
// Start to scan advertising packets
1111
switchbot.startScan({
12-
model: 'H',
13-
//model: 'T',
12+
//model: 'H',
13+
model: 'T',
1414
//id: 'cb:4e:b9:03:c9:6d',
1515
}).then(() => {
1616
// Wait for 30 seconds

0 commit comments

Comments
 (0)