Home Home Automation Control Yeelight Smart Bulb with Amazon Dash buttons

Control Yeelight Smart Bulb with Amazon Dash buttons

Oh Yeelight - my favourite bulbs to work with

I’m often looking back at the previous projects thinking, what improvements I could make.  I actually have one article about controlling Yeelight Smart Bulb with Amazon Dash button, but it uses a Python script. Since the Amazon Dash button and NodeRED integration is possible, I thought I would rewrite it again, making it much more user-friendly! Oh, and if you are new to NodeRED – Check the Guide for Beginners!

Control Yeelight Smart Bulb with Amazon Dash buttons

First, a quick overview. If you did not use the Amazon Buttons for anything, please know you can intercept the button’s signal and use it for your own purposes. All this as long as you don’t mind about 6 sec delay and a10 sec overall cooldown. I found it to be acceptable as a light toggle. Suits best for a secondary light, like a lamp or similar.

Like previously, I will show you three different control variants. Before I jump to different scenarios let’s establish the lightbulb control in the NodeRED. To control the Yeelight Smart WiFi lights we will need a node:

npm install yeelight-compat-hue-state

Download it via terminal or palette manager. If you want to know more about how to install nodes – see part 2 of my NodeRED guide.

You will notice 2 new nodes. These will work with Philips Hue and Yeelight. Win, win! One node can be used to obtain the current status of the bulb, the other one is used to send the new values to the light bulb. As we are going to create the toggles, we will only focus on sending ON/OFF information.

Buy Yeelight RGB smart bulb

Buy it using these links to support NotEnoughTech.

To send the information to Yeelight lightbulb, you have to open the app and enable the LAN control. This way the lightbulb can receive the commands via the local network. While you at it, check the lightbulb IP address, as this information is needed to configure the Yeelight nodes.

The commands go to the port 55443 then use the IP of the bulb to point the commands to the right direction, add the name for each bulb and the config part is done. Remember, that you will have to do this for each bulb you have.

One Amazon Dash button, one Yeelight bulb

This is the most popular setup. A single Amazon Dash button controls one of the Yeelight bulbs.I’m going to start with obtaining the Yeelight Bulb state every 5 seconds. When the inject node triggers the Yeelight status node, the information about the current values will be updated and sent to the function node. In this example, I’m only interested in the status (on/off) of the lightbulb.

The function node will save the status as a global variable – and I will be able to always retrieve the current state of the bulb. This information will be used later to toggle the opposite state.

global.set("Yeelight", msg.payload.state.on);
return msg;
Amazon Dash toggle

When the button is pressed, I’m checking the current status of the light using the function node:

var x = global.get("Yeelight");
msg.yeelight = x;
return msg;

The value stored (true/false) can be used in combination with the switch node to send the payload with the opposite value. In the two templates nodes I’m sending the:

{"on":false} /*if true is received*/
{"on":true}  /*if false is received*/

This is the format that Yeelight node is expecting.

Multiple Amazon Dash buttons, one Yeelight bulb

If you want to have two toggles placed at the opposite ends of rooms this the way you want to hook up your Amazon Dash buttons with Yeelight Smart bulb. The situation is exactly the same as in the setup above, but this time I have 2 or more Amazon Dash buttons linked to the “Get Last Yeelight state” node. There is no need for other changes.

One Amazon Dash button, multiple Yeelight bulbs

If you have a group, or the room contains more than one Yeelight Bulb you can use the Amazon Dash to toggle more than one bulb at the same time.To complete this setup we have to add 2 more Yeelight nodes. One to read the status, one to control the second light bulb. There are no other changes in the code. The status of both bulbs is written to the global variable, so the Amazon Dash will toggle both lights based on the last performed action. If one of the bulbs has been turned off lately, the button will light both bulbs up.

Conclusion

As you can see, linking multiple buttons is super easy. You could also use the Amazon Dash button so preset specific colour, state and brightness if you prefer. Just change up the message submitted to the node.

Project Download

Download project files here. Bear in mind that Patreon supporters have early access to project files and videos.

PayPal

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

Patreon

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

image/svg+xml

Bitcoin (BTC)

Use this QR to keep me caffeinated in style with crypto-currency

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?

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

Best Automation Projects

ESP8266 WIFI lights under $5

0
Your Sonoff device can't do this!

Free wireless doorbell (Amazon Dash button hack)

0
The most terrifying situation I can imagine* is missing a parcel

New Amazon Dash Buttons

0
You can teach new buttons old tricks!

ESP8266 ceiling light – demo

0
Testing the ESP8266 as a WIFI light controller

Try Tasker and Raspberry Pi for your home automation needs!

0
Raspberry Pi can help you with your Tasker profiles

Smart Home

Awesome time with Wio Terminal

0
Wio Terminal from SeeedStudio is a great all-in-one development board that doesn't require soldering skills to get started with.

Flashing Tasmota on Sonoff ZigBee Bridge

0
How to flash Tasmota on Sonoff ZigBee Bridge to enable it for NodeRED and Home Assistant

Flashing Tasmota on Novostella smart bulb & floodlights

0
Flashing Tasmota on Tasmota on Novostella smart bulb & floodlights - it's quick simple and rewarding - here is how to use lights in NodeRED

Adding Sonoff sensors in Zigbee2MQTT and other systems

0
Can you use Sonoff sensors in Zigbee2MQTT and other ecosystems? Trying Tuya, Xiaomi, IKEA Tradfi and CC2531

Sonoff Zigbee sensors

0
I'm checking out Sonoff ZigBee sensors by ITEAD - what's the budget sensors like?