Skip to content

Commit

Permalink
Tweaking documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
aholstenson committed Apr 17, 2017
1 parent 16f4b03 commit ced776f
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 9 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# miIO Device Library

This is a small library for controlling Mi Home devices that implement the miIO
protocol, such as the Mi Air Purifier, Mi Robot Vacuum and Mi Smart Socket.
Control Mi Home devices that implement the miIO protocol, such as the
Mi Air Purifier, Mi Robot Vacuum and Mi Smart Socket.

This library requires at least Node 6.0.0.

Expand Down Expand Up @@ -65,6 +65,20 @@ device.on('propertyChanged', e => console.log(e.property, e.oldValue, e.value));
device.on('action', e => console.log('Action performed:', e.id));
```

Use capabilities if you want to support different models easily:

```javascript
if(device.hasCapability('temperature')) {
console.log(device.temperature);
}

if(device.hasCapability('power')) {
device.setPower(false)
.then(console.log)
.catch(console.error);
}
```

If you are done with the device call `destroy` to stop all network traffic:

```javascript
Expand Down
6 changes: 3 additions & 3 deletions docs/devices/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ column can be one of the following:
* Good - most of the functionality is available including some more advanced features such as settings
* Excellent - as close to complete support as possible

If your device is:
If your device:

* Not in this list, it might still be a miIO-device and at least have generic support. See the next section for details about how to find out if that is the case.
* Is not in this list, it might still be a miIO-device and at least have generic support. See the next section for details about how to find out if that is the case.
* Needs a manual token and the table says it should not, something has probably changed in the firmware, please open an issue so the table can be adjusted.
* Marked as Untested you can help by testing the implementation is this library and opening an issue with information about the result
* Is marked as Untested you can help by testing the implementation is this library and opening an issue with information about the result.

Name | Type | Auto-token | Support | Note
------------------------------|---------------------------------|------------|-----------|--------
Expand Down
14 changes: 14 additions & 0 deletions docs/devices/gateway.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,17 @@ Emitted when a device is no longer available for access via the gateway.
### `device.devices: Array[SubDevice]`

List the current devices that are available.

### `device.addDevice()`

Tell the gateway that a new device should be added. The actual Aqara device
needs to be reset, which is a different procedure for each device. The device
has 30 seconds to join the gateway.

### `device.stopAddDevice()`

Tell the gateway that you no longer want to add a new device.

### `device.removeDevice(id)`

Remove a device from the gateway using its identifier.
6 changes: 4 additions & 2 deletions example.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const miio = require('./lib');
miio.device({
address: '192.168.100.8'
}).then(device => {
console.log('power is now', device.power);
return device.setPower(! device.power);
if(device.hasCapability('power')) {
console.log('power is now', device.power);
return device.setPower(! device.power);
}
}).catch(console.error);
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
"name": "miio",
"version": "0.6.0",
"license": "MIT",
"description": "Control Mi Home devices implementing the miIO protocol, such as Mi Robot Vacuums, Mi Air Purifiers and more",
"description": "Control Mi Home devices, such as Mi Robot Vacuums, Mi Air Purifiers, Mi Smart Home Gateway (Aqara) and more",
"repository": "aholstenson/miio",
"main": "lib/index.js",
"keywords": [
"xiaomi",
"mi",
"miio"
"miio",
"aqara"
],
"main": "lib/index.js",
"bin": {
Expand Down

0 comments on commit ced776f

Please sign in to comment.