homebridge-plugins / homebridge-ewelink

Homebridge plugin to integrate eWeLink devices into HomeKit.
MIT License
389 stars 127 forks source link

Web Socket Error 406 #202

Closed SimonLawson70 closed 3 years ago

SimonLawson70 commented 3 years ago

What issue do you have? Please be as thorough and explicit as possible.

Getting the below errors in my HomeBridge log - the two warnings repeat about every 3 minutes. The sequence number changes every time. The plugin is working fine, devices are controllable and responding correctly in the Home app

Details of your setup.

HomeBridge (1.3.0) + config-ui (4.39.0) + Docker (Synology NAS)

HomeBridge 1.3.0

npm 16.14.10 node.js 14.15.5

eWeLink plugin version 4.7.6

2x Sonoff Micro USB Smart Adapters

Please paste any relevant logs below.

[2/22/2021, 11:05:10 AM] [eWeLink] WS login failed as Unknown WS parameters received
{
  "error": 406,
  "apikey": "2a9c7a8f-REDACTED",
  "sequence": "1613991910244",
  "actionName": "userOnline"
}{.
[2/22/2021, 11:05:10 AM] [eWeLink] WS unknown command received.
{
  "error": 406,
  "apikey": "2a9c7a8f-REDEACTED",
  "sequence": "1613991910244",
  "actionName": "userOnline",
  "params": {}
}
bwp91 commented 3 years ago

Hi @SimonLawson70

This is an authentication issue which can happen in a number of circumstances, eg

Please make sure:

Also use your main ewelink credentials for the app AND homebridge if you don’t already. Let me know!

neilheyes commented 3 years ago

Hi, yes this has started happening to me too today.

SimonLawson70 commented 3 years ago

OK, logged out of the eWeLink app on my phone, did a complete restart of HomeBridge (restarted the Docker container) and everything seems fine. The error messages have gone and my Sonoff switches are accessible and responding in the Home app.

Thanks

bwp91 commented 3 years ago

OK, logged out of the eWeLink app on my phone, did a complete restart of HomeBridge (restarted the Docker container) and everything seems fine. The error messages have gone and my Sonoff switches are accessible and responding in the Home app.

Thanks

Oh good news!

Out of interest, I noticed you have the micro USB adaptors. Do they work in LAN mode? From the logs you will be able to tell.

bwp91 commented 3 years ago

You can see on my 'Supported Devices' wiki page, it's the only device with a LAN mode question mark!

https://github.com/bwp91/homebridge-ewelink/wiki/Supported-Devices

SimonLawson70 commented 3 years ago

I assume the answer to that is "yes" from these log entries:

[2/22/2021, 12:25:46 PM] [eWeLink] [Sonoff Micro 227] initialised and found locally with IP [192.REDACTED]. [2/22/2021, 12:25:47 PM] [eWeLink] [Sonoff Micro 384] initialised and found locally with IP [192.REDACTED].

bwp91 commented 3 years ago

Could you post the logs of using Home app to control one of the devices?

SimonLawson70 commented 3 years ago

Nothing much shows up in the Homebridge log, just:

[2/22/2021, 1:42:04 PM] [eWeLink] [Sonoff Micro 227] current state [off]. [2/22/2021, 1:42:06 PM] [eWeLink] [Sonoff Micro 227] current state [on].

It works perfectly, and instantly - there's no delay between the command in the Home app and the switch responding which makes me think it is LAN connected, not via Cloud

bwp91 commented 3 years ago

Ah sorry I forgot to mention setting the plugin debug setting to true. this would confirm.

on a standard internet connection the web socket (ie non lan mode) can be just as fast as lan mode.

if you are able to post the logs (in debug mode!) of switching on/off a device, that would be super :)

neilheyes commented 3 years ago

I did the same (and upgraded homebridge to 1.3 and the errors have gone) - although weirdly one of mine mini's has dropped off the lan

SimonLawson70 commented 3 years ago

Like this:

