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.66k stars 412 forks source link

Invalid config - Cannot connect to host eu-api.coolkit.cc:8080 - Can't connect to eWeLink Cloud #227

Closed manosioa closed 4 years ago

manosioa commented 4 years ago

Hi,

I have the following error in notifications: image

The installation is fresh.

Environment:
Home Assistant Core release with the issue: Home Assistant 0.114.4

My Configuration yaml:

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Text to speech
tts:
  - platform: google_translate

#Magichome LED strip
light:
  - platform: flux_led
    devices:
      192.168.1.110:
        name: TV Light
        mode: "rgbw"

#Sonoff & EweLink Devices
sonoff:
  username: xxxxxxxxxxxxxxx
  password: xxxxxxxxxxxxx

#Yeelight Bubls
yeelight:
  devices:
    192.168.1.193:
      name: Tall Lamp
    192.168.1.213:
      name: Ball Lamp
    192.168.1.128:
      name: Office Lamp

#LG WebOS TV
webostv:
  host: 192.168.1.50
  #other settings
  turn_on_action:
    service: wake_on_lan.send_magic_packet
    data:
      mac: xxxxxxxxxxxxxxxxxx
      broadcast_address: 192.168.1.45

#Broadlink RM MIni 3
remote:
  - platform: broadlink
    host: 192.168.1.126
    mac: xxxxxxxxxxxxxxxxxxxx
  - platform: broadlink
    host: 192.168.1.127
    mac: xxxxxxxxxxxxxxxxxxxx

smartir:

switch:
  - platform: broadlink
    host: 192.168.1.126
    mac: xxxxxxxxxxxxxxxxx
    type: rm_mini
  - platform: broadlink
    host: 192.168.1.127
    mac: xxxxxxxxxxxxxxxxxx
    type: rm_mini

#Air Condition
climate:
  - platform: smartir
    name: Living Room A/C
    unique_id: living_room_ac
    device_code: 1960
    controller_data: 192.168.1.126
  - platform: smartir
    name: Bedroom A/C
    unique_id: bedroom_ac
    device_code: 1960
    controller_data: 192.168.1.127

#Soundbar & BluRay
media_player:
  - platform: smartir
    name: Soundbar
    unique_id: soundbar
    device_code: 1041
    controller_data: 192.168.1.126
  - platform: smartir
    name: Blue Ray
    unique_id: bluray
    device_code: 1020
    controller_data: 192.168.1.126

#Camera
camera:
  - platform: mjpeg
    mjpeg_url: http://192.168.1.202/mjpeg

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
`

In the logs:

`Log Details (ERROR)
Logger: homeassistant.setup
Source: custom_components/sonoff/sonoff_cloud.py:282
First occurred: 12:11:51 AM (1 occurrences)
Last logged: 12:11:51 AM

Error during setup of component sonoff
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 191, in _async_setup_component
    result = await task
  File "/config/custom_components/sonoff/__init__.py", line 102, in async_setup
    if await registry.cloud_login(config[CONF_USERNAME],
  File "/config/custom_components/sonoff/sonoff_main.py", line 110, in cloud_login
    return await self.cloud.login(username, password)
  File "/config/custom_components/sonoff/sonoff_cloud.py", line 282, in login
    if resp.get('error') == 406:
AttributeError: 'NoneType' object has no attribute 'get'`
`Log Details (ERROR)
Logger: custom_components.sonoff.sonoff_cloud
Source: custom_components/sonoff/sonoff_cloud.py:147
Integration: sonoff (documentation)
First occurred: 12:11:51 AM (1 occurrences)
Last logged: 12:11:51 AM

Coolkit API error: Cannot connect to host eu-api.coolkit.cc:8080 ssl:default [Connect call failed ('52.57.118.192', 8080)]
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 936, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore  # noqa
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1025, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1010, in create_connection
    sock = await self._connect_sock(
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 924, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 494, in sock_connect
    return await fut
  File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 526, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
TimeoutError: [Errno 110] Connect call failed ('52.57.118.192', 8080)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/sonoff/sonoff_cloud.py", line 147, in _api
    r = await coro
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 480, in _request
    conn = await self._connector.connect(
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 523, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 858, in _create_connection
    _, proto = await self._create_direct_connection(
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 1004, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 980, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 943, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host eu-api.coolkit.cc:8080 ssl:default [Connect call failed ('52.57.118.192', 8080)]`
`Log Details (WARNING)
Logger: homeassistant.setup
Source: /usr/local/lib/python3.8/asyncio/events.py:81
First occurred: 12:11:29 AM (1 occurrences)
Last logged: 12:11:29 AM

Setup of sonoff is taking over 10 seconds.`

Any suggestions?

desigan321 commented 4 years ago

Cannot connect to host eu-api.coolkit.cc:8080 ssl:default [Connect call failed ('52.57.118.192', 8080)]

Check internet connectivity of the device.

manosioa commented 4 years ago

Hi,

@desigan321 Check connectivity of which device? The HA is working without any issue and is connected to the internet.

It can ping the ip and port image image

All of my sonoff devices are working through the Alexa skill and the EWeLink app. @AlexxIT any ideas?

Thanks :)

Cannot connect to host eu-api.coolkit.cc:8080 ssl:default [Connect call failed ('52.57.118.192', 8080)]

Check internet connectivity of the device.

desigan321 commented 4 years ago

Try adding debug tracing to Sonoff portion of the config file. Restart HA and check if anything shows up in the logs.

Sonoff & EweLink Devices

sonoff: username: xxxxxxxxxxxxxxx password: xxxxxxxxxxxxx debug: true

manosioa commented 4 years ago

@desigan321 After i added the "debug: true", I got this : image

When i click on the "Open Log" i get a blank page.

The Logs from the HA:

`Log Details (ERROR)
Logger: homeassistant.setup
Source: custom_components/sonoff/sonoff_cloud.py:282
First occurred: 4:17:58 PM (1 occurrences)
Last logged: 4:17:58 PM

Error during setup of component sonoff
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 191, in _async_setup_component
    result = await task
  File "/config/custom_components/sonoff/__init__.py", line 102, in async_setup
    if await registry.cloud_login(config[CONF_USERNAME],
  File "/config/custom_components/sonoff/sonoff_main.py", line 110, in cloud_login
    return await self.cloud.login(username, password)
  File "/config/custom_components/sonoff/sonoff_cloud.py", line 282, in login
    if resp.get('error') == 406:
AttributeError: 'NoneType' object has no attribute 'get''
'Log Details (ERROR)
Logger: custom_components.sonoff.sonoff_cloud
Source: custom_components/sonoff/sonoff_cloud.py:147
Integration: sonoff (documentation)
First occurred: 4:17:58 PM (1 occurrences)
Last logged: 4:17:58 PM

Coolkit API error: Cannot connect to host eu-api.coolkit.cc:8080 ssl:default [Connect call failed ('52.57.118.192', 8080)]
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 936, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore  # noqa
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1025, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1010, in create_connection
    sock = await self._connect_sock(
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 924, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 494, in sock_connect
    return await fut
  File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 526, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
TimeoutError: [Errno 110] Connect call failed ('52.57.118.192', 8080)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/sonoff/sonoff_cloud.py", line 147, in _api
    r = await coro
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 480, in _request
    conn = await self._connector.connect(
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 523, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 858, in _create_connection
    _, proto = await self._create_direct_connection(
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 1004, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 980, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 943, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host eu-api.coolkit.cc:8080 ssl:default [Connect call failed ('52.57.118.192', 8080)]
Log Details (WARNING)
Logger: homeassistant.setup
Source: /usr/local/lib/python3.8/asyncio/events.py:81
First occurred: 4:17:36 PM (1 occurrences)
Last logged: 4:17:36 PM

Setup of sonoff is taking over 10 seconds.
desigan321 commented 4 years ago

The debug logs don't show much different.

Check/Try the following:

  1. Go to Configuration - Server Controls - Check Configuration (Does it return "Configuration Valid"?)
  2. Switch off all phones/devices that have the EweLink/Alexa app installed to check if multiple accounts logging in could be the issue.
  3. Comment out everything extra in your configuration.yaml file and leave only the Sonoff lines - to rule out any other issue that might be causing a conflict somewhere.

A) Are you using HACS or direct folder copy of Sonoff into custom_components folder? B) What version of SonoffLAN repo are you using? v2.3.1? Have you tried another version? C) Are you running HA from virtual machine or Raspberry Pi? D) What version of eweLink app are you using on your phone?

manosioa commented 4 years ago

@desigan321 I followed all your suggestions. Here are the results:

The debug logs don't show much different.

Check/Try the following:

1. Go to Configuration - Server Controls - Check Configuration (Does it return "Configuration Valid"?) Yes! 2. Switch off all phones/devices that have the EweLink/Alexa app installed to check if multiple accounts logging in could be the issue. Logged out of the iOS app, the only app that I use. 3. Comment out everything extra in your configuration.yaml file and leave only the Sonoff lines - to rule out any other issue that might be causing a conflict somewhere. I did and left only Sonoff lines. I get this on the debug log:

2020-09-03 00:49:52  DEBUG    main          SysInfo: {'version': '0.114.4', 'dev': False, 'hassio': True, 'virtualenv': False, 'python_version': '3.8.3', 'docker': True, 'arch': 'x86_64', 'os_name': 'Linux', 'os_version': '4.19.107-Unraid', 'supervisor': '235', 'host_os': None, 'chassis': None, 'docker_version': '19.03.5'}
2020-09-03 00:49:52  DEBUG    main          AUTO mode start
2020-09-03 00:50:25  ERROR    sonoff_cloud  Coolkit API error: Cannot connect to host eu-api.coolkit.cc:8080 ssl:default [Connect call failed ('...', 8080)]
2020-09-03 00:50:25  ERROR    sonoff_cloud  Login error: None
2020-09-03 00:50:25  WARNING  main          Can't connect to eWeLink Cloud
2020-09-03 00:50:25  INFO     sonoff_local  100099eb90 <= Local1 | No devicekey for device
2020-09-03 00:50:26  INFO     sonoff_local  100099d0f6 <= Local1 | No devicekey for device
2020-09-03 00:55:28  DEBUG    sonoff_local  Zeroconf Removed: eWeLink_100099eb90._ewelink._tcp.local.
2020-09-03 00:55:28  DEBUG    sonoff_local  Zeroconf Removed: eWeLink_100099d0f6._ewelink._tcp.local.

A) Are you using HACS or direct folder copy of Sonoff into custom_components folder? I Used HACS to install the Sonoff B) What version of SonoffLAN repo are you using? v2.3.1? Have you tried another version?I used v.2.3.1. Just tried v.2.3.0 and v2.2.3, with just the sonoff lines in the config and valid config. Same issue. I get the same output on the debug log. C) Are you running HA from virtual machine or Raspberry Pi? HA is running on a docker on Unraid. Had no issues for a month now. D) What version of eweLink app are you using on your phone? iOS v4.4.0.

