Sonoff /eWeLink component for original firmware

On 0.90.2 I have this error i copyed sonoff-debug. Py a lot of error there is not but now I have this problemchrome

all I can say here is that my python_version is 3.7.2

where does it say in the README that you have to copy sonoff-debug script too? sonoff-debug even has (albeit, basic) a description of what’s suppose to do!

please read everything 10 times before instant posting here the problem. i feel you might add confusion among the other users when it could be easily avoided.

I’m also having this issue. Can anyone clarify on the config check?

Ive created folder custom_components inside config file. Have the following structure.
config/custom_components/sensor/sonoff.py
config/custom_components/switch/sonoff.py
config/custom_components/sonoff.py

I restarted Hassio after this and all is fine. If I add the following to my configuration.yaml, the config check just hangs with spinning wheel.

sonoff:
  username: [[email protected]]
  password: [MYPASSWORD]
  scan_interval: 60
  grace_period: 600

Edit:
I saw there is a master88+ version. I updated the components folder
config/custom_components/sonoff/init.py
config/custom_components/sonoff/sensor.py
config/custom_components/sonoff/switch.py

but I still have the hanging config checker with the sonoff config in my yaml file.

EDIT 2: FIXED
Turns out I downloaded the init.py incorrectly as error logs showed
File “/config/custom_components/sonoff/init.py”, line 7 <!DOCTYPE html> ^ SyntaxError: invalid syntax .

redownloaded with raw data and config check works…

Now I can continue.

ok now i see all i put all also sonoff debug but i have this error
2019-04-02 00:18:50 ERROR (Thread-17) [websocket] error from callback <bound method Sonoff.on_message of <custom_components.sonoff.Sonoff object at 0x6a4c7b90>>: ‘NoneType’ object has no attribute ‘attributes’
why?can you help me???

I love this component, I have been noticing lately that most of the time when I flip a “switch” (Using HoneKit) that my devices fin’t Change state. If I turn in then back off most of the time they work. Anybody else having this same issue?

Hello !
I installed the SonOff component and it is working fine sofar… with a SonOff 4CH Rev2
My environment: Raspbrry Pi 3B+, HA 0.90.1 in a virtual environment, Python 3.7.2…

Thank you for the great job !

Hi
I’m Having issue with sonof, i have model Sonoff S20.

entity not available
Hassio Version : 0.91.0
i’m using websocket-HA0.88 +
this is the log:

2019-04-04 19:54:07 ERROR (MainThread) [homeassistant.setup] Error during setup of component sonoff
Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/urllib3/connection.py”, line 159, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File “/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py”, line 57, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File “/usr/local/lib/python3.7/socket.py”, line 748, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Try again

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 600, in urlopen
chunked=chunked)
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 343, in _make_request
self._validate_conn(conn)
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 839, in _validate_conn
conn.connect()
File “/usr/local/lib/python3.7/site-packages/urllib3/connection.py”, line 301, in connect
conn = self._new_conn()
File “/usr/local/lib/python3.7/site-packages/urllib3/connection.py”, line 168, in _new_conn
self, “Failed to establish a new connection: %s” % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x72ed68f0>: Failed to establish a new connection: [Errno -3] Try again

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/requests/adapters.py”, line 449, in send
timeout=timeout
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File “/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py”, line 398, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host=‘eu-api.coolkit.cc’, port=8080): Max retries exceeded with url: /api/user/login (Caused by NewConnectionError(’<urllib3.connection.VerifiedHTTPSConnection object at 0x72ed68f0>: Failed to establish a new connection: [Errno -3] Try again’))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/homeassistant/setup.py”, line 151, in _async_setup_component
hass, processed_config)
File “/config/custom_components/sonoff/init.py”, line 52, in async_setup
hass.data[DOMAIN] = Sonoff(config)
File “/config/custom_components/sonoff/init.py”, line 96, in init
self.do_login()
File “/config/custom_components/sonoff/init.py”, line 137, in do_login
headers=self._headers, json=app_details)
File “/usr/local/lib/python3.7/site-packages/requests/api.py”, line 116, in post
return request(‘post’, url, data=data, json=json, **kwargs)
File “/usr/local/lib/python3.7/site-packages/requests/api.py”, line 60, in request
return session.request(method=method, url=url, **kwargs)
File “/usr/local/lib/python3.7/site-packages/requests/sessions.py”, line 533, in request
resp = self.send(prep, **send_kwargs)
File “/usr/local/lib/python3.7/site-packages/requests/sessions.py”, line 646, in send
r = adapter.send(request, **kwargs)
File “/usr/local/lib/python3.7/site-packages/requests/adapters.py”, line 516, in send
raise ConnectionError(e, request=request)

someone?

