Sonoff /eWeLink component for original firmware

Hi everyone, first post here!

I’ve just found out by mistake this awesome Home Assistant framework and to my surprise I couldn’t find a component that would support Sonoff Basic switches (I don’t have others right now) out of the box.

If you have the time (or need) feel free to give it a try, most of the details are already laid out in the description:
https://github.com/peterbuga/HASS-sonoff-ewelink

Looking forward for some possible feedback.

Update
with awesome support from @forums2012 the list has been extended to support also Sonoff 4CH Pro (R2)
has been reported to work with WHDTS WiFi Momentary Inching Relay also (needs a custom HA button to simulate the momentary action … i think)

Another update
the list of devices keeps extending (thanks everyone for providing the information) and please be sure to check this list before submitting any questions and if it’s a new device to follow these new-device guidelines

List of major features

  • supports shared devices
  • most of switch devices are supported (if your device it’s not on the compatibility list give it a try, might actually work)
  • sensor entities are generated for devices that return values for power/current/voltage/temperature/humidity
48 Likes

That’s pretty interesting and could be useful but I still don’t like the idea of needing the cloud for them to work. Which is a big impetus for many (most?) coming to HA.

But thanks for sharing! I’m sure someone will get use out of it.

2 Likes

There are so many advantages with flashing custom firmware, such as Tasmota, and not using the Ewelink Cloud App and it is such an easy process for 90% of the Sonoff devices.

The main purpose of Home Assistant is to locally control as many items in your home as you possibly can, so you can secure your network as well as not rely on a cloud server and the internet. If Ewelink or your internet goes down, so do all your Sonoff switches.

Flash Tasmota to your Sonoff’s, and all of your automations will work as normal. It’s a no brainer.

3 Likes

I thought there was already an ewelink component. I recall one a while ago (but ignored it for the same reason as the others have said).

There is another third party one. I have mine flashed with Tasmota however it’s no different to me that Xiaomi WiFi plugs or Limitless LED lights or Yeelights… all need some ‘server’ somewhere to get up and running…

Im sure people will find this component interesting. Some people are terrified about flashing them.

Thanks for sharing, I have a Sonoff with original firmware and I was looking for something like that.
in these days I will try it .

Thanks

1 Like

Thanks everyone for the comments!

Let me start by saying that I’m 100% supporting the custom firmwares for Sonoff (or any kind of) devices. Just the idea of having an alternative to a device’s way of working and not just let it die by the will of the manufacturers.

I started this project to get familiar with HA framework internal stuff (what better why to learn it than having a problem ready to be fixed, right?) and if you wonder why I still have the original firmware is because my connected devices are lamps/speakers and is not the end of the world if they fail to start :sweat_smile:.
Also, I noticed first hand that even if the people are capable of doing a simple task as flashing a custom firmware they tend not to do it and it’s easier (maybe faster) just to insert 3+ lines in a config file like DavidFW1960 kindly mentioned above.

There are many many more official components in HA that use the same approach (again, as DavidFW1960 mentioned): query in a way or another the official endpoint and put the data/states in HA + send the action, this is from where I got my idea in the first place, so unless you buy a device and know exactly how it’s going to work you’re pretty much cloud dependent anyway.

I’m glad if this might end up helping anyone :relaxed:.

9 Likes

The ‘other’ one is half way between this and tasmota etc. It works without flashing but does away with the link to iTead’s servers and therefore means the app no longer works.

Everyone should now be satisfied with one of the three options.

Finally, an easy way to get started when you don’t want to mess around exposing HA to the internet and adding Google Assistant to HA in order to control Tasmota Sonoff devices.

Not really worried about the flashing, but more so of the need to expose to internet to get them working on Google Assistant.

Thanks for this.

1 Like

Also, I have Sonoff 4Ch pro and another 3 gang device on my ewelink account, will I still be able to use this component?
I hope it will not mess things up?
Thanks.

I see someone it’s willing to embrace my idea :+1:

Unfortunately I’m sorry to say that the listed devices are not supported/implemented right now, only the Sonoff Basic switch (that’s the only devices I have right now to test and probably the last too, I’m migrating to Shelly). The good part is that, by reading the code of ported project, I could (in theory at least, maybe with some help from you testing it a bit) add them quite easily.

If you are willing to help, I could write a small python debug script for you to provide back the json response/data of the ewelink app that will help me identify the devices and properly add them to HA.

In the current version of the code, the component might fail to add them or best case scenario you’ll see them listed in HA and definitely not be able to change their state.

4 Likes

For my personal needs this is perfect! :heart_eyes:

I have only sonoff basics, didn’t flash them just because I’m lazy and didn’t want to tinker with them. Also they are in the wall and didn’t want to dismantle a lot of things to reach them (and risk the wife’s anger…)

I created a serie of automations and input_booleans that replicated in Home Assistant the state of the sonoff, and I could even toggle them via home assistant.
The problem was I used ifttt in doing so and created an half-loop, it worked but was extremely faulty.

For me this project is just what I needed!
Great job! :+1:

I feel only that there is the need of something to prevent the ewe application to disconnect, even for a short amount of time, because actually you don’t even the chance to add new devices to the cloud.

1 Like

I already mentioned this possible next feature in the project’s description (it’s buried somewhere there in description :grin:). I’ll take this mention as a +1 for this and I’ll add it in a way or another in the near future.
Any ideas/inputs how this could be managed ? Calling an event to disable it for a defined period of time / implement a custom defined wait time between reconnects / a button on dashboard maybe ?

1 Like

Was contemplating about this myself.
Why not just create another account and share devices to that account and use that for the component here?

Would be more than happy to help!

However I am an absolute beginner, so don’t know how useful I can prove to be!

I will create tomorrow a debug of-some-sorts script and give more details about when it’s done. If you have a command line and you can run a basic python sonoff-debug.py <arguments> script then we’re good :wink:

1 Like

I updated the component, check out the new information in the repo!

TL;DR
scan_interval option to limit how fast the data is updated in HA
grace_period option to set a period of time that will stop sonoff refreshing inside HA to allow you to do various changes inside mobile app, this will kick in (more or less) the moment you login in the app.

2 Likes

You have got yourself a guinea-pig! :slight_smile:

Would be more than happy to help.

great addiction!

I think a service to stop indefinitely the updates (and another to restart them) would be usefull.

I have an hass.io installation, I can login in terminal, if I can help with the testing just ask.

Just try to install it & use it and let me know how it works :crossed_fingers: personally for me toggling the switch states work as fast as the mobile app itself, and i have everything installed (raspbian + virtual env) on a Rasp pi W :smile: