Code Monkey home page Code Monkey logo

ewelink-api's Introduction

ewelink-api

eWeLink API for JavaScript

Key features

  • can run on browsers, node scripts or serverless environment
  • set on/off devices
  • get power consumption on devices like Sonoff POW
  • listen for devices events
  • using zeroconf (LAN mode), no internet connection required

Installation

 npm install ewelink-api

Usage

Check library documentation and examples at https://github.com/skydiver/ewelink-api/tree/master/docs

ewelink-api's People

Contributors

dependabot[bot] avatar ig0rr0 avatar nickdub-old avatar skydiver avatar ttz642 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ewelink-api's Issues

401 "Authentication error"

I'm writing application to control my devices, from a web browser, and I'm randomly unable to connect to you api.
I'm using the connection object following your examples, and I'm getting error 401 "Authentication error", as a result of getDevices or setDevicePowerState. Function like getDevicePowerState or getRegion, works as expected. It's happened over and over again, on the same machine. While the same code on the same time other machine works fine. Weblink application also works.
The issue is reproducible on my local machine, and azure server.
Calling api from different location(probably) is not the source off issue, because i swich devices only when i'm forced to do it.

It's a serious issue because it's made your API impossible to use and trust.

Slow login. Using ewelink-api is much slower than using ewelink app on mobile.

Not so much of an issue but an observation and a request to update the documentation.

What I have found is that when I use ewelink-api to access the devices via the cloud it takes a long time to open and fetch information about the devices, eg:
connection = new ewelink({
email: config.ewelink.email,
password: config.ewelink.password
});
. . .
devices = await connection.getDevices();
console.log(devices);

Running this takes nearly 6 seconds (and longer sometimes):
$ time bin/fetchDevices.js
real 0m5.816s
user 0m1.349s
sys 0m0.084s

Occasionally it failed to connect and I noticed that the host it was trying to connect to was the US server, ie:
https://us-api.coolkit.cc:8080

This made me think, what if this is the default login is the us server so I changed the Class Instantiation to include my region:
connection = new ewelink({
email: config.ewelink.email,
password: config.ewelink.password,
region: "eu"
});

sure enough:
$ time bin/fetchDevices.js
real 0m1.930s
user 0m1.331s
sys 0m0.088s

Could you update the documentation to require the region be included in the Class Instantiation API as it affects performance.

This is also why I think the alternative connection is failing as they are sometimes connecting to the wrong server for where a user is registered. ie add the region as a required parameter when using the 'access token' or 'api key'.

Only had a switch and socket a few days but so far I've had more success with your library than all the others I've tried, I just want a simple library not a whole automation system.

I noticed you've commented on LAN mode which is what I'm really after, I'll start moving that way soon as I'd rather not be using the cloud to store what's happening in my house and I want it to work when the internet is down.

pinging US server:
$ ping -c 10 us-api.coolkit.cc
PING us-api.coolkit.cc (13.57.86.90) 56(84) bytes of data.
64 bytes from ec2-13-57-86-90.us-west-1.compute.amazonaws.com (13.57.86.90): icmp_seq=1 ttl=35 time=163 ms
. . .
--- us-api.coolkit.cc ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 9009ms
rtt min/avg/max/mdev = 162.212/165.930/177.053/4.508 ms

pinging EU server:
$ ping -c 10 eu-api.coolkit.cc
PING eu-api.coolkit.cc (52.57.118.192) 56(84) bytes of data.
64 bytes from ec2-52-57-118-192.eu-central-1.compute.amazonaws.com (52.57.118.192): icmp_seq=1 ttl=41 time=41.5 ms
. . .
--- eu-api.coolkit.cc ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 9013ms
rtt min/avg/max/mdev = 39.034/42.012/43.908/1.710 ms

Sonoff RF Bridge toggling?

I can see my Sonoff RF Bridge listed with all his RF list commands. Is there any way to toggle those ?

WebSocketAsPromised - Error: socket hang up