desigan321 commented 4 years ago

Is hassio in docker configured for bridge or host in network config?

Run network docker ls and check. If bridge, change to host (for testing) and restart HA and retry.

manosioa commented 4 years ago

@desigan321 In unraid i chose the hassio_supervisor image All the guides online use this as the docker. You download it on Unraid, start it and it downloads and installs all the required instances. Then you complete the setup as usual.

The only thing that can be changed is Supervisor. It was on bridge. Changed to host. Started the Supervisor (which then automatically runs all the required instances) and it does not start homeassistant, addon_core_configurator,addon_core_ssh. image

When I run homeassistant manually I get this message when I cilck on Supervisor image

I did not have any problems since mid August. Suddenly without me messing around with anything, sonoff devices stopped working. Then i tried some restarts but no luck. The tried to reinstall the HA from scratch,fresh. No luck. Now i'm here. Not knowing whats the issue.

desigan321 commented 4 years ago

When it stopped working the first time, did you get the same errors in the log? "Invalid config", "Can't connect to..." ?

Sometimes when the Sonoff devices stop working even in LOCAL mode (with SONOFFLAN), it could be the IP addresses of the devices changed.

It looks like you have already rebooted your router and everything else. I'm not familiar with Unraid so can't suggest anything further with it.

To rule out any physical network (or docker network config), firewall rules, DuckDNS issues etc., I would suggest installing HA on VirtualBox in a Windows environment and see if that works.

This video explains how to do it with VirtualBox: https://www.youtube.com/watch?v=sVqyDtEjudk

manosioa commented 4 years ago

When it stopped working the first time, did you get the same errors in the log? "Invalid config", "Can't connect to..." ? Yes! Those errors sent me on the trip i described.

Sometimes when the Sonoff devices stop working even in LOCAL mode (with SONOFFLAN), it could be the IP addresses of the devices changed. All of my Sonoff devices use static IP.

It looks like you have already rebooted your router and everything else. I'm not familiar with Unraid so can't suggest anything further with it. Yes, tried every possible sollution i could think of before posting my issue.

To rule out any physical network (or docker network config), firewall rules, DuckDNS issues etc., I would suggest installing HA on VirtualBox in a Windows environment and see if that works.

This video explains how to do it with VirtualBox: https://www.youtube.com/watch?v=sVqyDtEjudk I'm on it.

manosioa commented 4 years ago

@desigan321 Tried everything. Even installing HA on a laptop and installing HA on VM using VirtualBox.

Nothing helped to solve the issue.

I gave up and bought a USB to TTL and DuPont cables and flashed Tasmota on all 10 sonoff devices I have.

Thanks for the help and recommendations.