mirror of
https://github.com/skydiver/ewelink-api.git
synced 2025-12-24 06:28:30 +01:00
* set APP_ID and APP_SECRET from main class * add APP_ID and APP_SECRET as class constructor parameters * updated test case * updated test case * added new test case * docs updated * Release v3.1.0 - "setWSDevicePowerState" (#96) * new mixing to control devices using websocket * switch status on single channel devices * working on deviceControl mixin * better error handling * working on fix for shared devices * refactor/cleanup * added helper function * added docs for new method * return device new status * added test cases * properly close websocket connection and clean used properties * added test cases * error detection enhancements * added test cases * error detection enhancements * added new test file to jest setup * method renamed * fix for closing websocket connection * new getWSDevicePowerState method * added test cases * re-arrange tests * added new test cases * extract helpers methods * added test case * close WebSocket connection on auth error * updated docs * updated dependencies * fix for "forbidden" error * updated dependencies
50 lines
1.4 KiB
Markdown
50 lines
1.4 KiB
Markdown
# Class Instantiation
|
|
|
|
* Default region of this library is `us`. If your are in a different one, **you must** specify region parameter or error 400/401 will be returned.
|
|
|
|
* If you don't know your region, use [getRegion](available-methods/getregion) method
|
|
|
|
* To get your access token and api key, use [getCredentials](available-methods/getcredentials) method
|
|
|
|
## Using email and password
|
|
```
|
|
const connection = new ewelink({
|
|
email: '<your ewelink email>',
|
|
password: '<your ewelink password>',
|
|
region: '<your ewelink region>',
|
|
});
|
|
```
|
|
|
|
## Using phone number and password
|
|
```
|
|
const connection = new ewelink({
|
|
phoneNumber: '<your phone number>',
|
|
password: '<your ewelink password>',
|
|
region: '<your ewelink region>',
|
|
});
|
|
```
|
|
|
|
## Using access token and api key
|
|
```
|
|
const connection = new ewelink({
|
|
at: '<valid access token>',
|
|
apiKey: '<valid api key>',
|
|
region: '<your ewelink region>',
|
|
});
|
|
```
|
|
|
|
## Custom APP_ID and APP_SECRET
|
|
This library uses an APP ID and APP Secret provided by Sonoff team.
|
|
If you want to specify another pair of settings, just pass in the class constructor:
|
|
```
|
|
const connection = new ewelink({
|
|
email: '<your ewelink email>',
|
|
password: '<your ewelink password>',
|
|
APP_ID: 'CUSTOM APP ID',
|
|
APP_SECRET: 'CUSTOM APP SECRET',
|
|
});
|
|
```
|
|
|
|
## Using devices and arp table cache files
|
|
Check [ZeroConf](zeroconf.md) docs for detailed information.
|