Closed oncioiu closed 9 months ago
same here, any idea ?
HI, seemed to miss this issue being logged, i can reproduce it by
System.out.println(eweLink.setDeviceStatus("1000111111", "off"));
however its fixed if i do this.
Thread.sleep(5000);
System.out.println(eweLink.setDeviceStatus("1000111111", "off"));
i feel you are trying to set the status of a device too soon after the setup of the websocket. the other thing, make sure you are using a shared instance of the EweLink in your code, dont spin one up each time you want to do something
Thanks a lot for your reply ! And thanks a lot for your work!! In the end I wrote my own code not using web sockets which I find simpler for my specific use case :
URL url = new URL("https://eu-api.coolkit.cc:8080/api/user/device/status");
HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection();
urlConnection.setRequestMethod("POST");
urlConnection.setRequestProperty("Content-Type", "application/json");
urlConnection.setRequestProperty("Accept", "application/json");
urlConnection.setRequestProperty("Authorization", "Bearer " + accessToken);
body should be :
{
"deviceid": <deviceId>,
"params": {
"switch": "<on/off>"
},
"appid": <same APP_ID as login>,
"type": 1,
"nonce": <same nonce code as login - getNonce()>,
"ts": <(System.currentTimeMillis() / 1000)>,
"version": 8
}
verry interesting so i had to rewrite a large portion of the code because "coolkit" deprecated V1 of their api
https://github.com/RealZimboGuy/ewelink-api-java/issues/5
because of that i had to reverse out V2 and that didnt have post support under baseUrl = "https://"+region+"-apia.coolkit.cc/v2/";
i see they must have had too much backlash and turned it back on
if it works for now, then in theory V2.1.3-RELEASE should still work which uses the post logic
Great! In case it is removed again, I'll add the sleep to the websocket version :) thanks!
Description After a successfully login, I was not able to perform device status change.
Step to reproduce:
setDeviceStatus
Tried to debug, seems that code is break bellow, but not sure why
return eweLinkWebSocketClient.sendAndWait(gson.toJson(statusChange),statusChange.getSequence());
Logs "org.java_websocket.exceptions.WebsocketNotConnectedException at app//org.java_websocket.WebSocketImpl.send(WebSocketImpl.java:628) at app//org.java_websocket.WebSocketImpl.send(WebSocketImpl.java:605) at app//org.java_websocket.client.WebSocketClient.send(WebSocketClient.java:410) at app//com.github.realzimboguy.ewelink.api.EweLinkWebSocketClient.sendAndWait(EweLinkWebSocketClient.java:83) at app//com.github.realzimboguy.ewelink.api.EweLink.setDeviceStatus(EweLink.java:328)"
Attached some pics with debug process