Skip to content

Commit

Permalink
_setup is now named init
Browse files Browse the repository at this point in the history
  • Loading branch information
aholstenson committed Apr 16, 2017
1 parent 2292f1f commit 0854d71
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ const device = miio.createDevice({
});
```

You will need to call `device.init()` manually to initialize the device:

```javascript
device.init()
.then(() => /* device is ready for commands */)
.catch(console.error);
```

## Advanced: Device management

Get information and update the wireless settings of devices via the management
Expand Down
2 changes: 1 addition & 1 deletion lib/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Device extends EventEmitter {
this.debug = require('debug')('miio.device.' + (options.id || '[' + options.address + ']'));
}

_setup() {
init() {
// Default setup involves activating monitoring
return this.monitor();
}
Expand Down
4 changes: 2 additions & 2 deletions lib/devices/gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ class Gateway extends Device {
// TODO: Device removal
}

_setup() {
return super._setup()
init() {
return super.init()
.then(() => this.findDeveloperKey());
}

Expand Down
5 changes: 1 addition & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module.exports.device = function(options) {
});
})
.then(device => {
return device._setup()
return device.init()
.then(() => device);
});
};
Expand All @@ -75,9 +75,6 @@ const createDevice = module.exports.createDevice = function(options) {
device = new d(options);
}

// Run setup, but do not block until it is done
device._setup();

return device;
};

Expand Down

0 comments on commit 0854d71

Please sign in to comment.