Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Open
ghost opened this issue Feb 4, 2020 · 15 comments

Comments

@ghost
Copy link

ghost commented Feb 4, 2020

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!

@howanghk
Copy link
Owner

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.

@ghost
Copy link
Author

ghost commented Feb 14, 2020

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.

@bwp91
Copy link

bwp91 commented Jun 8, 2020

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

@ghost
Copy link
Author

ghost commented Jun 9, 2020

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.

@bwp91
Copy link

bwp91 commented Jun 12, 2020

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

@ghost
Copy link
Author

ghost commented Jun 16, 2020

@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.

@bwp91
Copy link

bwp91 commented Jun 23, 2020

@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

@ghost
Copy link
Author

ghost commented Jun 23, 2020

@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

@bwp91
Copy link

bwp91 commented Jun 23, 2020

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

@ghost
Copy link
Author

ghost commented Jun 23, 2020

@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)

@bwp91
Copy link

bwp91 commented Jun 23, 2020

@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!

@dhutchison
Copy link

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.

@bwp91
Copy link

bwp91 commented Jun 28, 2020

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!

@dhutchison
Copy link

@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.

@bwp91
Copy link

bwp91 commented Jul 1, 2020

@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!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants