skydiver / ewelink-api

eWeLink API for JavaScript
https://www.npmjs.com/package/ewelink-api
MIT License
267 stars 108 forks source link

Zero conf on devices witch 2 channels #120

Open apadilla83 opened 3 years ago

apadilla83 commented 3 years ago

Hi, when I turn on second channel on sonoff device, if firts channel are on, siwtch to off the firts channel and on the second channel. There any way to change this behaviour?

Thanks

ahmet8282 commented 3 years ago

I have the same issue. Were you able to find a solution?

apadilla83 commented 3 years ago

Nothing , I have to use the api over internet to work witch 2 channels devices....Nobody answer....

ahmet8282 commented 3 years ago

I figured it out. You must execute these only once in your app.

 devicesCache = await Zeroconf.loadCachedDevices();
 arpTable = await Zeroconf.loadArpTable();

/* create the connection using cache files */
 connection = new ewelink({ devicesCache, arpTable });

I set them up to execute during startup of my app, and use connection as singleton. The problem was fixed.

apadilla83 commented 3 years ago

I figured it out. You must execute these only once in your app.

 devicesCache = await Zeroconf.loadCachedDevices();
 arpTable = await Zeroconf.loadArpTable();

/* create the connection using cache files */
 connection = new ewelink({ devicesCache, arpTable });

I set them up to execute during startup of my app, and use connection as singleton. The problem was fixed.

This Work!! many thanks!!

Flip76 commented 3 years ago

Can you please paste a sniplet? Can‘t get it to work with a Pro 4Channel :-(

xajis commented 3 years ago

I fixed this by changing this /src/mixins/setDevicePowerState.js line 48

    if (switches) {
        params.switches = switches.filter(sw => sw.outlet === channel - 1)
        params.switches[0].switch = stateToSwitch;
    } else {
        params.switch = stateToSwitch;
    }

it was sending the signal to switch all of the channels

apadilla83 commented 3 years ago

Hi, xajis, This work for me. Thanks!

xajis commented 3 years ago

Happy to help :) this was bugging me for a long time..