node-switchbot 1.4.2-beta.0 → 1.4.2-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -54,12 +54,17 @@ But some functionalities of this module were developed through trial and error.
54
54
  - [`close()` method](#close-method)
55
55
  - [`pause()` method](#pause-method)
56
56
  - [`runToPos()` method](#runtopos-method)
57
+ - [`SwitchbotDeviceWoPlugMini` object](#switchbotdevicewoplugmini-object)
58
+ - [`turnOn()` method](#turnon-method)
59
+ - [`turnOff()` method](#turnoff-method)
60
+ - [`toggle()` method](#toggle-method)
57
61
  - [Advertisement data](#advertisement-data)
58
62
  - [Bot (WoHand)](#bot-wohand)
59
63
  - [Meter (WoSensorTH)](#meter-wosensorth)
60
64
  - [Curtain (WoCurtain)](#curtain-wocurtain)
61
65
  - [Contact (WoContact)](#contact-wocontact)
62
66
  - [Motion (WoMotion)](#motion-womotion)
67
+ - [PlugMini (WoPlugMini)](#plugmini-woplugmini)
63
68
  - [Release Note](#release-note)
64
69
  - [References](#references)
65
70
  - [License](#license)
@@ -340,7 +345,7 @@ The `startScan()` method starts to scan advertising packets coming from devices.
340
345
 
341
346
  | Property | Type | Required | Description |
342
347
  | :------- | :----- | :------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
343
- | `model` | String | Optional | `"H"`, `"T"` or `"c"`. 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. |
348
+ | `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. |
344
349
  | `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. |
345
350
 
346
351
  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.
@@ -835,6 +840,31 @@ switchbot
835
840
  });
836
841
  ```
837
842
 
843
+ ---
844
+ ## `SwitchbotDeviceWoPlugMini` object
845
+
846
+ The `SwitchbotDeviceWoPlugMini ` object represents a PlugMini, which is created through the discovery process triggered by the [`Switchbot.discover()`](#Switchbot-discover-method) method.
847
+
848
+ Actually, the `SwitchbotDeviceWoPlugMini ` 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.
849
+
850
+ ### `turnOn()` method
851
+
852
+ The `turnOn()` method sends a turn-on command to the PlugMini. This method returns a `Promise` object. A `boolean` value indicating whether the PlugMini is on (`true`), is passed to the `resolve()` method of the Promise.
853
+
854
+ 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.
855
+
856
+ ### `turnOff()` method
857
+
858
+ The `turnOff()` method sends a turn-off command to the PlugMini. This method returns a `Promise` object. A `boolean` value indicating whether the PlugMini is off (`false`), is passed to the `resolve()` method of the Promise.
859
+
860
+ 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.
861
+
862
+ ### `toggle()` method
863
+
864
+ The `toggle()` method sends a toggle command to the PlugMini, toggling between the on and off state. This method returns a `Promise` object. A `boolean` value indicating whether the PlugMini is on (`true`) or off (`false`), is passed to the `resolve()` method of the Promise.
865
+
866
+ 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.
867
+
838
868
  ---
839
869
 
840
870
  ## Advertisement data
@@ -1023,6 +1053,42 @@ Structure of the `serviceData`:
1023
1053
  | `battery` | Integer | This value indicates the battery level (`1-100`, `%`). |
1024
1054
  | `lightLevel` | String | This value indicates the light level (`dark`, `bright`). |
1025
1055
 
1056
+ ### PlugMini (WoPlugMini)
1057
+
1058
+ Example of the advertisement data:
1059
+
1060
+ ```json
1061
+ {
1062
+ "id": "cd2409ea3e9441f87d4580e0380a62bf",
1063
+ "address": "60:55:f9:35:f6:a6",
1064
+ "rssi": -50,
1065
+ "serviceData": {
1066
+ "model": "j",
1067
+ "modelName": "WoPlugMini",
1068
+ "state": "off",
1069
+ "delay": false,
1070
+ "timer": false,
1071
+ "syncUtcTime": true,
1072
+ "wifiRssi": 48,
1073
+ "overload": false,
1074
+ "currentPower": 0
1075
+ }
1076
+ }
1077
+ ```
1078
+
1079
+ Structure of the `serviceData`:
1080
+
1081
+ | Property | Type | Description |
1082
+ | :------------ | :------ | :---------------------------------------------------------------------------------- |
1083
+ | `model` | String | This value is always `"j"` or `"g"`, which means "PlugMini" (JP or US). |
1084
+ | `modelName` | String | This value is always `"WoPlugMini"`, which means "PlugMini". |
1085
+ | `state ` | Boolean | This value indicates whether the plug mini is turned on (`true`) or not (`false`). |
1086
+ | `delay` | Boolean | Indicates whether a delay is present. |
1087
+ | `timer` | Boolean | Indicates whether a timer is present. |
1088
+ | `syncUtcTime` | boolean | Indicates whether the UTC time has been synchronized. |
1089
+ | `overload` | boolean | Indicates whether the Plug Mini is overloaded, more than 15A current overload. |
1090
+ | `currentPower`| Float | Current power consumption in Watts. |
1091
+
1026
1092
  ---
1027
1093
 
1028
1094
  ## References
@@ -75,7 +75,7 @@ class SwitchbotAdvertising {
75
75
  !Buffer.isBuffer(manufacturerData) ||
76
76
  manufacturerData.length < 3;
77
77
 
78
- if (bufIsInvalid && manufacturerDataIsInvalid) {
78
+ if (bufIsInvalid || manufacturerDataIsInvalid) {
79
79
  return null;
80
80
  }
81
81
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-switchbot",
3
- "version": "1.4.2-beta.0",
3
+ "version": "1.4.2-beta.2",
4
4
  "description": "The node-switchbot is a Node.js module which allows you to move your Switchbot (Bot)'s arm and Switchbot Curtain(Curtain), also monitor the temperature/humidity from SwitchBot Thermometer & Hygrometer (Meter).",
5
5
  "main": "./lib/switchbot.js",
6
6
  "files": [
@@ -37,6 +37,6 @@
37
37
  "@abandonware/noble": "^1.9.2-15"
38
38
  },
39
39
  "devDependencies": {
40
- "npm-check-updates": "^16.0.6"
40
+ "npm-check-updates": "^16.2.1"
41
41
  }
42
42
  }