AlexxIT / SonoffLAN

Control Sonoff Devices with eWeLink (original) firmware over LAN and/or Cloud from Home Assistant
https://github.com/AlexxIT/Blog
MIT License
2.74k stars 416 forks source link

Cloud WS exception (error 406) #1011

Closed hanskiepl closed 7 months ago

hanskiepl commented 2 years ago

i have got latest version of your pllugin Generally it works but i dont know why it ocasionally stops working on every single day. eWelink app works fine when homeasistatnt stops reading data.

Logger: custom_components.sonoff.core.ewelink.cloud
Source: custom_components/sonoff/core/ewelink/cloud.py:318
Integration: Sonoff (documentation, issues)
First occurred: 14:28:49 (5 occurrences)
Last logged: 14:50:07

Cloud WS exception
Traceback (most recent call last):
  File "/config/custom_components/sonoff/core/ewelink/cloud.py", line 318, in connect
    raise Exception(resp)
Exception: {'error': 406, 'apikey': 'xxxxxxxxxxxxxxxxxx', 'sequence': '166600000029875', 'actionName': 'userOnline'}

Issues link looks like below 

2022-10-24 00:40:13 [D] 100168ba28 <= Cloud3 | {'power': '46.21', 'voltage': '228.75', 'current': '0.26'} | None
2022-10-24 00:41:03 [E] Cloud WS exception|  File "/config/custom_components/sonoff/core/ewelink/cloud.py", line 318, in connect|    raise Exception(resp)|Exception: {'error': 406, 'apikey': '3c104dcf-90690000000-3180fb1f80ef', 'sequence': '1666564863386', 'actionName': 'userOnline'}|
2022-10-24 00:41:03 [D] CLOUD True => False
2022-10-24 00:41:03 [D] Cloud connection retrying in 15 seconds
2022-10-24 00:41:19 [E] Cloud WS exception|  File "/config/custom_components/sonoff/core/ewelink/cloud.py", line 318, in connect|    raise Exception(resp)|Exception: {'error': 406, 'apikey': '3c104dcf-9069-⁰00000007-3180fb1f80ef', 'sequence': '1666564878993', 'actionName': 'userOnline'}|
2022-10-24 00:41:19 [D] CLOUD False => False
2022-10-24 00:41:19 [D] Cloud connection retrying in 60 seconds
2022-10-24 00:42:19 [E] Cloud WS exception|  File "/config/custom_components/sonoff/core/ewelink/cloud.py", line 318, in connect|    raise Exception(resp)|Exception: {'error': 406, 'apikey': '3c104dcf-9069-0000000-3180fb1f80ef', 'sequence': '1666564939347', 'actionName': 'userOnline'}|
2022-10-24 00:42:19 [D] CLOUD False => False
2022-10-24 00:42:19 [D] Cloud connection retrying in 300 seconds
2022-10-24 00:47:19 [E] Cloud WS exception|  File "/config/custom_components/sonoff/core/ewelink/cloud.py", line 318, in connect|    raise Exception(resp)|Exception: {'error': 406, 'apikey': '3c104dcf-9069-0000000-3180fb1f80ef', 'sequence': '1666565239961', 'actionName': 'userOnline'}|
2022-10-24 00:47:20 [D] CLOUD False => False
2022-10-24 00:47:20 [D] Cloud connection retrying in 900 seconds
2022-10-24 01:02:20 [E] Cloud WS exception|  File "/config/custom_components/sonoff/core/ewelink/cloud.py", line 318, in connect|    raise Exception(resp)|Exception: {'error': 406, 'apikey': '3c104dcf-9069-00000000-3180fb1f80ef', 'sequence': '1666566140417', 'actionName': 'userOnline'}|
2022-10-24 01:02:20 [D] CLOUD False => False
2022-10-24 01:02:20 [D] Cloud connection retrying in 3600 seconds
2022-10-24 02:02:20 [E] Cloud WS exception|  File "/config/custom_components/sonoff/core/ewelink/cloud.py", line 318, in connect|    raise Exception(resp)|Exception: {'error': 406, 'apikey': '3c104dcf-9069-00⁰000000-3180fb1f80ef', 'sequence': '1666569740881', 'actionName': 'userOnline'}|
2022-10-24 02:02:20 [D] CLOUD False => False
2022-10-24 02:02:20 [D] Cloud connection retrying in 3600 seconds
2022-10-24 03:02:21 [E] Cloud WS exception|  File "/config/custom_components/sonoff/core/ewelink/cloud.py", line 318, in connect|    raise Exception(resp)|Exception: {'error': 406, 'apikey': '3c104dcf-9069-0000000-3180fb1f80ef', 'sequence': '1666573341784', 'actionName': 'userOnline'}|
2022-10-24 03:02:21 [D] CLOUD False => False
2022-10-24 03:02:21 [D] Cloud connection retrying in 3600 seconds
yurtaevalex commented 2 years ago

