skydiver / ewelink-api

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

getDevicePowerUsage() --> error: 'No power usage data found.' #153

Open gino-nl opened 3 years ago

gino-nl commented 3 years ago

Hi all,

I use a Sonoff Pow R2 to register the electricity usage of my home spa. Everything used to work until October 2020, when I shut down my spa for the winter. Since then, I haven't updated the firmware of the device. For some reason, when I now (May 2021) run getDevicePowerUsage() command, it returns this error: error: 'No power usage data found.'

It's weird because other commands like, getDevice, getDevicePowerState, work just fine. Also, the "Power usage" is measured correctly and can be seen in the iOS app.

Any idea's what might be causing the 'No power usage data found.' error and how I can solve it? Please help

gino-nl commented 3 years ago

I updated the ewelink-api from 2.0.0 to 3.1.1 and still no change 😓.

This is what I get after running: const device = await connection.getDevice('1000zzzzf6'); { _id: '5eb181bc81c89800zzzff2dd', group: '', online: true, groups: [], devGroups: [], name: 'Intex Spa', type: '10', deviceid: '10zzzz1f6', apikey: 'c0884c83-zzzz-zzzz-zzzz-1572ce7b1a94', extra: { _id: '5daebf158zzzfbc506e10d2', apikey: 'c938b391-zzz-zzz-afa5-da5b3523a19d', extra: { uiid: 32, description: '201910zz040', brandId: '5c4c1azzzz7d24c7100be054', apmac: 'd0:27:01:zz:zz:3d', mac: 'd0:27:01:zz:zz:3c', ui: '功率检测插座过载告警', modelInfo: '5c700f7eczzz8c47441fd236', model: 'PSC-B67-GL', manufacturer: '深圳松诺技术有限公司', chipid: '004FB005', staMac: 'EC:FA:zz:zz:B0:05' }, country: 'CN', expiredAt: '2024-10-20T08:34:29.066Z', secretKey: '74341853bc4zzzc7eead1ee1292a99ac6', deviceid: '10zzbzz1f6', createdAt: '2019-10-22zzz:34:29.066Z' }, settings: { opsNotify: 0, opsHistory: 1, alarmNotify: 1, wxAlarmNotify: 0, wxOpsNotify: 0, wxDoorbellNotify: 0, appDoorbellNotify: 1 }, createdAt: '2020-05-05zzz:09:48.320Z', __v: 0, onlineTime: '2021-05-2zz08:38:19.958Z', params: { bindInfos: { gaction: [Array] }, startTime: '2021-05-2zz07:44:15.864Z', endTime: '2021-05-29zz7:44:33.110Z', hundredDaysKwh: 'get', timeZone: 2, uiActive: 60, oneKwh: 'stop', current: '0.23', voltage: '232.40', power: '43.24', pulseWidth: 500, pulse: 'off', startup: 'off', switch: 'on', alarmPValue: [ -1, -1 ], alarmCValue: [ -1, -1 ], alarmVValue: [ -1, -1 ], alarmType: 'pcv', init: 1, rssi: -88, staMac: 'EC:zz:zz:4F:B0:05', fwVersion: '3.4.0', sledOnline: 'on', version: 8 }, ip: '31.151.166.105', location: '', offlineTime: '2021-05-2zz08:35:04.816Z', tags: { 'm_7zbz_n@sh': 'on', m_7zzz_nsha: 'on', m_1azz_nsha: 'on' }, family: { id: '5f0ezzz595de0008c03326', index: 0 }, sharedBy: { email: 'n.zzzzi@gmail.com', apikey: 'c0zzzc83-aaa9-4620-9fad-1572ce7b1a94' }, deviceUrl: 'https://eu-api.coolkit.cc/api/detail/5c700f7ecc248c47441fd236.html', brandName: 'SONOFF', productModel: 'POWR2', uiid: 32 }

const usage = await connection.getDevicePowerUsage('1000zzzzf6'); { error: 'No power usage data found' }

alexjimenezes commented 3 years ago

Hi @gino-nl ! I think this issue has been answered in this post: #133 Good luck!

gino-nl commented 3 years ago

Hi @gino-nl ! I think this issue has been answered in this post: #133 Good luck!

HI @alexjimenezes,

I implemented the suggested two changes in the code and upgraded the firmware to 3.5.0, and still no difference.

BTW the error of the other post (#133 ) is error: 400, reason: 'Bad Request', My error is error: 'No power usage data found'

I'm a bit lost 😓. Does POWR2 not support PowerUsage anymore or is it just my setup? @skydiver any ideas? The weird thing is that I can read the Power usage in the iOS app just fine.

o-SAM-a-98 commented 2 years ago

I have been having the same issue, and am also using the POWR2. Did you find any solutions ?

baugp commented 2 years ago

I followed https://github.com/skydiver/ewelink-api/issues/133 and got it to work most of the time. I found a bug in DevicePowerUsageRaw.get() that it cannot handle multiple websocket responses which occur sometimes. Below are changes that I made to fix it. With this, it works 100% of the time for me.

baugp commented 2 years ago

Any reason why you add 2 to getDevice() method? It clearly doesn't exist as the error message suggests.

To try my fix, just clone my fork instead of the original repository.

https://github.com/baugp/ewelink-api

baugp commented 2 years ago

npm uninstall ewelink-api npm uninstall -g ewelink-api then npm install baugp/ewelink-api