If the web socket connection to the ITLEAD cloud fails the ping doesn't handle it.

Returned error: { RequestError: Error: socket hang up
    at new RequestError (/home/sonoff/node_modules/request-promise-core/lib/errors.js:14:15)
    at Request.plumbing.callback (/home/sonoff/node_modules/request-promise-core/lib/plumbing.js:87:29)
    at Request.RP$callback [as _callback] (/home/sonoff/node_modules/request-promise-core/lib/plumbing.js:46:31)
    at self.callback (/home/sonoff/node_modules/request/request.js:185:22)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at Request.onRequestError (/home/sonoff/node_modules/request/request.js:881:8)
    at emitOne (events.js:116:13)
    at ClientRequest.emit (events.js:211:7)
    at TLSSocket.socketErrorListener (_http_client.js:387:9)
    at emitOne (events.js:116:13)
    at TLSSocket.emit (events.js:211:7)
    at emitErrorNT (internal/streams/destroy.js:64:8)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
  name: 'RequestError',
  message: 'Error: socket hang up',
  cause: 
   { Error: socket hang up
    at TLSSocket.onHangUp (_tls_wrap.js:1137:19)
    at Object.onceWrapper (events.js:313:30)
    at emitNone (events.js:111:20)
    at TLSSocket.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
     code: 'ECONNRESET',
     path: null,
     host: 'eu-api.coolkit.cc',
     port: '8080',
     localAddress: undefined },

RENAME login to getCredentials or getAccount ?

Martin,

The method login is confusing, it isn't actually logging in and does not require any information to LOGIN.

Everybody understands the term login to mean gaining secure access to something by supplying account or other secret information.

Login is really fetching the details about the current session, perhaps it would be better if it were renamed to getCredentials (or getAccount) which more correctly identifies what it is actually doing.

Rather than simply rename and break everybody's code perhaps create a new method getCredentials (or getAccount) (a duplicate of login) and just mark login as:

login has been DEPRECATED and will be removed in the near future, please update your code to use getCredentials (or getAccount)

Perhaps with release 2.0.0, version with LAN access tried and tested ?

--
Steve

Sonoff RF Bridge

Hi,

Has anyone got the RF bridge working with learned remotes? Querying the device shows it's got no switches.

Thanks,

Paul

connection.setDevicePowerState returns success but does not work

When I try using the connection.setDevicePowerState api to on/off/toggle it does return a success response with

{ status: 'ok', state: 'on' }

but no changes are done to the physical actual switch

Note: I tested this a couple of days ago with the same exact script it was working, the switch is working through the ewelink app and the software switch on it

Error 503

For a few days now, when I try to log in, I get the following error: Service 503 temporarily unavailable and a CORS error.
Does it just happen to me? Any solutions?

Zeroconf on Windows: Arping fails when iterating over current machine ip

192.168.1.15 is local IP of my computer.
I've got an error and used debugger.
image

TypeError: Cannot read property 'replace' of undefined
    at D:\Projects\MyProjects\ewelink-api\node_modules\arpping\index.js:83:51
    at ChildProcess.exithandler (child_process.js:286:7)
    at ChildProcess.emit (events.js:223:5)
    at maybeClose (internal/child_process.js:1021:16)
    at Socket.<anonymous> (internal/child_process.js:430:11)
    at Socket.emit (events.js:223:5)
    at Pipe.<anonymous> (net.js:664:12)

Broken Links to Documentation

Hi, a fellow (also retired) skydiver here!

The correct path to your documentation is:
https://github.com/skydiver/ewelink-api/tree/master/docs

but its shown as this in a couple of different locations:
https://github.com/skydiver/ewelink-api/docs
which gives a 404 error.

The two locations I'm aware of are:
https://github.com/skydiver/ewelink-api
https://www.npmjs.com/package/ewelink-api

Also, your personal website:
https://skydiver.dev
has an expired certificate.

Blue skies!

Pete.

RF bridge support question

Is there any chance to send data to rf bridge?
openWebSocket listen data form rf bridge but how we can send data to rf bridge?

data recived:
{ action: 'update',
deviceid: 'xxx',
apikey: 'xxxx',
userAgent: 'app',
sequence: '1582506488423',
ts: 0,
params: { cmd: 'transmit', rfChl: 0 },
tempRec: 'xxxxx' }

Slow response times, and setDevicePowerState not working

Hi,

Thanks for this Library!
This is what I have found out about the title's topics.

There are several reports of 6 second response times.
It seems to me to be the normal time for Node.js start-up and required module loading.
Once that's done, switching is fast.

Regarding switching, my Sonoff S26 did not switch using the standard script.
It is in LAN mode, and using the serverless mode it switches correctly (and immediately!).

Questions -
How do you listen for device events?
Are device connections persistent, so I only create once, and use to switch the device occasionally from other sources?

Thanks.

switch to fahrenheit?

Is not possible at the moment switch to fahrenheit mode for TH10/16 sensors, but it seems to be possible from mobile apps, so probably there's a param that could be added to get back temperature in fahrenheit instead of celsius?

401 Authentication error with Phone Numbers

I am getting 401 Authentication error with phone numbers as login email. I do use the country code and it gives 401 even for getRegion requests. I tried using another account with an email address and it works.

Types issue with Multichannel devices

Hi,

I found an issue with types definition for multichannel devices: in the Params interface, you need to add a switches and pulses properties. I defined them in my project like these:

  pulses: Array<{outlet: number; pulse: "on" | "off"; width: number}>;
  switches: Array<{outlet: number; switch: "on" | "off"}>;

Thanks,
Fabio.

eweLink has made some changes last week. API needs updating

As of last week, ewelink made some changes in how it sends data. I don't know of the changes, but I do know that there were some changes. A similar problem was faced with the SONOFF API for homeassistant.

I would really appreciate if you can update this API to reflect the changes.

As for now,

The login with email/password - OK.
Login with accesstoken/apikiey - FAIL
Listening to the websocket (https://ewelink-api.now.sh/docs/available-methods/openwebsocket) - OK
getDevices - FAIL
ToggleDevice - FAIL

I haven't tested rest of the commands, since I just started using the API today.

Would really appreciate your attention. Thanks.

-Faisal Qureshi

Some error logs:

all devices { error: 400, msg: 'params incomplete' }
a device { code: 400, error: 'params is incomplete' }

Trying to use the accesstoken:
login details -> { error: 400, msg: 'Authentication error' }
devices { error: 401, msg: 'Authentication error' }

documentation update

Martin,

Issue #21 is really due to misunderstanding of the documentation.

Perhaps a few more clarifications to address this.

Login method add:
console.log('Region: ', auth.region);

serverless
Need to put code in async function because if you just copy and paste it doesn't work.

Introduction
Make a note that the region assigned when your eWeLink account is initially created may not be what you expect and you should check what server/region with either login or getRegion return.

Online Offline state ?

Hi,

I want to check if a device are online before i send a toggle cmd.

Any idea to check it ?

Thanks.

Switching multi-channel devices

Hi everyone,
I'm trying to toggle a multi-channel switch, but I get an error from the server.
No problem using the official app.
I'm using the library in the browser, I have no problem with other single-channel devices.
The request-response pasted below:
WS request:

{
   "action":"update",
   "deviceid":"10007b7e72",
   "apikey":"480837cb-aa7f-4b10-855b-327826fb3865",
   "selfApikey":"480837cb-aa7f-4b10-855b-327826fb3865",
   "params":{
      "switches":[
         {
            "outlet":0,
            "pulse":null,
            "switch":"on"
         },
         {
            "outlet":1,
            "pulse":null
         },
         {
            "outlet":2,
            "pulse":null
         },
         {
            "outlet":3,
            "pulse":null
         }
      ]
   },
   "sequence":1582712713914,
   "userAgent":"app"
}

WS response:

{
   "error":400,
   "deviceid":"10007b7e72",
   "apikey":"480837cb-aa7f-4b10-855b-327826fb3865",
   "sequence":"1582712713914"
}

I have no clue on what to do. I've tried to sniff official app traffic but i see only many strange symbols ๐Ÿ˜Š.
Can someone help me?

Fabio.

Dependency issue with arpping

Hi,
When trying to add ewelink-api as a dependency I have the following error:

npm ERR!
code 128
npm ERR! Command failed: git clone --mirror -q git://github.com/skydiver/arpping.git /.npm/_cacache/tmp/git-clone-1484b751/.git
npm ERR! fatal: could not create leading directories of '/.npm/_cacache/tmp/git-clone-1484b751/.git'
npm ERR!

anything I'm missing?

Sync vs Async?

I'm no expert in nodeJS just yet but i don't understand the sync vs async usage within your code, eg:

  static async loadArpTable(fileName = './arp-table.json') {
    try {
      const jsonContent = await fs.readFileSync(fileName);
      return JSON.parse(jsonContent);
    } catch (e) {
      return { error: e.toString() };
    }
  }

What is the purpose of the await on the readFileSync which is not an async method, it is synchronous and in theory will return once complete. the await isn't needed.

Alternatively you could change the code to use async method, eg:

  static async loadArpTable(fileName = './arp-table.json') {
    fs.readFile(fileName, 'utf8', function(e, data) {
      if (e){
        return { error: 'readFile: '+e.toString() };
      }
      try{
        var jsonContent = JSON.parse(data);
        return jsonContent;
      } catch (e){
        return { error: 'JSON: '+e.toString() };
      }
    });
  }

the calling code would use await, eg:

await loadArpTable();

Receive updates from Sonoff Camera

I just installed a Sonoff Camera GK-200MP2-B and i'm trying to get motion detected updates but couldn't make it work.

After a getDevices() i get this about the camera:
{ group: '',
online: true,
shareUsersInfo: [],
groups: [],
devGroups: [],
_id: '5e5003069145e10008ed',
name: 'Camera Sonoff',
type: 'a6',
deviceid: 'a620001a03',
apikey: 'b53faefe-xxxx-xxxx-a380-7c3b27c0xxxx',
params:
{ partnerDevice: [Object],
bindInfos: [Object],
version: 7,
romVersion: '24520191030' },
extra: { extra: [Object], _id: '5e5003069145e10008xxxxxx' },
createdAt: '2020-02-21T16:19:18.857Z',
__v: 0,
onlineTime: '2020-02-28T12:42:35.370Z',
ip: '179.54.x.x',
location: '',
offlineTime: '2020-02-27T19:16:54.632Z',
deviceStatus: '',
sharedBy:
{ email: '[email protected]',
apikey: 'b53faefe-xxxx-xxxx-a380-7c3b27c0xxxx',
permit: 15,
shareTime: 1582985068238 },
devicekey: '290ba8dd-xxxx-xxxx-xxxx-6d706694f070',
deviceUrl: '',
brandName: 'coolkit',
showBrand: true,
brandLogoUrl: '',
productModel: 'GK-200MP2B',
devConfig: {},
uiid: 87 }

Did anyone make it work?

Tks,

Fernando

ewelink-api-release_2.0.0 ArpTable DevicesCachejson result as json Enhancement

I've been testing your ewelink-api-release_2.0.0 zeroconf, beside windows compability problems I've find out that storing, ArpTable and DevicesCache to files creates a lot of troubles. Would it be possible to get saveDevicesCache(); and Zeroconf.saveArpTable result after await, eg. via callback? Insted of storing them to file, and then load, and then use js objects.

Error sending a Request

Hello, just implement the library and tried to make a request and it gaves me an error, i don't know what could i miss..

the response was:

Error: getaddrinfo EAI_AGAIN us-api.coolkit.cc:8080
    at new RequestError (/srv/node_modules/request-promise-core/lib/errors.js:14:15)
    at Request.plumbing.callback (/srv/node_modules/request-promise-core/lib/plumbing.js:87:29)
    at Request.RP$callback [as _callback] (/srv/node_modules/request-promise-core/lib/plumbing.js:46:31)
    at self.callback (/srv/node_modules/request/request.js:185:22)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at Request.onRequestError (/srv/node_modules/request/request.js:881:8)
    at emitOne (events.js:116:13)
    at ClientRequest.emit (events.js:211:7)
    at TLSSocket.socketErrorListener (_http_client.js:401:9)
    at emitOne (events.js:116:13)
    at TLSSocket.emit (events.js:211:7)
    at emitErrorNT (internal/streams/destroy.js:66:8)
    at _combinedTickCallback (internal/process/next_tick.js:139:11)
    at process._tickDomainCallback (internal/process/next_tick.js:219:9)

i just install the package with npm and add the getDevices example code, by the way, i'm using it in Firebase Cloud Functions, here is the code:

const ewelink = require('ewelink-api');

exports.getMyDevices = https.onRequest( async (req, res) => {
    const myEmail = req.body.email;
    const myPassword = req.body.password;

    const conn = new ewelink({
        email: myEmail,
        password: myPassword,
      });
    
    /* get all devices */
    const devices = await conn.getDevices();
    res.status(200).send(devices);
});

error is changed(please update something, before check it all)

(node:78231) UnhandledPromiseRejectionWarning: RequestError: Error: getaddrinfo ENOTFOUND us-api.coolkit.cc
at new RequestError (/Users/kangjoojin/develop/sonoff/sonoff-python-0.1/node_modules/request-promise-core/lib/errors.js:14:15)
at Request.plumbing.callback (/Users/kangjoojin/develop/sonoff/sonoff-python-0.1/node_modules/request-promise-core/lib/plumbing.js:87:29)
at Request.RP$callback [as _callback] (/Users/kangjoojin/develop/sonoff/sonoff-python-0.1/node_modules/request-promise-core/lib/plumbing.js:46:31)
at self.callback (/Users/kangjoojin/develop/sonoff/sonoff-python-0.1/node_modules/request/request.js:185:22)
at Request.emit (events.js:209:13)
at Request.onRequestError (/Users/kangjoojin/develop/sonoff/sonoff-python-0.1/node_modules/request/request.js:881:8)
at ClientRequest.emit (events.js:209:13)
at TLSSocket.socketErrorListener (_http_client.js:406:9)
at TLSSocket.emit (events.js:209:13)
at emitErrorNT (internal/streams/destroy.js:91:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
at processTicksAndRejections (internal/process/task_queues.js:77:11)
(node:78231) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:78231) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

how to control sonoff timer with ewelink-api

Hello, I'm very happy with this API, thank you
I've successfully using all available function through this api
But I need to view and modify the sonoff timer, are there any functions to help ?

WebSocket closed error

When the hearbeat interval function runs it does not check if the websocket is open and that often creates error like this one:
(node:914) UnhandledPromiseRejectionWarning: Error: Can't send data because WebSocket is not opened. at exports.throwIf (/root/nodejs/ewelink-sserver/node_modules/websocket-as-promised/dist/index.js:3470:11) at WebSocketAsPromised.send (/root/nodejs/ewelink-sserver/node_modules/websocket-as-promised/dist/index.js:554:7) at Timeout._onTimeout (/root/nodejs/ewelink-sserver/node_modules/ewelink-api/mixins/websocket/openWebSocketMixin.js:38:17) at listOnTimeout (internal/timers.js:531:17) at processTimers (internal/timers.js:475:7)

Please add the check "if (wsp.isOpened)" to the interval function (line 37 in openWebSocketMixin):

   setInterval(async () => {
      if (wsp.isOpened) {
        await wsp.send('ping');
      }
    }, heartbeat);

Change color ?

Hi,

I try to change a color of a humidifier with led color, here the params of the device :

params: { lightBcolor: 0, rssi: -50, staMac: '2C:3A:E8:45:82:25', lightRcolor: 255, timers: [Array], lightswitch: 0, water: 1, lightGcolor: 0, switch: 'off', lightmode: 1, lightbright: 100, fwVersion: '2.7.0', state: 2, sledOnline: 'on' },
They are a possibility to change this data ?

Thanks

documentation:: Class Instantiation

If I try another connection using region & access token:

	const atConnection = new ewelink({
		at: login.at,
		region: login.region
	});

using the connection to openWebSocket ALWAYS fails with the error:

openWebSocket data:: { error: 406, sequence: '1573811728283' }

If I add the apiKey (obtained from the first device from the getDevices()):

	const atConnection = new ewelink({
		at: login.at,
		apiKey: login.user.apikey,
		region: login.region
	});

it works.

Thought: you mentioned a double login where the us is tried first and then the region, would the apikey be picked up on the first access (ie us server) and not updated on second login to the regional server and therefore use the wrong apikey provided by the us server?

type error in :: ewelink-api/classes/PowerState/ChangeState.js

UnhandledPromiseRejectionWarning: TypeError: Cannot convert undefined or null to object
ie:

(node:2220) UnhandledPromiseRejectionWarning: TypeError: Cannot convert undefined or null to object
    at hasOwnProperty (<anonymous>)
    at String.split.call.filter.reduce (/home/sonoff/node_modules/ewelink-api/lib/helpers.js:6:40)
    at Array.reduce (<anonymous>)
    at _get (/home/sonoff/node_modules/ewelink-api/lib/helpers.js:5:6)
    at Function.set (/home/sonoff/node_modules/ewelink-api/classes/PowerState/ChangeState.js:20:19)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
(node:2220) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)

I'm guessing there's an issue with the return from this.WebSocketRequest:

    const response = await this.WebSocketRequest(apiUrl, [
      payloadLogin,
      payloadUpdate,
    ]);

    const error = _get(response[1], 'error', false);

I've put a try round to see if I can see what is being returned when the error happens, ie:

    var error;
    try{
        error = _get(response[1], 'error', false);
    }catch (err) {
        console.log('---ERROR--- :: WebSocketRequest error',err,' and returned response:',JSON.stringify(response,null,4));
    }

Issue with certificate's altnames

Is there a problem with the server certificates or is somebody trying a man in the middle attack:

2020-01-27T15:23:59.370Z | deviceid: XXXXXXXXXX returned error: { RequestError: Error: Hostname/IP doesn't match certificate's altnames: "Host: eu-api.coolkit.cc. is not in the cert's altnames: DNS:poker.zynga.com, DNS:*.poker.zynga.com"
    at new RequestError (/home/sonoff/node_modules/request-promise-core/lib/errors.js:14:15)
    at Request.plumbing.callback (/home/sonoff/node_modules/request-promise-core/lib/plumbing.js:87:29)
    at Request.RP$callback [as _callback] (/home/sonoff/node_modules/request-promise-core/lib/plumbing.js:46:31)
    at self.callback (/home/sonoff/node_modules/request/request.js:185:22)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at Request.onRequestError (/home/sonoff/node_modules/request/request.js:881:8)
    at emitOne (events.js:116:13)
    at ClientRequest.emit (events.js:211:7)
    at TLSSocket.socketErrorListener (_http_client.js:387:9)
    at emitOne (events.js:116:13)
    at TLSSocket.emit (events.js:211:7)
    at emitErrorNT (internal/streams/destroy.js:64:8)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
  name: 'RequestError',
  message: 'Error: Hostname/IP doesn\'t match certificate\'s altnames: "Host: eu-api.coolkit.cc. is not in the cert\'s altnames: DNS:poker.zynga.com, DNS:*.poker.zynga.com"',
  cause: 
   { Error: Hostname/IP doesn't match certificate's altnames: "Host: eu-api.coolkit.cc. is not in the cert's altnames: DNS:poker.zynga.com, DNS:*.poker.zynga.com"
    at Object.checkServerIdentity (tls.js:223:17)
    at TLSSocket.<anonymous> (_tls_wrap.js:1111:29)
    at emitNone (events.js:106:13)
    at TLSSocket.emit (events.js:208:7)
    at TLSSocket._finishInit (_tls_wrap.js:639:8)
    at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:469:38)
     reason: 'Host: eu-api.coolkit.cc. is not in the cert\'s altnames: DNS:poker.zynga.com, DNS:*.poker.zynga.com',
     host: 'eu-api.coolkit.cc',
     cert: 
      { subject: [Object],
        issuer: [Object],
        subjectaltname: 'DNS:poker.zynga.com, DNS:*.poker.zynga.com',
        infoAccess: [Object],
        modulus: 'C1614F61E989FE0BC16E002096001905007AA98F53D6A2747379EEFB2343F8824516B954DBF642F58F373D5DC9A6183E012BA0DAC699B34D70A10EBD931AA249B513BCF2FCCD6F32B8FCFACF9C5E4C2AB5B6B7FF893AB735444381316D5A756DCEF136889B83CBCDED024C4318B557105B5FDE37CEB8F994533F2B8DC85F6E77F7C295050484EE2A0DCF07999645A4D726B1B91C5A263B36D6DAC6CFA18F15A6F47AD2B5706F160614B236BC94540C0D8727BEDA2CB9E06E3250692C85CAFED70631C6C4CB42268BC20A385AF328C5F346C0921F40F95D70A2C01B6EAD564FC3AB12F8A0F8077A83529854C8978EBA0960207E2ECEA4ED100BBA60ADF39389E9',
        exponent: '0x10001',
        valid_from: 'Mar 22 00:00:00 2019 GMT',
        valid_to: 'Apr 22 12:00:00 2020 GMT',
        fingerprint: '02:20:2F:74:9B:94:C5:56:85:44:D8:30:2A:4B:47:D3:DF:C7:B2:80',
        ext_key_usage: [Array],
        serialNumber: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
        raw: <Buffer 30 82 05 7a 30 82 04 62 a0 03 02 01 02 02 10 03 ba 7d a5 89 a3 3c 0d 85 d9 19 33 3b 51 d2 c0 30 0d 06 09 2a 86 48 86 f7 0d 01 01 0b 05 00 30 46 31 0b ... > } },
  error: 
   { Error: Hostname/IP doesn't match certificate's altnames: "Host: eu-api.coolkit.cc. is not in the cert's altnames: DNS:poker.zynga.com, DNS:*.poker.zynga.com"
    at Object.checkServerIdentity (tls.js:223:17)
    at TLSSocket.<anonymous> (_tls_wrap.js:1111:29)
    at emitNone (events.js:106:13)
    at TLSSocket.emit (events.js:208:7)
    at TLSSocket._finishInit (_tls_wrap.js:639:8)
    at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:469:38)
     reason: 'Host: eu-api.coolkit.cc. is not in the cert\'s altnames: DNS:poker.zynga.com, DNS:*.poker.zynga.com',
     host: 'eu-api.coolkit.cc',
     cert: 
      { subject: [Object],
        issuer: [Object],
        subjectaltname: 'DNS:poker.zynga.com, DNS:*.poker.zynga.com',
        infoAccess: [Object],
        modulus: 'C1614F61E989FE0BC16E002096001905007AA98F53D6A2747379EEFB2343F8824516B954DBF642F58F373D5DC9A6183E012BA0DAC699B34D70A10EBD931AA249B513BCF2FCCD6F32B8FCFACF9C5E4C2AB5B6B7FF893AB735444381316D5A756DCEF136889B83CBCDED024C4318B557105B5FDE37CEB8F994533F2B8DC85F6E77F7C295050484EE2A0DCF07999645A4D726B1B91C5A263B36D6DAC6CFA18F15A6F47AD2B5706F160614B236BC94540C0D8727BEDA2CB9E06E3250692C85CAFED70631C6C4CB42268BC20A385AF328C5F346C0921F40F95D70A2C01B6EAD564FC3AB12F8A0F8077A83529854C8978EBA0960207E2ECEA4ED100BBA60ADF39389E9',
        exponent: '0x10001',
        valid_from: 'Mar 22 00:00:00 2019 GMT',
        valid_to: 'Apr 22 12:00:00 2020 GMT',
        fingerprint: '02:20:2F:74:9B:94:C5:56:85:44:D8:30:2A:4B:47:D3:DF:C7:B2:80',
        ext_key_usage: [Array],
        serialNumber: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
        raw: <Buffer 30 82 05 7a 30 82 04 62 a0 03 02 01 02 02 10 03 ba 7d a5 89 a3 3c 0d 85 d9 19 33 3b 51 d2 c0 30 0d 06 09 2a 86 48 86 f7 0d 01 01 0b 05 00 30 46 31 0b ... > } },
  options: 
   { method: 'GET',
     uri: 'https://eu-api.coolkit.cc:8080/api/user/device',
     headers: 
      { Authorization: 'Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' },
     body: {},
     qs: 
      { lang: 'en',
        getTags: 1,
        version: 6,
        ts: 1580138639,
        appid: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
        imei: 'DF7425A0-3933-5451-9F5E-3BC9179E48FB',
        os: 'android',
        model: '',
        romVersion: '',
        appVersion: '3.12.0' },
     json: true,
     callback: [Function: RP$callback],
     transform: undefined,
     simple: true,
     resolveWithFullResponse: false,
     transform2xxOnly: false },
  response: undefined }

