Sonoff /eWeLink component for original firmware

Tags: #<Tag:0x00007f20403210d8>


Great @peterbuga. They were in the states section. I works fine!!! Can I change the name of it for a friendly one in customize? Another question, I have a 2ch geekcreit device linked. It should work too?


Awesome, glad that it works ;)!

You can easily customize your entities either from built-in customize menu or from customize.yaml (which is pretty much the same thing).
Or, if by “customize”, you mean the name of the entity itself to be “” for example, I’m still debating for this case. It has come to my attention that the names that don’t contain valid ascii characters (ex: chinese characters) don’t play nice with entities and i have to default back to device id instead, leaving everything a small mess.

Keep an eye on the project (I don’t have an ETA yet) I’m re-writing the component to rely completely on the websocket for all the to&from updates, it’ll be much faster, probably less cpu intensive and the changes will reflect almost instantly in HA.


I’m unfamiliar with this device but if you can control it eWeLink app it should definitely work. If it’s not working please follow the guidelines for adding a new device mentioned in the 1st post.


Hyped for this. :slight_smile:
Working pretty amazing with what the websocket branch has so far.

Also I think your decision to stick with deviceid makes sense.
That way the automations and homekit integration is not affected.


It has two switches but I see only one switch in HA. I will connect it and check what happens
If you can integrate your project directly in home assistant core in future releases it would be great!


@peterbuga I have tried to use in a raspberry getting this message:
Traceback (most recent call last):
File “”, line 87, in
devices_json = get_devices()
File “”, line 69, in get_devices
headers.update({‘Authorization’ : 'Bearer ’ + user_details[‘at’]})
KeyError: ‘at’
Do you know what it means?


@jgyoldi most likely you provided wrong user and/or password :laughing: double check!
this is just a debug script, i didn’t spent too much time on it catching all the errors :confused:


@peterbuga Finally I got it working and I have a device.json file with the information of the following device:

It appears at HA with your project as one single switch but it doesn´t work. How can I send you the devices.json containing it?



You can post contents of the file here or on GitHub as an issue.
He made sure all sensitive data is already removed.
Still feel free to go through the contents once


@peterbuga you’re about to receive a pleasant surprise. :slight_smile:


Have been using the websocket branch with the changes in the pull request for about a day now.
Must I say it’s insanely fast!!
Like blows my mind every time it updates and changes state. :stuck_out_tongue:


Running Hassio,
Assuming I did this properly maybe?

local/custom_components/sonoff & .getmore files

and : local/custom_components/sonoff

the added to the main config.yaml

  username: !secret sonoff_username
  password: !secret sonoff_password
  scan_interval: 60 
  grace_period: 600 
  api_region: 'eu'

getting a error : Component not found: sonoff

I must be missing something, any suggestions anyody?


You would want to place the files in custom_components (already present within your /config folder, the folder that contains configuration.yaml) not local/custom_components

So your file structure should look like:


Edit: Oh I misread your question. The files don’t need another folder called sonoff. Just add directly to custom_components and create a folder called switch (and place the other from github here)


Yes that’s where I placed them, I was just showing the path I placed them in


On Hassio for other custom components I had to place them in that folder ( ie ; Alexa.nedia_player, google_calendar etc.)


Oh I misread your question. The files don’t need another folder called sonoff. Just add directly to custom_components and create a folder called switch (and place the other from github here)


ok, ty I’ll give it a try


@Corey_Maxim just as @forums2012 mentioned earlier you really do not need to create any folder called sonoff
if it makes things a bit clear, the only 2 files you need to have are like this:



ok, I was able to restart. do you know what might be causing this error?

Error during setup of component sonoff
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/”, line 145, in _async_setup_component
hass, processed_config)
File “/config/custom_components/”, line 52, in async_setup[DOMAIN] = Sonoff(config)
File “/config/custom_components/”, line 96, in init
File “/config/custom_components/”, line 162, in do_login
self._bearer_token = resp[‘at’]
KeyError: ‘at’


its hard to figure out the correct password on the app. I think maybe its that…