Easy 3+ way light control

Our stairway has a light and naturally you’d want a switch at the top of the stairs and at the bottom. This was easy with dumb switches. Google 3 way wiring and it will return different ways to do it.

But of course, I want automation. The recessed LED light is dimmable so I ended up buying a GE zwave smart dimmer and installed it at the top of the stairway.

For the bottom of the stairs, the only option available from GE is to buy an add-on switch then run a traveler from the add-on to the zwave at the top. I didn’t like this because it means I have to run more Romex.

Inspired by one SuperhouseTV episode, I decided to make my own wifi enabled addon switch. Less than an hour later, I have 3 way switching and possibly more if I want to. The beauty of this design is I can repurpose my custom switch to toggle anything inside the house. All I would need to do is remap in Home Assistant.

For my switch, what I used was a nodemcu v2, a 10k resistor to pull up D7, and some wires to connect it to a dumb switch at the bottom of the stairs. The nodemcu will send an mqtt message to toggle then an HA automation script will invoke light.toggle. And that’s it!

Btw, the dumb switch is only used to toggle the light on or off. I haven’t found a rocker momentary switch that I can use to detect long or short presses. I could use this to send requests to change the brightness.

I’m using Xiaomi gatewate (zigbee) combined with smart bulbs to achieve the same.
The xiaomi has some super cheap (£5) switches that can trigger 3 events (click, double click and long click).
E.g. can set click as toggle a stairs light, double click to turn on all lights on ground floor for night time emergency, long click to turn off all lights (or similar).

This xiaomi kit is amazing value.

I also use the amazon dash buttons (wifi) and dasher calling HA API, but these are no way as responsive.

I’m not quite as homebrew hardware oriented as you - definitely interested, most probably capable, but sadly time limited

You can also do this with Hue and their dimmer switches.

Nice. Good to know. In my case, my light switches are wall mounted and are plain switches from the local hardware store. But I might get some of these Xiaomi switches for other purposes since it’s cheap.

Thanks. That’s the switch design I’m looking for or something similar. Definitely easier to go with Hue lights + dimmer switches. I just checked Amazon and it’s $35.00 for a kit.

You do need the gateway as well as the switches… but thats cheap too (£25)
There are considerations - need to import from china (gearbest etc), chinese plug on the gateway, beta support

But its super cheap and (for me) works great!

Yeah, Hue is awesome but I wouldn’t call it cheap.

For those interested, I’m using the following:

  1. light switch from Lowes ($16.10 for 10 pcs)
  2. nodemcu (~$7.99 ea on Amazon. Definitely cheaper if you are willing to wait for shipping).
  3. 10k Resistors ($4.19 for 100pcs on Amazon). Don’t even need that many :slight_smile:
  4. Some wires

A nodemcu can potentially control 9 switches (D0 - D8). I wrote a simple sketch that polls when each pin is pulled low then it sends out an MQTT message.

Was replying to @benaranguren regarding Xiaomi.
But I agree w you re hue. Good. Not cheap.

1 Like

wow, very nice, can u share with us all your code and stuff, if possible with some photos? i am very interested.

Certainly. I’ll be making some more this weekend. I’ll snap some photos and upload the code somewhere in github.

2 Likes

Sounds great, I’d love to see how you have this set up!

Can you please explain the wiring setup and code for nodemcu

Finally got around to push my code to github.

I just finished refactoring the code and I haven’t gotten the chance to validate it. But the meat of the code is there :slight_smile:

I’ll continue updating the documentation now that the code is in github.

I’m sure you might have questions since the code and wiring is not very clear but just let me know and I’ll try to respond as soon as I can.

Certainly, the code for nodemcu periodically pollls pins D6 and D7.

I was going to use 2 pins to make certain that the switch is in either state: ON/OFF or D6 is HIGH/D7 is HIGH. I need to verify this drawing as I don’t have the circuit in front of me, but it looks right :slight_smile:

Also, the code right now is only reacting to changes on one pin.

It there another wire+resistor to power the NodeMCU?
Otherwise, doesn’t it shut down when the switch is in “inbetween” mode?

What the latency from the moment you switch the button till the light actually switches?

Yes, NodeMCU is powered by USB. I also updated the drawing to reflect that. The switching latency is very small and it should just be what the polling interval is.

At the moment, I ignore D7 so it’s either D6 is HIGH or LOW and every time it transitions, a toggle command is sent to my zwave controller.