Skip to content

Commit 5291057

Browse files
cocoaboxcocoabox
andauthored
Documentation for WoPlugMini (#145)
* added PlugMini documentation to README.md * minor fix to readme Co-authored-by: cocoabox <[email protected]>
1 parent 4007f2f commit 5291057

File tree

1 file changed

+67
-1
lines changed

1 file changed

+67
-1
lines changed

README.md

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,17 @@ But some functionalities of this module were developed through trial and error.
5454
- [`close()` method](#close-method)
5555
- [`pause()` method](#pause-method)
5656
- [`runToPos()` method](#runtopos-method)
57+
- [`SwitchbotDeviceWoPlugMini` object](#switchbotdevicewoplugmini-object)
58+
- [`turnOn()` method](#turnon-method)
59+
- [`turnOff()` method](#turnoff-method)
60+
- [`toggle()` method](#toggle-method)
5761
- [Advertisement data](#advertisement-data)
5862
- [Bot (WoHand)](#bot-wohand)
5963
- [Meter (WoSensorTH)](#meter-wosensorth)
6064
- [Curtain (WoCurtain)](#curtain-wocurtain)
6165
- [Contact (WoContact)](#contact-wocontact)
6266
- [Motion (WoMotion)](#motion-womotion)
67+
- [PlugMini (WoPlugMini)](#plugmini-woplugmini)
6368
- [Release Note](#release-note)
6469
- [References](#references)
6570
- [License](#license)
@@ -340,7 +345,7 @@ The `startScan()` method starts to scan advertising packets coming from devices.
340345

341346
| Property | Type | Required | Description |
342347
| :------- | :----- | :------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
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. |
344349
| `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. |
345350

346351
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
835840
});
836841
```
837842

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+
838868
---
839869

840870
## Advertisement data
@@ -1023,6 +1053,42 @@ Structure of the `serviceData`:
10231053
| `battery` | Integer | This value indicates the battery level (`1-100`, `%`). |
10241054
| `lightLevel` | String | This value indicates the light level (`dark`, `bright`). |
10251055

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+
10261092
---
10271093

10281094
## References

0 commit comments

Comments
 (0)