HomeHome AutomationeWeLink API in NodeRED- why are you silent about your API?

eWeLink API in NodeRED- why are you silent about your API?

We have more options to connect eWeLink devices now!

If it wasn’t for this inexpensive and extremely frustrating to pair unbranded eWeLink 2-way switch, I would never find the API for eWeLink! It takes a pinch of anger, a spoon of frustration and lucky timing, to enter the keywords in Google that will lead you to the revelation you have been looking for for ages.

eWeLink API – kind of…

I will be frank, there is work to be done, but eWeLink has published something that resembles a development guide. It’s a great news for anyone who would like to use eWeLink devices with NodeRED or Home Assistant without flashing the firmware.

Obviously Tasmota is still a very much desired firmware for sonoff devices, but as my journey with this eWeLink unbranded switch shows – this is not always possible.


I don’t have a clue how long this API was available, but the node I’m bout to present is only a couple of months old and works pretty well. While the API aims at developers of other apps, the resources allow to connect to eWeLink account, get information about your linked devices and to take over the control of it.

What’s the benefit of using API over flashing it with Tasmota? You will retain the eWeLink app function, the smart speakers integrations and you will be able to control all eWelink devices from NodeRED and Home Assistant at the same time. Something that was possible before with Shelly devices (Shelly vs Sonoff).

At the moment there is a profound lack of details about how things work, but with a little searching here and there, I was able to figure out controls and set up.

NodeRED and eWeLink API

The best node to use right now is node-red-contrib-ewelink. If you want to give it a go – install this from palette manager. Before we start, there is a small catch – you will be logged out from your eWeLink app – at the moment the interactions are login based, but I hope that eWeLink will switch to token-based authentication. (UPDATE 11/04/2020: new eWeLink app introduces “deauthorise device” option – which could indicate support for multiple sessions)

The workaround would be to share all devices with another account to use the app and NodeRED at the same time. If you log back in to eWeLink, you will have to re-authenticate the NodeRED config.


This node has it all. I was able to find my RF433 remote linked to the Sonoff RF Bridge (review) as well as the Sonoff Zigbee Bridge (review) and the child device Sonoff Basic R3 Zigbee (review). Whatever you have linked to your eWeLink account will be controllable.

Node instructions are very bare. The configuration will ask you for your eWeLink credentials and region. I’m in the UK and my region is eu, if you are in the USA – your region can be empty – or use us.

Controls could use some polish as well. There is a separate node to receive status from the eWeLink device and another one to change that status (why not to merge it into input-output node? But everything works.

LAN mode?

I know what’s the next question is going to be – does it work with LAN mode? Not for now. I know it could be a deal-breaker for some, but given time things mat change. From my perspective, a couple of months ago we were not able to control the eWeLink devices outside of the app at all – so this is a step in the right direction. I hope this is not the last step.

In action

To control a eWeLink device you need to get the msg.payload[0].deviceid taken from the eWeLink devices node. This ID is used to define each device in other nodes. The device node contains every piece of information you would need about your devices including child devices for Bridges.

There are separate nodes to handle temperature and humidity, power usage and a listener node to monitor changes to individual eWeLink devices. A perfect tool if you want to update the state of the Sonoff.

There is a small delay in execution (less than a second) which isn’t terrible. Let me show you how easy it is to control that unbranded eWeLink 2-way switch I reviewed recently. In any other circumstances, I would not be able to control it from NodeRED

First I need to get the device ID. I know the location is msg.payload[0].deviceid but I need to know which device is it. If you look up the msg.payload[0].name it will give you the name of the device.

To control the state (on|off) you will need a state node. Fill the node with ID. You will also need the Channel – which I believe is the relay number. For most devices this will be 1 unless you are trying to use something like Sonoff Dual R2.

The state node in this instance takes on|off|toggle values – sadly no support for true|false or 1|0. and once injected – you will receive the confirmation that looks like:


To receive updates from the eWeLink device (as this switch can change the state via wall switch) I need to hook up an event listener node. It’s smart to add the deviceID to limit the responses to a specific device and add a further filter to decrease the number of payloads. The same info is available from the control node as well – so it’s your choice

The state update is saved in msg.payload.params.switch and you can update your variables with on|off.


Looks like we are one step closer to have a very good solution to take the advantage of eWeLink functions and smart speaker integration and link the devices to our NodeRED server. I know a lot of you want to have LAN mode available, but if you already have eWeLink devices that you can’t flash with Tasmota (hello Tasmotizer) then this is probably the next best thing to play with. Let me know what do you think in this Reddit thread.


Nothing says "Thank you" better than keeping my coffee jar topped up!


Support me on Patreon and get an early access to tutorial files and videos.


Bitcoin (BTC)

Use this QR to keep me caffeinated with BTC: 1FwFqqh71mUTENcRe9q4s9AWFgoc8BA9ZU

Smart Ideas with

Automate your space in with these ecosystems and integrate it with other automation services


Learn NodeRED

NodeRED for beginners: 1. Why do you need a NodeRED server?

To server or not to server? That's a very silly question!

Best Automation Projects

Tuya SDK for beginners: Intro to Tuya Cloud API

Working with Tuya Cloud API. A guide to Cloud automation for beginners, get started with REST!

NEST your old thermostat under $5

Nest-ing up your older thermostat under $5

Nora – Google Assistant in NodeRED

Integrate Google Assistant with NodeRED thanks to Nora - NodeRED home automation

Sonoff Zigbee Bridge – review

Sonoff line up will soon include Sonoff Zigbee Bridge and more Zigbee sensors - here is the first look

DIY Smart Washing Machine – for about 15 bucks!

Learn how to add washing machine notifications to your Google Home on the cheap

Smart Home

I wish I had known about the SMLIGHT ZigBee/Thread Coordinators sooner!

SMLIGHT coordinators are the perfect choice for anyone just diving into ZigBee. SLZB-06 series is easy to use and comes with future-proofing Thread support.

Sonoff ZigBee Bridge U isn’t what you think!

I expected Sonoff ZB Bridge U to be a next gen ZigBee bridge with Matter support. Turns out, there is much more to talk about!

Aqara “Everything” M3 Hub

When I started my home automation adventure, the current problem was the number of ecosystems needed to outfit your smart home. Aqara M3 Hub has a long list of protocols to match that!

Sonoff ZB Micro did it! (and bonus ZigBee device)

A long time ago, I took an angle grinder to the humble Sonoff Micro, will I do this again? Meet Sonoff ZB Micro and Sonoff ZB Contact (SNZB-04P) - the latest devices from the ZigBee ecosystem.

This keyless entry is PRO: SwitchBot Lock Pro

SwitchBot Lock Pro offers comprehensive upgrades over the original, combining enhanced design, stronger performance, and a faster mechanism for keyless entry