Last updated on August 5th, 2020 at 09:13 am

Hey, I recently face the following problem: I wanted to share a smart Sonoff switch with my family using the native eWeLink app. At the same time I wanted to Integrate this smart switch with my local Home Assistant and Node Red installations. eWeLink + Home Assistant + Node-RED – I managed to find a solution and now I have the best from both worlds – Cloud and Local Sonoff at the same time. In this video post I want to show you how you can also do it step-by-step.

eWeLink + Home Assistant + Node-RED Other Possible solutions?

Initially I thought that I will just flash the Sonoff switch with Tasmota – 

or if you prefer to read

and then aI will setup a VPN client for everyone that I want to have access to my switch. While this approach will definitely do the job it’s seem that it will be too complicated. Setting a VPN on different devices – ones with iOS others with Android on top with different OS versions can be a real pain.

Then I immediately remember about ZeroTier for the VPN part –

the full article can be found here

But even with ZeroTier, explaining to a non tech person what is VPN, then how to connect to it, then what to open and at the end how to turn on and off the switch is not an easy task. So I abandoned this idea for now and I start searching for other solution – eventually I found it. 

eWeLink + Home Assistant + Node-RED Prerequisites:

  • A Sonoff Device with the free eWeLink app installed and eWeLink account 
  • A Smashed Subscribe button
  • Working Home Assistant or Node Red or better both 


Actually the solutions are two: 

  • For Home Assistant is called – HASS-sonoff-ewelink –
    • Create the following structure inside your Home Assistant configuration folder (the sonoff folder you can get from the GitHub repo above)
     └── sonoff
  • Add the following lines to your configuration.yaml file:
   username: [email or phone number]
   password: [password]
   scan_interval: 60 (optional, lower values than 60 won't work!)
   grace_period: 600 (optional)
   api_region: 'eu' (optional)
   entity_prefix: True (optional)
   debug: False (optional) 

$ npm install node-red-contrib-ewelink

  • From Node-RED

Go to Menu → Manager palette → Install and search for node-red-contrib-ewelink and click install.

After that you could watch the video above and you can use the test flow that I created, but don’t forget to add your credentials and device ID:

[{"id":"6fa808c4.c0bbf8","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"749668f3.7fdf9","type":"ewelink-devices","z":"6fa808c4.c0bbf8","name":"eWeLink","auth":"","x":280,"y":160,"wires":[["18933913.b11b97"]]},{"id":"18933913.b11b97","type":"debug","z":"6fa808c4.c0bbf8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":570,"y":180,"wires":[]},{"id":"63db88fb.e0769","type":"inject","z":"6fa808c4.c0bbf8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":100,"y":160,"wires":[["749668f3.7fdf9"]]},{"id":"d1ff556.50679a8","type":"ewelink-power-state-write","z":"6fa808c4.c0bbf8","name":"Living room","deviceId":"10002c6c42","channel":1,"auth":"","x":330,"y":280,"wires":[["e223595d.83955"]]},{"id":"544407bf.d9f05","type":"inject","z":"6fa808c4.c0bbf8","name":"","topic":"","payload":"toggle","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":280,"wires":[["d1ff556.50679a8"]]},{"id":"e223595d.83955","type":"debug","z":"6fa808c4.c0bbf8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":550,"y":280,"wires":[]},{"id":"28cccac9.3a78a6","type":"ewelink-temperature-humidity","z":"6fa808c4.c0bbf8","name":"Living Room ","deviceId":"10002c6c42","auth":"","x":310,"y":380,"wires":[["b2343b36.ca1c28"]]},{"id":"b2343b36.ca1c28","type":"debug","z":"6fa808c4.c0bbf8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":510,"y":380,"wires":[]},{"id":"e27c8e6e.3d06c","type":"inject","z":"6fa808c4.c0bbf8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":380,"wires":[["28cccac9.3a78a6"]]},{"id":"a7e87ba4.9aa2a","type":"ewelink-event-listener","z":"6fa808c4.c0bbf8","name":"Living room Listener","deviceId":"10002c6c42","auth":"","x":370,"y":480,"wires":[["aa3fdbb4.943ae8"]]},{"id":"aa3fdbb4.943ae8","type":"debug","z":"6fa808c4.c0bbf8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":570,"y":500,"wires":[]},{"id":"a1b90720.db6668","type":"ewelink-power-state-read","z":"6fa808c4.c0bbf8","name":"LR","deviceId":"10002c6c42","channel":1,"auth":"","x":310,"y":80,"wires":[["d506bcf9.a6b9f"]]},{"id":"d506bcf9.a6b9f","type":"switch","z":"6fa808c4.c0bbf8","name":"IF ","property":"payload.state","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":480,"y":80,"wires":[["98098daf.e0f6e8"],["36d17efa.722c92"]]},{"id":"98098daf.e0f6e8","type":"debug","z":"6fa808c4.c0bbf8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":630,"y":40,"wires":[]},{"id":"36d17efa.722c92","type":"debug","z":"6fa808c4.c0bbf8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":630,"y":120,"wires":[]},{"id":"4af4862b.3cafd","type":"inject","z":"6fa808c4.c0bbf8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":80,"wires":[["a1b90720.db6668"]]}]


What smart home topic do you want me to cover next in my videos – let me know your answers in the comment section below. 

Support my channel

Any sort of engagement on this channel does really help out a lot with the YouTube algorithm, so make sure you hit the subscribe, Like and Bell buttons If you enjoy this video.

Enter your questions in the comments section below, if you have an Idea for my next video – please share it there as well – all of this will help me a lot. Also feel free to add me on Twitter, by searching for KPeyanski. I post there pretty much daily. 

I really hope that you find this information useful and you now have working Sonoff device with eWeLink, Home Assistant and Node Red simultaneously.

Thank you for watching, stay safe and see you next time.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.