homebridge-ewelink icon indicating copy to clipboard operation
homebridge-ewelink copied to clipboard

It is recommended that you use websocket to get device status instead of requesting API

Open ghost opened this issue 5 years ago • 15 comments

Hello,

There are some problems in the way of getting the device status of your project. Although the request device list (/api/user/device) can get all the device status, too many requests for the interface will cause great pressure on the coolkit server. It is recommended to use websocket to monitor and get the latest status of the device in real time.

Relevant document address: https://coolkit-technologies.github.io/apiDocs/findStatus_en.html

It can improve your project and hope to adopt it.

Thank you!

ghost avatar Feb 04 '20 09:02 ghost

Hi carl, it's good to have an official API documentation! I would like to adopt the new API you've mentioned, however my ewelink device is out of order, and I don't have any other functional device to test right now. It would be hard (if not impossible) to develop such functionality without testing. Due to the virus outbreak I cannot buy a new device from taobao now, let's see if we can do this after things get back to normal.

howanghk avatar Feb 13 '20 12:02 howanghk

Hi carl, it's good to have an official API documentation! I would like to adopt the new API you've mentioned, however my ewelink device is out of order, and I don't have any other functional device to test right now. It would be hard (if not impossible) to develop such functionality without testing. Due to the virus outbreak I cannot buy a new device from taobao now, let's see if we can do this after things get back to normal.

OK, I see, thank you for your reply.

ghost avatar Feb 14 '20 01:02 ghost

Hi, Just wondered if this is still a “thing”? With guidance I would be able to help with the coding.

bwp91 avatar Jun 08 '20 19:06 bwp91

At present, we have two versions (v1 and v2) of the interface, but the document is currently only in Chinese, and the English part only has the v1 interface, which is still being translated.

The device data is "thing"

Hi, Just wondered if this is still a “thing”? With guidance I would be able to help with the coding.

ghost avatar Jun 09 '20 11:06 ghost

@coolkit-carl There doesn't seem to be a way of getting a complete device list through the web socket?

bwp91 avatar Jun 12 '20 20:06 bwp91

@coolkit-carl There doesn't seem to be a way of getting a complete device list through the web socket?

Yes, it works with API, websocket is just to maintain two-way traffic.

ghost avatar Jun 16 '20 01:06 ghost

@coolkit-carl going off topic here im sorry i don't know where else to ask. how can I send a request via the API to update the target temperature and humidity of the sonoff thermostats? I'm looking for the payload format particularly the payload.params = {} part... would you know? eg could be params.targetTemperature that needs to be sent? thanks

bwp91 avatar Jun 23 '20 11:06 bwp91

@coolkit-carl going off topic here im sorry i don't know where else to ask. how can I send a request via the API to update the target temperature and humidity of the sonoff thermostats? I'm looking for the payload format particularly the payload.params = {} part... would you know? eg could be params.targetTemperature that needs to be sent? thanks

Please tell me a device ID, I want to check the protocol of the device type it belongs to

ghost avatar Jun 23 '20 11:06 ghost

@coolkit-carl its the TH10 and TH16 thermostat sensors.

bwp91 avatar Jun 23 '20 11:06 bwp91

@coolkit-carl its the TH10 and TH16 thermostat sensors.

Ok, I have found the relevant agreement documents. I am not sure if I can provide it to you. I need to ask my leader. (Expected to reply to you tomorrow)

ghost avatar Jun 23 '20 12:06 ghost

@coolkit-carl its the TH10 and TH16 thermostat sensors.

Ok, I have found the relevant agreement documents. I am not sure if I can provide it to you. I need to ask my leader. (Expected to reply to you tomorrow)

i appreciate any help you can/are allowed to give!

bwp91 avatar Jun 23 '20 12:06 bwp91

It looks like (based on the old docs I could find) that the full device list is only available in the HTTP API, which is probably alright if you consider only populating the devices at the point the plugin is initialised. After that you can hit the WebSocket API to get the status for a device (I've got a branch that I'm working on with an experimental implementation of this, behind a feature flag).

This is going to require quite a bit of testing before it goes for a PR as I've refactored quite a bit of code to cut down on duplication, and I don't have all the devices I'd need to test this fully. Fans, temperature & humidity sensors are particularly worrying gaps.

@thepotterfamily generally "params" sent for an update looks to be the same as what you would get when you get the device status.

dhutchison avatar Jun 28 '20 21:06 dhutchison

It looks like (based on the old docs I could find) that the full device list is only available in the HTTP API, which is probably alright if you consider only populating the devices at the point the plugin is initialised. After that you can hit the WebSocket API to get the status for a device (I've got a branch that I'm working on with an experimental implementation of this, behind a feature flag).

This is exactly how i have implemented it in my own fork of this project!

bwp91 avatar Jun 28 '20 21:06 bwp91

@thepotterfamily I did wonder after seeing your fork as a result of that PR someone created if we were heading in the same direction :)

I had started writing a new plugin from scratch in Typescript but then came back around to seeing how I could start with this plugin and incrementally refactor to get into a state where it could switch between the HTTP, WebSockets & Lan control APIs as desired.

dhutchison avatar Jun 28 '20 21:06 dhutchison

@thepotterfamily I did wonder after seeing your fork as a result of that PR someone created if we were heading in the same direction :)

I had started writing a new plugin from scratch in Typescript but then came back around to seeing how I could start with this plugin and incrementally refactor to get into a state where it could switch between the HTTP, WebSockets & Lan control APIs as desired.

Ah if you ever feel like helping me out with my fork as well as this one... let me know!

bwp91 avatar Jul 01 '20 17:07 bwp91