skydiver / ewelink-api

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

Sonoff POW R2 sensor data not updating #86

Open robert777robert777 opened 4 years ago

robert777robert777 commented 4 years ago

Sonoff POW R2 sensor data not updating. Connecting a websocket gives no results for this model (TH does send updates). The data obtained from getDevice also contains not up to date data (requesting again after the current changes sends again the old data).

This data DOES get updated only while the ewelink app is open. By packetsniffing i've found that on LAN the app sends requests to http://device_ip:8081/zeroconf/monitor with an encrypted request. The decrypted contents of the request are : {"uiActive":60} Retransmitting the same request every 60 seconds does help the sensor data flowing (works both by retransmitting the same encrypted packet, as well as by creating the request with known methods).

But if my server (for logging sensor data) isn't in the same lan my way doesn't work (So i try to use the websocket). I've tried to send the same {"uiActive":60} request with action:"update" to the websocket, but it doesn't help (there should be a way since the ewelink app does it even without LAN)

skydiver commented 4 years ago

Hello @robert777robert777

I'm able to get device information, here is my code:

  const connection = new ewelink({
    email: 'email',
    password: 'password',
  });

  await connection.getCredentials();

  const socket = await connection.openWebSocket(async data => {
    console.log(data);
  });

and this is the result:

{
  action: 'update',
  deviceid: 'DEVICE ID',
  apikey: 'API KEY',
  userAgent: 'device',
  ts: 0,
  params: { power: '0.00', voltage: '230.52', current: '0.00' },
  from: 'device'
}

My POW2 model is PSC-B67-GL

robert777robert777 commented 4 years ago

I've tried the same code, my model is the same, firmware version is 3.4.0 but i get similar results only if during the last minute i did 1 of the following:

skydiver commented 4 years ago

My device is on version 3.3.1

Will try to update to 3.4.0 and test again ...

skydiver commented 4 years ago

Hey @robert777robert777

I've upgraded my POW2 to version 3.4.0 and was my previous code still works.

foulek57 commented 4 years ago

Hi,

I send {"uiActive":60} Over the websocket every 60 min with a crib. The data is now non stop.

patience4711 commented 3 years ago

@Foulek57, I also want to encourage the sonoffPow to update. I have the websocket open but get nothing unless i open the app. I cannot find out how to send this {"uiActive":60} with a crib. over the websocket. So how exactly do i do that?

patience4711 commented 3 years ago

Hi @robert777robert777 If i understand it correctly you found a way to get up-to-date data from the sonoffPow from inside your lan. For me that is good enough. Would you be so kind to explain more in detail how you solved it.

works both by retransmitting the same encrypted packet, as well as by creating the request with known methods

How can i retransmit the encrypted package and / or create the request. T.i.a

jerry1333 commented 3 years ago

It works only for few seconds, then just responds 'pong'. If I start ewelink app on phone again then is starts to spit data again, and after closing app after minute or so again no data...

Trying to pull data to influxdb from this devices is pain in the ass...

jedi24 commented 2 years ago

Did anyone solve that problem? I know that Tuyapi has a refresh method to force devices to send the data.

jerry1333 commented 2 years ago

Yes - I switched to Tasmota firmware in Sonoff devices to not use ewelink ever again.

cachac commented 1 year ago

Hi, any updates about this issue?

jaroja4 commented 1 year ago

Hi @foulek57

Can you give me an example of how to send the {"uiActive":60}??

robertoalmeida commented 1 year ago

I have the same problem. Does anyone have the solution?