Sonoff /eWeLink component for original firmware

@quarx I haven’t really tested it that systematically but FWIW the Sonoffs (web controlled) are just as quick to respond as the Ikea Tradfri lights (locally controlled via the Tradfri hub).

I only use the Xiaomi kit for sensors (motion, doors, temperature, light level, vibration) so I can’t comment on working with the Yeelights.

I have found the Xiaomi stuff pretty robust but it has dropped out once or twice in the last few months. I am using the China server because AFAIK you have to for the gateway and sensors.

I actually also have the Roborock 2 vacuum but that is on a EU server on a different account. I have my tablet logged into the EU account and my phone logged into the China account. Not ideal but no practical bother.

I just found this: https://bitekmindenhol.blog.hu/2018/08/31/sonoff_lan_uzemmod

Based on Google Translator it looks like in the LAN mode there is a UDP handshake and from there on all communication is based on the same protocol as when the app talks with the Ewelink server.

There is already a lan mode component for sonoff, its on the forum sonewhere.

For original firmware?

Yes, original f/ware.

1 Like
1 Like

Thanks, it’s a nice proof-of-concept!

Hi,
I have some trouble trying to install the component. This is the error I get:

Blockquote
INFO:homeassistant.util.package:Attempting install of colorlog==4.0.2
Testing configuration at /config
ERROR:homeassistant.scripts.check_config:BURB
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/scripts/check_config.py”, line 207, in check
res[‘components’] = check_ha_config_file(hass)
File “/usr/local/lib/python3.6/site-packages/homeassistant/scripts/check_config.py”, line 335, in check_ha_config_file
component = loader.get_component(hass, domain)
File “/usr/local/lib/python3.6/site-packages/homeassistant/loader.py”, line 92, in get_component
module = importlib.import_module(path)
File “/usr/local/lib/python3.6/importlib/init.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 994, in _gcd_import
File “”, line 971, in _find_and_load
File “”, line 955, in _find_and_load_unlocked
File “”, line 665, in _load_unlocked
File “”, line 674, in exec_module
File “”, line 781, in get_code
File “”, line 741, in source_to_code
File “”, line 219, in _call_with_frames_removed
File “/config/custom_components/sonoff.py”, line 7

^
SyntaxError: invalid syntax
Fatal error while loading config: invalid syntax (sonoff.py, line 7)
Failed config
General Errors:
- invalid syntax (sonoff.py, line 7)
Successful config (partial)
< Blockquote

What am I doing wrong?

Yes proof of concept, but couldn’t get it to work with my 2 channel device.

first of all you have pending install packages from adding/enabling other components as stated here
INFO:homeassistant.util.package:Attempting install of colorlog==4.0.2

moving forward there’s a slight possibility that you didn’t copy-paste properly the sonoff files (might be the reason you get the synstax error problem), remove everything related to sonoff component and start from scratch, watch closely the install instructions!

WOW! just wow! this is another cool idea.

Unfortunately seems like everyone ignores the elephantS in the room regarding this implementation: i might be wrong but the devices might first need properly to connect to internet before dropping into LAN Mode and the fact the list of supported devices (better said only 1-switch devices) are supported :frowning: this is a real let down from ewelink coders :-1:

I’m definitely keeping an eye on this project and maybe i’ll add an offline fallback but as mentioned above creates an overall confusion of what/how the devices will work with this component.

Thank you for your reply. I noticed the error about colorlog, but I thought it was not an error and it had finally managed to install. I am not very familiar with hassio on the Raspberry PI and I don’t quite know how to install colorlog. I tried to look it up but I couldn’t find anything clear. I am still learning, sorry.
As for the sonoff.py files, what I did was download each file (respecting the folder order) and then upload them to my HA installation in the configuration folder. I will try the copy and paste option. Thanks!

Yes! It works! The problem seems to be the way I was installing the sonoff.py files. I assumed I could download each PY file to my computer and upload it to the HA server, but it doesn’t work like this!
So, I’ve got one Sonoff S20, a Sonoff basic and a wifi socket from Coolkit which also works through the ewelink server. Everything working right now!

