Comments (13)
Fixed it by adding a 100ms delay after platform.wsc.send(string) in the setPowerState function. Did it super dirty but it works
`if (platform.isSocketOpen) {
setTimeout(function() {
platform.wsc.send(string);
// TODO Here we need to wait for the response to the socket
var waitTill = new Date(new Date().getTime() + 100);
while(waitTill > new Date()){}
callback();
}, 1);
from homebridge-ewelink.
I was thinking maybe adding a slight delay between simultaneous requests would help? Tbh I haven't had my hands in code in a long time so I'm hesitant to get into it myself
from homebridge-ewelink.
Thanks! I will look into this and implement a fix.
from homebridge-ewelink.
Fixed it by adding a 100ms delay after platform.wsc.send(string) in the setPowerState function. Did it super dirty but it works
`if (platform.isSocketOpen) {
setTimeout(function() { platform.wsc.send(string); // TODO Here we need to wait for the response to the socket var waitTill = new Date(new Date().getTime() + 100); while(waitTill > new Date()){} callback(); }, 1);
Hi, thanks for support. where do I enter this code?
Thanks..
from homebridge-ewelink.
Hi @rcapolino, I'm still working on a proper fix for this. In the meantime you may use dospaquetes's fork https://github.com/dospaquetes/homebridge-ewelink
from homebridge-ewelink.
Hello. I can make the dispaquete’s fork to work. I wonder if you have had the chance to merge it into yours? Count me in if you need people to test it out.
Regards.
from homebridge-ewelink.
Hi @daveramirez5, dospaquetes's fork add a small delay to setPowerState, although this may work but this does not 100% address the issue. The proper way to fix this is to implement a request-response mechanism for the websocket messages, and only send the next message after we got response for the previous one. Unfortunately I still don't have time to write code for this yet. If you happen to know programming, please consider contributing to the this project!
from homebridge-ewelink.
Here's my attempt at a fix.
The approach is to not allow new WebSocket send requests to leave until the previous one has responded.
Seems to work for me. Contains extra debugging output that should be removed at a later date.
Thoughts ?
from homebridge-ewelink.
[01/07/2019, 4:42:24 pm] [eWeLink] Setting power state to [off] for device [eWeSwitch3]
[01/07/2019, 4:42:24 pm] [eWeLink] Setting power state to [off] for device [eWeSwitch1]
[01/07/2019, 4:42:24 pm] [eWeLink] Setting power state to [off] for device [eWeSwitch4]
[01/07/2019, 4:42:24 pm] [eWeLink] WebSocket messge received: {"error":0,"deviceid":"xxxx","apikey":"yyyyyyy","sequence":"1561965144113"}
[01/07/2019, 4:42:24 pm] [eWeLink] *********** ========== sendIfSafe Waited 0.5s so far.
[01/07/2019, 4:42:24 pm] [eWeLink] *********** ========== sendIfSafe now CLEAR ****
[01/07/2019, 4:42:24 pm] [eWeLink] *********** ========== sendIfSafe Waited 0.5s so far.
[01/07/2019, 4:42:25 pm] [eWeLink] WebSocket messge received: {"error":0,"deviceid":"xxxx","apikey":"yyyyyyy","sequence":"1561965144113"}
[01/07/2019, 4:42:25 pm] [eWeLink] *********** ========== sendIfSafe Waited 1s so far.
[01/07/2019, 4:42:25 pm] [eWeLink] *********** ========== sendIfSafe now CLEAR ****
[01/07/2019, 4:42:25 pm] [eWeLink] WebSocket messge received: {"error":0,"deviceid":"xxxxxxx","apikey":"yyyyyyy","sequence":"1561965144113"}
from homebridge-ewelink.
I never received any feedback on this fix.
I forgot I had this fix and updated the ewelink-homebridge and immediately lost reliable control over my devices when they are grouped and turned on/off together.
How are other people having any luck without a fix for this in place ?
I merged my code back into the main branch and all works again.
from homebridge-ewelink.
Hi @rob0101 there's a similar fix #66 merged and relased in 0.1.18 on Dec 16, 2019. I looked at your fork the last commit was dated Jun 30, 2019. Is the fix in 0.1.18 not helping your situation?
from homebridge-ewelink.
Hi @howanghk,
I'm using the latest version of your plugin and got the same problem with automation and multiple devices.
from homebridge-ewelink.
The error exists only for blinds. I was able to correct the error #82.
from homebridge-ewelink.
Related Issues (20)
- Temperature update interval TH16 HOT 3
- error was encountered while requesting a list of devices while interrogating current temperature (TH16) HOT 2
- Plugin stopped working HOT 3
- AND, OR, XOR conditions
- L1 crashes
- WebSocket closed error 406 on Setting Power On / Off HOT 3
- May you add sprinkler/Valve support?
- Can't add [Heater CH 4], because device [Single channel switch,multi -channel] has only [0] switches.
- devices not discovered in LAN
- Sonoff micro showing as 4 channels when it is only a single channel device HOT 1
- API Error 503
- Error 400, Bad Request? HOT 19
- [eWeLink] WebSocket messge received: {"error":400,"reason":"Bad Request" HOT 9
- error on plugin HOT 2
- Typo in payload apkVersion (or by design?)
- Missing configuration data HOT 1
- eWelink response - params is error
- error 400 badRequest apikey
- Ewelink Authentication Errors Sign:oauthClient enable invalid HOT 2
- Don't Download This Plugin - Read on... HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from homebridge-ewelink.