Toggle auto/manual, and setpoints, on a Sonoff TH10?

Is it possible to toggle a TH10 between auto and manual using this API? Is it possible to alter the set points?

I don't think it is, and I would like to offer to alter code a new mixin mixins/temphumd/setTHMixin.js, based on the way it is done in setDevicePowerStateMixin.js.

The Sonoff TH10 is supported by your API, and the device.productModel==='Sonoff THS' identifies this type of device. The TH10 can be a manual switch, or an automatic heating/cooling controller by turning on and off at configurable temperature set points. The response from getDevice on a Sonoff TH10 temperature humidity sensor contains params.deviceType==='temperature' if the TH10 is in Auto, and params.deviceType='normal' if the TH10 is in Manual. The set points are also returned as an array of objects in params.targets:

  { targetHigh: '10', reaction: { switch: 'off' } },
  { targetLow: '8', reaction: { switch: 'on' } }
]

Am I correct to say the API does not presently allow setting the auto/manual mode and setpoints?
Would you be open to this me developing this change?

"RequestError: Error: getaddrinfo ENOTFOUND usa"

Hi ,

Am getting "RequestError: Error: getaddrinfo ENOTFOUND usa"error while creating initial connection to my eWelink account. Credentials has been verified working in mobile app, but not working in node-red. Help in solving the same

Minor documentation issue :: typo in Demos / serverless

Martin, just to make sure cut'n'paste works for all examples.

Each time you make a Class Instantiation the structure is missing the comma on the first line and unnecessarily includes one on the second, eg:

  const newConnection = new ewelink({
    at: accessToken
    region: region,
  });

should be written:

  const newConnection = new ewelink({
    at: accessToken,
    region: region
  });

This is the case of all three examples in serverless demo

It's possible to listen to an RF Bridge triggers?

I see the library can check Devices and change the state of them, but could be or it's possible to listen to an RF Bridge triggers? that would be definetly a game changer because it's not possible not event with IFTTT

name of the device group

Hi, trying the API. There are several questions. How to get the name of the device group (devices[0].groups).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.