@yoni3210 did you had problems before with previous HA versions or it just started out of the sudden after you updated to HA 0.91?

The errors are somehow self explanatory, for some reason HA instance cannot access the coolkit.cc servers (the one that power the eWeLink app) please make sure you didn’t installed recently anything that can qualify as a firewall (like piHole or alike). Alternatively to do some more basic debugging try to run the sonoff-debug.py script, it uses the same flow of the component and could help you figure out what’s going on with your instance.

worked just fine, but today for some reason stopped working on version 0.88, so i upgrade and it still not working. but until today it was working perfectly

then it’s nothing i can do i’m 99% sure it’s a network problem. try to use another internet source like sharing the internet from your phone via cable/wifi, restart pc/HA and see if it works again.

1 Like

You are right, tried restarting the router 3 times.
Only when I restarted the modem, problem resolved!
Tx

With the update to 0.91 I keep getting messages to switch from “\sensor\sonoff.py” to “\sonoff\sensor.py”, but after trying this- the component wouldn’t work. Should I be concerned with changing it? Or just leave it how it is for now?

I’m using the websocket version, as the regular version was far too slow for me at the time of installing it; I’m not sure if that’s changed or not with the latest version, but figured if it ain’t broke, don’t fix it. If it’s recommended to switch to the master version of it though, I will; as long as the lag issue has been fixed.

The websocket version works almost instantly for me, whereas the last time I used the master version, there was a long delay between switch updates (+/- 5 seconds)

@pmcenaney scroll/read up a dozen (or more) of replies. all already explained.

Sorry, I couldn’t find the posts you’re talking about. I went back a few weeks, and did see someone on the master branch mention trying their files in the “/sonoff/sensor.py” configuration, but there wasn’t much information on it, and I’m currently using the websocket branch. Also, I was just curious if the concensus is that I should be using the websocket or master branch. My main concern is having it fast, without lag, since some of my automations require that; which is why I’ve been using websocket, but I’m not sure if the master branch has been updated to be faster since I’ve last tried it or not.

The files on github are arranged in the folders exactly as they should be under custom_components. There is even a README pointing out exactly how they should be named and arranged.

custom_components
    └── sonoff
        └── __init__.py
        └── switch.py
        └── sensor.py

I am not sure how much easier anyone can make it.

I just went back to git to have another look, I hadn’t noticed the difference in folder structure between the websocket branch (the branch I’ve been on) and websocket-HA0.88+. Likely because I was on 0.87 when I installed the component. So yes, I did read the readme- but it was the readme for the branch that I had installed at the time; I didn’t notice the difference in the newer one until now (likely since I wasn’t using the new version at the time of installing the component and had since forgotten about it being there), but yes, the instructions are very simple. Thanks for getting me to have another look at it, and notice the newer branch; even if it was an extremely condescending way of doing it.

@peterbuga I saw you have updated on github yesterday. I have websocket for +0.88HA. Wich version should I update now? I see that only init.py is updated, so update only this file? Thanks for great work! I hated flashing sonoffs

@warcanoid now that (mostly) everyone figured it out the global HA0.88+ components structure change, i’m moving towards exclusive support for it too, therefore i released/archived the old versions (if someone might ever need them)

right now master holds again the latest stable (i hope!) changes (websocket branch will be removed soon too) everything got merged into it and gone are the polling days, websocket all the way :muscle: (as general knowledge i’m still using polling of data as a fallback to update the states and sensors)

if you have only switch devices you can easily avoid update the component, not much has changed in that area and probably nothing will drastically change anytime soon. instead there’s a new advance-r and dumb-er built-in system to generate sonoff debug logs that i desperately need them and it seemed to be a real problem for most of the people to provide them :frowning:

ps: next device integration is Sonoff B1 with full brightness/colour settings if anyone’s interested and willing to test

Hey, i have a quick question.
Been using the component for a while and its great, especially with the websocket version which works great with the interlocking feature of the 4ch, it’s wonderful.

My case in question:
I want to use a sonoff 4ch to control the irrigation system in a remote location.
I have checked that the timers still fire even if the sonoff is disconnected from the wifi/internet (at least the ones i set during the day, i am guessing that the daily repeating ones will still work in the case there’s no wifi- feedback welcome on this)
Although the tasmota fw does serve this purpose I feel safer using the default app and fw to set my irrigation timers.
What i would like to do is have a remote hassio instance collect weather data and then enable or disable the timers set on the sonoff by its app (assuming ofcourse, that there is a link established)

TLDR: I would like to be able to enable/disable timers set on the device by eWeLink. Is this possible (or would it ever be in the future)?

Thanks in advance and again, congrats :slight_smile:

Note: i was just going through your github readme looking this up and i saw the tip about having a second ewelink account and sharing the switches. That’s a life saver too, just did it :slight_smile: