Control Sonoff Devices with eWeLink (original) firmware over LAN and/or Cloud

@AlexxIT first of all… Thank you! What a great integration. Secondly, I have the latest WiFi connected door sensor from sonoff. After adding it in the eWelink app, I resynced to home Assistant, and although it shows up as a door binary sensor in home Assistant, it shows as offline

Share it to my account with ewelink app [email protected]

Turns out that I just needed to open and close the door to activate the sensor. It is showing up correctly now

Just shared- let me know if I can help further (happy to send you a door sensor if that might help)

Oh. I received today my ZigBee Bridge. And now I see yours on the list. I’ll see what I can do.

3 Likes

Hi,

Recently after a HACS update my sonoff switch is no longer working. I have rebooted and also reinstalled the integration. Any ideas? Hacs version = 1.1.2

image

I have similar issue:
Annotation 2020-07-16 082407

But I have no idea what is wrong…

@Mship check errors in log

@monaco you have another working program with same ewelink account.
Read the instructions on the link

Log details below: Nothing has changed on my side (other than HACS and HA updates). Has been working fine for a couple of months until about a week ago.

Log Details (ERROR)
Logger: homeassistant.setup
Source: custom_components/sonoff/sonoff_cloud.py:258
First occurred: 8:38:49 AM (1 occurrences)
Last logged: 8:38:49 AM

Error during setup of component sonoff
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 193, in _async_setup_component
    result = await asyncio.wait_for(task, SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/config/custom_components/sonoff/__init__.py", line 103, in async_setup
    config[CONF_PASSWORD]):
  File "/config/custom_components/sonoff/sonoff_main.py", line 122, in cloud_login
    return await self.cloud.login(username, password)
  File "/config/custom_components/sonoff/sonoff_cloud.py", line 258, in login
    self._apikey = resp['user']['apikey']
KeyError: 'user'

Very happy with this component, thank you @AlexxIT
One question: Is the service sonoff.update_consumption working for you guys? I’m manually calling the service, but consumption is not reported for POW R2. Log don’t give me any clue.

2020-07-19 12:56:32 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=sonoff, service=update_consumption, service_data=>
2020-07-19 12:56:32 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.2727937392] Sending {'id': 148, 'type': 'result', 'success': True, 'result': {'context': Context(user_id='8a35148478c64943bd18fe4320d1920e', parent_id=None, id='1b530437e04c4ca7b14d0eca3e45c6d0')}}

Tried it both in cloud and local mode, but I can’t seem any attributes with daily consumption. Am I missing something?

I have same account in use on the tablet that is only for monitoring. Could that be the issue?

@prates update_consumption load data from ewelink servers

@monaco yes it could. You need to use another account with shared devices.

@AlexxIT understood. Well, I’ve also tried this service in “cloud mode”, but still no answer. Thanks anyway.

Check logs. Maybe there are some errors in it.

Now I can see some errors in the log, but still do not understand what’s going on

2020-07-24 09:43:41 ERROR (MainThread) [custom_components.sonoff.sonoff_cloud] Coolkit API
Traceback (most recent call last):
  File "/data/data/com.termux/files/home/homeassistant/lib/python3.8/site-packages/aiohttp/connector.py", line 964, in _create_direct_connection
    hosts = await asyncio.shield(self._resolve_host(
  File "/data/data/com.termux/files/home/homeassistant/lib/python3.8/site-packages/aiohttp/connector.py", line 829, in _resolve_host
    addrs = await \
  File "/data/data/com.termux/files/home/homeassistant/lib/python3.8/site-packages/aiohttp/resolver.py", line 29, in resolve
    infos = await self._loop.getaddrinfo(
  File "/data/data/com.termux/files/usr/lib/python3.8/asyncio/base_events.py", line 825, in getaddrinfo
    return await self.run_in_executor(
  File "/data/data/com.termux/files/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/data/data/com.termux/files/usr/lib/python3.8/socket.py", line 918, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 7] No address associated with hostname

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

Traceback (most recent call last):
  File "/data/data/com.termux/files/home/.homeassistant/custom_components/sonoff/sonoff_cloud.py", line 108, in _api
    r = await coro
  File "/data/data/com.termux/files/home/homeassistant/lib/python3.8/site-packages/aiohttp/client.py", line 480, in _request
    conn = await self._connector.connect(
  File "/data/data/com.termux/files/home/homeassistant/lib/python3.8/site-packages/aiohttp/connector.py", line 523, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/data/data/com.termux/files/home/homeassistant/lib/python3.8/site-packages/aiohttp/connector.py", line 858, in _create_connection
    _, proto = await self._create_direct_connection(
  File "/data/data/com.termux/files/home/homeassistant/lib/python3.8/site-packages/aiohttp/connector.py", line 971, in _create_direct_connection
    raise ClientConnectorError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host us-api.coolkit.cc:8080 ssl:None [No address associated with hostname]
1 Like

You have some problems with Internet on your HA.

Hello AlexIT… wonderful integration, thank you.
I bought a couple of switches (mini, dualr2, powr2, 4ch pro r2) and connected with eWeLink… succesful.
I’ve setup HA with
sonoff:
username: [email protected]
password: xxxxxx
mode: local
reload: always # update device list every time HA starts

No devices imported…
Question: will ALL or only “devices currently on” devices synced?

Thanks for your support

@FreekBos Leave only username and password in config. May be you have some problems with local connection.