ver. v3.3.1

Logger: custom_components.sonoff.core.ewelink.cloud
Source: custom_components/sonoff/core/ewelink/cloud.py:318
Integration: Sonoff ([documentation](https://github.com/AlexxIT/SonoffLAN), [issues](https://github.com/AlexxIT/SonoffLAN/issues))
First occurred: 30 октября 2022 г., 12:42:06 (51 occurrences)
Last logged: 12:06:11

Cloud WS exception
Traceback (most recent call last):
  File "/config/custom_components/sonoff/core/ewelink/cloud.py", line 318, in connect
    raise Exception(resp)
Exception: {'error': 406, 'apikey': 'xxxxx', 'sequence': 'xxxxx', 'actionName': 'userOnline'}
AlexxIT commented 2 years ago

Is problem still actual?

yurtaevalex commented 2 years ago

Проблема еще актуальна?

Да

hanskiepl commented 2 years ago

Is problem still actual?

Yes, still the same problem. Sometime once sometime a few times daily :-(

phantomdez commented 1 year ago

I have this issue as well. I am unable to add new devices to home assistant it seems. Existing devices are working normally. The new device is working in the eWelink app but I cannot see it in Home assistant.

pauldanieltudor commented 1 year ago

I get the same error but in my case it is after some 2-3 days of working perfectly and if I restart HA it works fine again, the problem ony manifests on devices that are connected via cloud only (not in my home LAN) Any fix on this?

Cloud WS exception| File "/config/custom_components/sonoff/core/ewelink/cloud.py", line 318, in connect| raise Exception(resp)|Exception: {'error': 406, 'apikey': 'actionName': 'userOnline'

mjburton commented 1 year ago

I have the same issue after upgrading to the latest HA and 3.3.1, yet the debug log suggests it has found the one device I have:

    ],
    "level": "WARNING",
    "source": [
      "custom_components/sonoff/core/ewelink/cloud.py",
      192
    ],
    "timestamp": 1670769011.3212235,
    "exception": "Traceback (most recent call last):\n  File \"/config/custom_components/sonoff/__init__.py\", line 199, in internal_normal_setup\n    devices = await registry.cloud.get_devices(homes)\n  File \"/config/custom_components/sonoff/core/ewelink/cloud.py\", line 192, in get_devices\n    raise Exception(resp[\"msg\"])\nException: cannot found access token info\n",
    "count": 1,
    "first_occurred": 1670769011.3212235
  },
  {
    "name": "custom_components.sonoff.core.ewelink.cloud",
    "message": [
      "Cloud WS exception"
    ],
    "level": "ERROR",
    "source": [
      "custom_components/sonoff/core/ewelink/cloud.py",
      318
    ],
    "timestamp": 1670769387.9991748,
    "exception": "Traceback (most recent call last):\n  File \"/config/custom_components/sonoff/core/ewelink/cloud.py\", line 318, in connect\n    raise Exception(resp)\nException: {'error': 406, 'apikey': 'xxxxxxxxxxx', 'sequence': '1670769011661', 'actionName': 'userOnline'}\n",
    "count": 4,
    "first_occurred": 1670769011.688297
  }
fuzzybear62 commented 1 year ago

Same issue, version 3.3.1 HA 2023.1.0

This is the output log:

2023-01-05 16:17:00.639 ERROR (MainThread) [custom_components.sonoff.core.ewelink.cloud] Cloud WS exception
Traceback (most recent call last):
  File "/config/custom_components/sonoff/core/ewelink/cloud.py", line 318, in connect
    raise Exception(resp)
Exception: {'error': 406, 'apikey': 'XXXXXXXX', 'sequence': 'XXXXX', 'actionName': 'userOnline'}
mjburton commented 1 year ago

To resolve this I created another Sonoff account and shared the device with it. Looks to be an issue with being logged in two places (app on phone, Hass)

On Thu, 5 Jan 2023 at 16:04, Aldo Curinga @.***> wrote:

Same issue, version 3.3.1 HA 2023.1.0

This is the output log: 2023-01-05 16:17:00.639 ERROR (MainThread) [custom_components.sonoff.core.ewelink.cloud] Cloud WS exception Traceback (most recent call last): File "/config/custom_components/sonoff/core/ewelink/cloud.py", line 318, in connect raise Exception(resp) Exception: {'error': 406, 'apikey': 'XXXXXXXX', 'sequence': 'XXXXX', 'actionName': 'userOnline'}

— Reply to this email directly, view it on GitHub https://github.com/AlexxIT/SonoffLAN/issues/1011#issuecomment-1372412382, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABREFLAQB23XCA4EAN6JAXDWQ3WKBANCNFSM6AAAAAARL3GGDY . You are receiving this because you commented.Message ID: @.***>

fuzzybear62 commented 1 year ago

I'll try thank you

AlexxIT commented 1 year ago

This is authorization error from cloud. I don't know how to reproduce it. And don't know how to fix it. Make sure you using latest integration version with latest version for cloud API

pauldanieltudor commented 1 year ago

It seems a year passed, many updates since then, problem persists: Cloud devices go permanently offline (unavailable) after 2-4 days, sometimes they work fine for 2-3 weeks, just had a record of almost a month, so it is indeed a rare occurance. Reloading the integration does not help, only HA restart fixes the issue but it does fix it every single time. I do get a cloud authentification error in logs but it does not help much:

Cloud WS exception| File "/config/custom_components/sonoff/core/ewelink/cloud.py", line 323, in connect| raise Exception(resp)|Exception: {'error': 406, 'reason': 'Authentication Failed', 'apikey': 'sequence': '1695612246995', 'actionName': 'userOnline'} CLOUD False => False

Devices in LAN never fail, only those outside of my LAN have this issue, they are actually in a subnet of my LAN but same thing: not in my LAN. Each time I find the offline in HA I check the ewelink app and there they are always working.

Not sure it helps but in older versions (2022-ish) reloading the integration used to work to fix this issue, sadly since oct 2022 (could be off by 6 months) reloading stopped helping and now requires HA restart.

pauldanieltudor commented 1 year ago

Also quick reload does not fix the issue either, anything (including updates to core or Supervisor) that involves HA restart will bring them right back up.

farmerkz commented 1 year ago

The same problem, I won’t tell you the exact time it appeared, but it seems that after the HAOS update a few days ago.

2023-10-06 00:40:37.825 ERROR (MainThread) [custom_components.sonoff.core.ewelink.cloud] Cloud WS exception
Traceback (most recent call last):
  File "/config/custom_components/sonoff/core/ewelink/cloud.py", line 323, in connect
    raise Exception(resp)
Exception: {'error': 406, 'reason': 'Authentication Failed', 'apikey': 'xxxxxxxxxxxxxxxx', 'sequence': 'dddddddddd', 'actionName': 'userOnline'}

A quick reload does not solve the problem; after rebooting HAOS, the problem disappears for about a day.

eduardoit commented 1 year ago

I live day after day with the same problem. I have all the updates up to date.

This error originated from a custom integration.

Logger: custom_components.sonoff.core.ewelink.cloud
Source: custom_components/sonoff/core/ewelink/cloud.py:323
Integration: Sonoff (documentation, issues)
First occurred: 9 de noviembre de 2023, 23:59:09 (15 occurrences)
Last logged: 10:21:02

Cloud WS exception
Traceback (most recent call last):
  File "/config/custom_components/sonoff/core/ewelink/cloud.py", line 323, in connect
    raise Exception(resp)
Exception: {'error': 406, 'reason': 'Authentication Failed', 'apikey': 'xxxxxxxxxxxxx', 'sequence': 'xxxxxxxxxxxx', 'actionName': 'userOnline'}

I reload the integration and it works again for a couple of hours.

marinus61 commented 9 months ago

Hi AlexxIT, thks works now, appriciate the great work you done for this great integration

AlexxIT commented 9 months ago

I didn't do anything about this issue. As I said earlier, it's a cloud error.

marinus61 commented 9 months ago

Anyway happy that your great integration is working again. Thks for your swift "support", maybe you have magical skills :)

AlexxIT commented 7 months ago

PS. "Authentication Failed" can be if you logged in with same account from another place.

AlexxIT commented 7 months ago

https://github.com/AlexxIT/SonoffLAN/releases/tag/v3.7.0