[2/22/2021, 3:10:34 PM] [eWeLink] [Sonoff Micro 227] current state [on]. [2/22/2021, 3:10:34 PM] [eWeLink] [Sonoff Micro 227] receiving update {"switches":[{"switch":"on","outlet":0},{"switch":"off","outlet":1},{"switch":"off","outlet":2},{"switch":"off","outlet":3}],"online":true,"updateSource":"WS"}. [2/22/2021, 3:10:34 PM] [eWeLink] [Sonoff Micro 227] receiving update {"switches":[{"switch":"on","outlet":0},{"switch":"off","outlet":1},{"switch":"off","outlet":2},{"switch":"off","outlet":3}],"online":true,"updateSource":"LAN"}. [2/22/2021, 3:10:35 PM] [eWeLink] [Sonoff Micro 227] receiving update {"switches":[{"switch":"on","outlet":0},{"switch":"off","outlet":1},{"switch":"off","outlet":2},{"switch":"off","outlet":3}],"online":true,"updateSource":"LAN"}. [2/22/2021, 3:10:37 PM] [eWeLink] [Sonoff Micro 227] sending update {"switches":[{"switch":"off","outlet":0},{"switch":"off","outlet":1},{"switch":"off","outlet":2},{"switch":"off","outlet":3}]}. [2/22/2021, 3:10:37 PM] [eWeLink] [Sonoff Micro 227] current state [off]. [2/22/2021, 3:10:37 PM] [eWeLink] [Sonoff Micro 227] receiving update {"switches":[{"switch":"off","outlet":0},{"switch":"off","outlet":1},{"switch":"off","outlet":2},{"switch":"off","outlet":3}],"online":true,"updateSource":"WS"}. [2/22/2021, 3:10:37 PM] [eWeLink] [Sonoff Micro 227] receiving update {"switches":[{"switch":"off","outlet":0},{"switch":"off","outlet":1},{"switch":"off","outlet":2},{"switch":"off","outlet":3}],"online":true,"updateSource":"LAN"}. [2/22/2021, 3:10:37 PM] [eWeLink] [Sonoff Micro 227] receiving update {"switches":[{"switch":"off","outlet":0},{"switch":"off","outlet":1},{"switch":"off","outlet":2},{"switch":"off","outlet":3}],"online":true,"updateSource":"WS"}. [2/22/2021, 3:10:38 PM] [eWeLink] [Sonoff Micro 227] receiving update {"switches":[{"switch":"off","outlet":0},{"switch":"off","outlet":1},{"switch":"off","outlet":2},{"switch":"off","outlet":3}],"online":true,"updateSource":"LAN"}.

That's starting with the switch on, then turning it off and back on

bwp91 commented 3 years ago

This is perfect thank you. Yes looks like these devices do support LAN mode so I can turn that question mark into a green yes 👍

Also in the next version of the plugin, if this original error 406 is received then a log entry will appear with a link to this issue, so anyone who receives it in the future has a point of reference.

Glad you both got it working in the end!

github-actions[bot] commented 3 years ago

This issue has been marked as complete as I believe the original query has been fixed/answered or will not be actioned. The issue will be closed in three days. If you feel the issue requires further attention then please let me know. Thanks!

no-response[bot] commented 3 years ago

This issue has been automatically closed as it was marked as complete and has had no further responses within three days. If you are still experiencing problems related to the original issue then please reply to this message and the issue will be reopened if necessary. Thank you.

fred-cardoso commented 2 years ago

I've been experiencing exactly the same issue (the original one) recently. This happened out of nowhere. The interesting thing is - Everytime I restart HomeBridge I'm logged out from the application, and every time I login on the application, I'm logged out from the HomeBridge plugin. Any clues?

These are the only two places where I'm using my account.

Thanks.

bwp91 commented 2 years ago

Hi @fred-cardoso Please see release notes for version 10 of the plugin https://github.com/bwp91/homebridge-ewelink/blob/latest/CHANGELOG.md

It has been great all this time to be able to use the same ewelink account for both the app and the plugin. however due to recent ewelink changes on their end, it’s now necessary to have different accounts again for the app and the plugin (using the same account will create these 406 errors)

fred-cardoso commented 2 years ago

Hi @bwp91

Thank you very much for the fast answer. I completely missed that changelog. I ensured the plugin was updated but that was it. I'm sorry for the trouble!