Guys, i have two questions on the Sonoff basic and Sonoff Bridge

  1. I keep noticing that my eWelink keeps logging out and have to log back into the eWelink app ? What do I need to do to solve this ?

  2. Is there a solution to Sonoff bridge in Home Assistant ? Is there anyway to get it integrated.

Thanks for all your time and help

@Vaughanza

  1. take 2minutes and carefully read the project’s README (aka the main page)
  2. it’s a pending issue work-in-progress. i’m quite confident that i might be able to integrate it buuut there’s always the possibility that might not work as intended
1 Like

Seems like great progress has been made! Kudos to our amazing man @peterbuga

I haven’t updated my files since before holidays (Dec 2018). Added Sonoff POW R2 to my collection.

Planning to upgrade files, will be using Websockets branch, as it works insanely fast!

Currently my devices are named switch.deviceid_outlet (have entity_name: False in my config), I would prefer to keep it this way. Do the new files change this? What should I do to get this working?

Thanks a lot for the amazing work!

Love the component.

1 Like

Thanks you!!
It works well on my sonoff basic

The current websocket branch works with this naming model (but it has been reported to be broken … oops) all others have the legacy switch.sonoff_deviceid_outlet even so, i think a quick global find and replace could bring everything in place.

i’ve been a bit busy lately so the updates are showing up a bit slower (not to mention that my SD card that was holding the HA installation decided to bravely give up and kinda killed my mood to push new stuff for now :frowning: )

So that means new files have the switch.deviceid_outlet naming model right?
You’re not using the switch.devicename or something in the latest version right?

Thanks.

Hi, I’m having problem with HASSIO running on docker Raspberry Pi.

I got this error:
2019-01-22 13:58:15 WARNING (MainThread) [homeassistant.loader] You are using a custom component for sonoff which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2019-01-22 13:59:18 ERROR (SyncWorker_3) [homeassistant.util.package] Unable to install package uuid: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘NewConnectionError(’<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x75a3fe50>: Failed to establish a new connection: [Errno -3] Try again’,)’: /packages/ce/63/f42f5aa951ebf2c8dac81f77a8edcc1c218640a2a35a03b9ff2d4aa64c3d/uuid-1.30.tar.gz
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘NewConnectionError(’<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x75a0f550>: Failed to establish a new connection: [Errno -3] Try again’,)’: /packages/ce/63/f42f5aa951ebf2c8dac81f77a8edcc1c218640a2a35a03b9ff2d4aa64c3d/uuid-1.30.tar.gz
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘NewConnectionError(’<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x75a0f730>: Failed to establish a new connection: [Errno -3] Try again’,)’: /packages/ce/63/f42f5aa951ebf2c8dac81f77a8edcc1c218640a2a35a03b9ff2d4aa64c3d/uuid-1.30.tar.gz
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘NewConnectionError(’<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x75a0fe10>: Failed to establish a new connection: [Errno -3] Try again’,)’: /packages/ce/63/f42f5aa951ebf2c8dac81f77a8edcc1c218640a2a35a03b9ff2d4aa64c3d/uuid-1.30.tar.gz
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘NewConnectionError(’<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x75a0ff90>: Failed to establish a new connection: [Errno -3] Try again’,)’: /packages/ce/63/f42f5aa951ebf2c8dac81f77a8edcc1c218640a2a35a03b9ff2d4aa64c3d/uuid-1.30.tar.gz
Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host=‘files.pythonhosted.org’, port=443): Max retries exceeded with url: /packages/ce/63/f42f5aa951ebf2c8dac81f77a8edcc1c218640a2a35a03b9ff2d4aa64c3d/uuid-1.30.tar.gz (Caused by NewConnectionError(’<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x75a0f750>: Failed to establish a new connection: [Errno -3] Try again’,))
2019-01-22 13:59:18 ERROR (MainThread) [homeassistant.requirements] Not initializing sonoff because could not install requirement uuid
2019-01-22 13:59:18 ERROR (MainThread) [homeassistant.setup] Setup failed for sonoff: Could not install all requirements.

Can anyone help?