howanghk / homebridge-ewelink

Homebridge plugin to control Sonoff relays with OEM firmware
MIT License
81 stars 46 forks source link

Sonoff T1 2c issue #17

Open bahoogas opened 5 years ago

bahoogas commented 5 years ago

Thanks for the awesome plugin.

I have an odd issue with the Sonoff T1 2 channel switch. It turns on/off properly through HomeKit, but I get very strange behaviour if I try to use it the switch itself. When I try to switch it on, it usually switches on and off a couple of times, and the same when I try to switch it off. It takes multiple attempts to switch it on or off. Strangely, it only happens with the second switch (ch2). I get the same behaviour with the EWeLink app and google home, so I’m guessing it has something to do with the way the plugin confirms if the switch is on/off.

I know you don’t have one of these switches, but is there any data I can provide to help?

Thanks!

James

howanghk commented 5 years ago

Hi @bahoogas,

If you stop homebridge / disable the homebridge-ewelink plugin, will the switch behave correctly, or the problem persist?

Please post your homebridge log which demonstrate the issue. Without the log it's hard to guess what's going wrong.

bahoogas commented 5 years ago

Thanks for the help

Yes, if I stop Homebridge the switch behaves correctly.

Here’s an example from the log.

First attempt I switched #2 on, but it immediately switched off Second attempt I switched #2 on on and it stayed on Third attempt I switched #2 off. It quickly switched off, on then off again (and stayed off) This is a pretty common pattern of behaviour

I also noticed the plugin has entries for ch3 and ch4, but they don’t seem to do anything when switched in the home app

[2019-3-6 22:21:07] [eWeLink] WebSocket messge received: {"error":504,"reason":"Request Timeout","deviceid":"100064f25a","apikey":"010de479-3045-452d-9ea5-bf1ea5684306","sequence":"1551871262155"} [2019-3-6 22:21:07] [eWeLink] WebSocket messge received: {"error":504,"reason":"Request Timeout","deviceid":"100064f25a","apikey":"010de479-3045-452d-9ea5-bf1ea5684306","sequence":"1551871262153"} [2019-3-6 22:21:07] [eWeLink] WebSocket messge received: {"error":504,"reason":"Request Timeout","deviceid":"100064f25a","apikey":"010de479-3045-452d-9ea5-bf1ea5684306","sequence":"1551871262152"} {"id":-1,"method":"get_prop","params":["power","bright","rgb"]} send hb to: 0x0000000003625142 {"id":-1,"method":"get_prop","params":["power","bright","rgb"]} send hb to: 0x000000000373113b {"id":-1,"method":"get_prop","params":["power","bright","rgb"]} send hb to: 0x00000000036d52e0 {"id":-1,"method":"get_prop","params":["power","bright","rgb"]} send hb to: 0x00000000036ec2ee [2019-3-6 22:21:03] [eWeLink] WebSocket messge received: {"error":0,"deviceid":"100064f25a","apikey":"010de479-3045-452d-9ea5-bf1ea5684306","sequence":"1551871262156"} [2019-3-6 22:21:02] [eWeLink] Setting power state to [off] for device [Double Switch CH 4] [2019-3-6 22:21:02] [eWeLink] Updating recorded Characteristic.On for [Double Switch CH 4] to [false]. No request will be sent to the device. [2019-3-6 22:21:02] [eWeLink] Setting power state to [off] for device [Double Switch CH 3] [2019-3-6 22:21:02] [eWeLink] Updating recorded Characteristic.On for [Double Switch CH 3] to [false]. No request will be sent to the device. [2019-3-6 22:21:02] [eWeLink] Setting power state to [off] for device [Double Switch CH 2] [2019-3-6 22:21:02] [eWeLink] Updating recorded Characteristic.On for [Double Switch CH 2] to [false]. No request will be sent to the device. [2019-3-6 22:21:02] [eWeLink] Setting power state to [on] for device [Double Switch CH 1] [2019-3-6 22:21:02] [eWeLink] Updating recorded Characteristic.On for [Double Switch CH 1] to [true]. No request will be sent to the device. [2019-3-6 22:21:02] [eWeLink] WebSocket messge received: {"action":"update","deviceid":"100064f25a","apikey":"010de479-3045-452d-9ea5-bf1ea5684306","userAgent":"device","ts":0,"params":{"switches":[{"outlet":0,"switch":"on"},{"outlet":1,"switch":"off"},{"outlet":2,"switch":"off"},{"outlet":3,"switch":"off"}]},"from":"device"} {"id":-1,"method":"get_prop","params":["power","bright","rgb"]} send hb to: 0x0000000003625142 {"id":-1,"method":"get_prop","params":["power","bright","rgb"]} send hb to: 0x000000000373113b {"id":-1,"method":"get_prop","params":["power","bright","rgb"]} send hb to: 0x00000000036d52e0 {"id":-1,"method":"get_prop","params":["power","bright","rgb"]} send hb to: 0x00000000036ec2ee [2019-3-6 22:20:53] [eWeLink] WebSocket messge received: {"error":0,"apikey":"010de479-3045-452d-9ea5-bf1ea5684306","config":{"hb":1,"hbInterval":145},"sequence":"1551871253507"} [2019-3-6 22:20:53] [eWeLink] Sending login request [{"action":"userOnline","userAgent":"app","version":6,"nonce":"155187125350600","apkVesrion":"1.8","os":"ios","at":"0594c6b181e81dcfce3c7898b17b76919ec5912a","apikey":"010de479-3045-452d-9ea5-bf1ea5684306","ts":"1551871253","model":"iPhone10,6","romVersion":"11.1.2","sequence":1551871253507}] WebSocketClient: reconnecting... [2019-3-6 22:20:47] [eWeLink] WebSocket was closed. Reason [1006] [2019-3-6 22:20:47] [eWeLink] Setting power state to [off] for device [Double Switch CH 4] [2019-3-6 22:20:47] [eWeLink] Updating recorded Characteristic.On for [Double Switch CH 4] to [false]. No request will be sent to the device. [2019-3-6 22:20:47] [eWeLink] Setting power state to [off] for device [Double Switch CH 3] [2019-3-6 22:20:47] [eWeLink] Updating recorded Characteristic.On for [Double Switch CH 3] to [false]. No request will be sent to the device. [2019-3-6 22:20:47] [eWeLink] Setting power state to [on] for device [Double Switch CH 2] [2019-3-6 22:20:47] [eWeLink] Updating recorded Characteristic.On for [Double Switch CH 2] to [true]. No request will be sent to the device. [2019-3-6 22:20:47] [eWeLink] Setting power state to [on] for device [Double Switch CH 1] [2019-3-6 22:20:47] [eWeLink] Updating recorded Characteristic.On for [Double Switch CH 1] to [true]. No request will be sent to the device. [2019-3-6 22:20:47] [eWeLink] WebSocket messge received: {"action":"update","deviceid":"100064f25a","apikey":"010de479-3045-452d-9ea5-bf1ea5684306","userAgent":"device","ts":0,"params":{"switches":[{"switch":"on","outlet":0},{"switch":"on","outlet":1},{"switch":"off","outlet":2},{"switch":"off","outlet":3}]},"from":"device"}

