skydiver / ewelink-api

eWeLink API for JavaScript
https://www.npmjs.com/package/ewelink-api
MIT License
265 stars 109 forks source link

setDevicePowerState stopped working today -- no changes #119

Closed ksaye closed 3 years ago

ksaye commented 3 years ago

Using version 3.1.1

D:\Git\eWeLinkAPI>npm info ewelink-api

ewelink-api@3.1.1 | MIT | deps: 7 | versions: 24
eWeLink API for Node.js
https://github.com/skydiver/ewelink-api#readme

keywords: ewelink, sonoff, api, node, nodejs

dist
.tarball: https://registry.npmjs.org/ewelink-api/-/ewelink-api-3.1.1.tgz
.shasum: fcda65462e60f0ecd3b19bee6f9ce793bb7f7ebe
.integrity: sha512-MJyVrEoAKFVbSJhlYeBqb6B5EFVIkMZG4L95CeF4YmjUO5/wr2mtfZkZfBwBwrJKUHqAI4qKJiTZeSXEQlzwgA==
.unpackedSize: 51.4 kB

dependencies:
arpping: github:skydiver/arpping node-fetch: ^2.6.1               websocket: ^1.0.32
crypto-js: ^4.0.0                random: ^2.2.0
delay: ^4.4.0                    websocket-as-promised: ^1.0.1

maintainers:
- skydiver <martin@flydev.com>

dist-tags:
latest: 3.1.1

published 3 weeks ago by skydiver <martin@flydev.com>

I noticed today that I get

error: 500, msg: undefined

when calling the setDevicePowerState

Not the code below:

const ewelink = require('ewelink-api');
const connection = new ewelink({
    email: 'ksa*********,
    password: '********,
    region: 'us',
    });

(async () => {
    const bb = await connection.getDevice('100027d819');
    console.log(bb);
    const aa = await connection.setDevicePowerState('100027d819', 'on');
    console.log(aa);
})();

And the ouput:

D:\Git\eWeLinkAPI>node test.js
{
  _id: '5ccdc8264625f5ad6ba58e0e',
  name: 'Fountain',
  type: '10',
  deviceid: '100027d819',
  apikey: 'e88************************8592dae',
  extra: {
    _id: '5a0021da6ed24cfc5974822e',
    apikey: 'fb3a5************************36a0d76e',
    extra: {
      description: 'WWJG001162',
      brandId: '5611402280a0e2630f7b102d',
      apmac: 'd0:27:00:4f:ad:83',
      mac: 'd0:27:00:4f:ad:82',
      ui: '开关改装模块',
      modelInfo: '5655cb0c93991b740423d1ba',
      model: 'ITA-GZ1-GL',
      manufacturer: '深圳创易智能系统有限公司',
      uiid: 14,
      staMac: '68:C6:3A:A7:D6:AB',
      chipid: '00A7D6AB'
    },
    country: 'CN',
    expiredAt: '2022-11-05T00:00:00.000Z',
    deviceid: '100027d819',
    createdAt: '2017-11-06T08:48:26.439Z'
  },
  settings: { opsNotify: 0, opsHistory: 1, alarmNotify: 1 },
  groups: [],
  shareUsers: [],
  online: true,
  createdAt: '2019-05-04T17:13:59.201Z',
  group: '',
  __v: 0,
  onlineTime: '2020-11-13T00:46:00.092Z',
  ip: '4************************8',
  location: '',
  params: {
    switch: 'on',
    fwVersion: '3.5.0',
    startup: 'off',
    staMac: '68:C6:3A:A7:D6:AB',
    rssi: -67,
    timers: [],
    version: 8,
    sledOnline: 'on',
    init: 1,
    pulse: 'off',
    pulseWidth: 500,
    only_device: { ota: 'success' },
    ssid: 'sa************************g',
    bssid: 'a0:cf:5b:a3:aa:10'
  },
  offlineTime: '2020-11-13T00:45:31.143Z',
  deviceStatus: '',
  tags: { m_2dae_ksay: 'on', disable_timers: [ [Object], [Object] ] },
  family: { id: '5eaade31b0ad2b0008ada452', index: 4 },
  brandName: 'Maker',
  productModel: 'Sonoff',
  uiid: 14
}
{ error: 500, msg: undefined }

Was there a change to the target API server to cause this?

ksaye commented 3 years ago

It seems that, with no code changes, the issue has now gone away. I will assume it was an issue with https://us-api.coolkit.cc.