Creating an ESP Button/Switch Device for WiFi Lightbulbs with ESPNow

Hello Everyone!

This is my first post here. It is my first week exploring Home Assistant (HA) after a couple of years using HomeBridge (HB). I want to create an ESP button/switch device to turn on and off my WiFi lightbulbs using ESPNow.

Currently, I have conventional switches (not smart) and smart lightbulbs. The lightbulbs are connected and controlled by HA.

When someone switches off the light using the conventional switch, the lightbulb is disconnected from the electricity, making it impossible to control via HA. Unfortunately, I cannot modify the existing switches.

My Idea:
I want to build a “fake switch” using an ESP board, a switch/button, and a battery. I discovered that ESPNow is energy-efficient, and I aim to keep the ESP device in a low-power state to preserve battery life. The process should work as shown in the attached diagram:

  1. Wake up the slave device when the button/switch is pressed.
  2. Send data to the master device and then put the slave device back to sleep.
  3. The master device receives the data and converts it into an action to control the light using HA.

I am just a hobbyist, so I’m not sure if this is the best way to solve this issue. Is there a repository or resource where I can start looking for guidance? Any advice or suggestions for completing this project would be greatly appreciated!

Thanks in advance,

Some discussion reg. ESP-Now: ESP-NOW with ESP-HOME - #14 by skotl

I thought of using bthome by afarago for this, but i ended up using tasmesh with tasmota

I configured the wall switch as broker and the wifi lights as nodes. On the switch i added rules to toggle the light with single button press and other custom actions.

Thank you for your replies. I’ve been reading more about this, and just as a personal challenge, I’d like to continue exploring this architecture.

From the other posts, it seems that there are difficulties in connecting the ESP-Master to the router to establish communication with HA (see the yellow link in my figure).

I’m not an expert, but I was wondering if this “yellow connection” (between the master and HA) could be made using a serial port via USB.

In this case, if someone presses the button on the slave, the data is sent to the master using ESPNow. Then, the master writes the data to the serial port, and HA interprets that as an instruction.

Would this approach work? Has anyone tried something similar?

Thanks again for your help!

Isn’t it easier to just add ZigBee to HA and buy a ZigBee remote?
Cost will probably be slightly more expensive since you need the ZigBee radio, but if you need more than one of these remotes then I believe it will be cheaper with ZigBee.

You mean using that remote to trigger the actions? because my bulbs are not zigBee.
Sounds a handy solution for me. Thanks!

I have WiFi bulbs controlled by ZigBee remotes.
Works fine.

1 Like