PatrikTheDev commented 5 years ago

I have this problem as well and it is irritating as hell, I will provide everything you need to get this fixed

PatrikTheDev commented 5 years ago

To me it looks like the plugin tries to do something with ch3 and ch4 internally and then it messes with the actual ch2, btw the ch3 and ch4 shouldn’t be there in the first place

VictorKrasnov commented 5 years ago

I've fixed ch3 and ch4 problem (see issue #24), but current issue was not resolved. I guess it's due to error below and this is an issue with ewelink API server:

[2019-3-6 22:21:07] [eWeLink] WebSocket messge received: {"error":504,"reason":"Request Timeout","deviceid":"100064f25a","apikey":"010de479-3045-452d-9ea5-bf1ea5684306","sequence":"1551871262155"}

No more idea at the moment...

PatrikTheDev commented 5 years ago

I don’t think they are going to fix it tho, they don’t want you to use it outside the ewelink app and google home/alexa

howanghk commented 4 years ago

Hi all, the multi-channel issue should be fixed by jacopofranza in https://github.com/howanghk/homebridge-ewelink/pull/86 , please install the latest version 0.1.21 and try again.

npm install -g homebridge-ewelink-max@latest

You may also need to clear existing accessories cache (remove the accessories directory in homebridge folder).

jpszalanski commented 4 years ago

I have the same problem with 3CH switches. When I use Home app to control the device, it works fine, but when I do that through any other, like ewelink app or alexa, the problem happens. I investigated and I kinda fixed. This happens because the plugin receive the websocket message within all channels status, then its compares the status one by one, so after the first channel it is comparing a old status and if is changed it sends a new command to ewelink, but it is not right, the status is not the most up dated. so it it will check status again and update to the right status, In this process im my case, my lights blink every time I ask to alexa turn on or off.

Multiple channels device has one extra channel, but is not a channel, it is used to turn on or off all channels at the same time. So the last channel is a function, not a channel. This is why happens the channel problem, in my case with my 3CH, shows this: Can't add [Sala CH 4], because device [T1 UK3C] has only [3] switches. I fixed this too and no more problem.