Giter Club home page Giter Club logo

Comments (13)

dospaquetes avatar dospaquetes commented on July 25, 2024 1

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.

dospaquetes avatar dospaquetes commented on July 25, 2024

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.

howanghk avatar howanghk commented on July 25, 2024

Thanks! I will look into this and implement a fix.

from homebridge-ewelink.

rcapolino avatar rcapolino commented on July 25, 2024

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.

howanghk avatar howanghk commented on July 25, 2024

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.

daveramirez5 avatar daveramirez5 commented on July 25, 2024

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.

howanghk avatar howanghk commented on July 25, 2024

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.

rob0101 avatar rob0101 commented on July 25, 2024

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 ?

master...rob0101:master

from homebridge-ewelink.

rob0101 avatar rob0101 commented on July 25, 2024

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

rob0101 avatar rob0101 commented on July 25, 2024

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.

howanghk avatar howanghk commented on July 25, 2024

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.

danielk117 avatar danielk117 commented on July 25, 2024

Hi @howanghk,
I'm using the latest version of your plugin and got the same problem with automation and multiple devices.

from homebridge-ewelink.

danielk117 avatar danielk117 commented on July 25, 2024

The error exists only for blinds. I was able to correct the error #82.

from homebridge-ewelink.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.