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

Tuya SDK for beginners: Intro to Tuya Cloud API

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

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 Zigbee Bridge – review

0
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!

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

Smart Home

We’ve seen this before: SwitchBot K10+ PRO

0
This is an odd one. Building on the success of SwitchBot K10+ they released SwitchBot K10+ PRO - but is the experience actually better?

Is this the smart panel we have waited for?

0
ITEAD has released a new smart panel: Sonoff NSPanel Pro 120 - have they learned the lesson from the terrible launch of the original Pro? Let's see what's new.

Aqara FP1E detects motionless humans

0
This isn't exactly a new device, it's an interaction of the original Aqara presence sensor. Aqara FP1E brings Matter, ZigBee and new triggers to your smart home

SwitchBot S10: cleaning re-imagined!

0
SwitchBot S10 promises unattended vacuuming and mopping so you can focus on things you love and care for. Does it deliver?

Sonoff for households and gardens

0
ITEAD released two ZigBee devices to manage water in your household and gardens. Now you can monitor the flow and dispense water with Sonoff SWV and prevent water damage using the Sonoff Water Leak sensor with a twist.