HomeHome AutomationControl 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 with BTC: 1FwFqqh71mUTENcRe9q4s9AWFgoc8BA9ZU

Smart Ideas with

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

client-image
client-image
client-image
client-image
client-image
client-image
client-image
client-image
client-image

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

NEST your old thermostat under $5

0
Nest-ing up your older thermostat under $5

Nora – Google Assistant in NodeRED

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

Sonoff R3 DIY mode & why it sucks

0
Long awaited Sonoff R3 DIY mode is even worse than I expected.

IKEA TRADFRI Wireless dimmer in NodeRED

0
Thanks to NodeRED you can use IKEA TRADFRI Wireless Dimmer to interact with everything

Things they don’t tell you about IKEA Trådfri

0
There are things you should know about IKEA Tradfri before you make your purchase

Smart Home

Electrolama in my network – flashing CC2652R

0
Flashing CC2652R Zigbee Coordinator to enable ZigBee2MQTT for your home automation

How to wake on LAN computers and put it to sleep with Power Menu, Alexa and Google Assistant

0
How to Wake on LAN properly via Android, Alexa, Google Assistant and Web

Power Menu – All sensors

0
Taking all the sensor data and adding it to a single Power Menu tile!

Smarting up Comfee Miniplus Dishwasher

0
Can a vibration sensor turn Comfee TD305-W dishwasher into a smart appliance? Let's see

M5Stack UnitV2 – Edge computing and vision projects with a mini dev board

0
M5Stack UnitV2 is upon us - everything you should know about the latest dev board for Edge computing and vision projects.