I’ve got an antique lamp that needs a new switch knob, but then scope-creep happened and now I want to “smartify” it. I started off thinking that, since it has a metal body, I’d install a capacitive touch switch, but now it’s escalated to wanting to put an ESP8266 or ESP32 in it to handle the capacitive sensing, Home Assistant connectivity/control, and maybe even switching to some kind of low-voltage RGBW LED instead of a 120VAC Edison-base bulb (especially since I suspect I’d need some kind of antenna sticking out the top, since the metal lamp body would presumably otherwise block the ESP32’s signal).
The lamp, BTW:
(Apparently it’s a Genie lamp by Laurel Lamp Company, in case anybody cares. Also, the lamp shown is the same model, but it’s not my picture.)
I’m aware that the “easy” way would probably be to just screw a smart light bulb into the socket and wiring I already have, but (a) I’m picky about both avoiding “clouds” and using FOSS firmware, and I don’t feel like sorting through the junk on Amazon to figure out which ones can be flashed with ESPHome, and more practically (b) that wouldn’t let me turn it on and off just by touching the lamp body, which is what sent me down this rabbit-hole in the first place.
Anyway, I know this sort of thing can be done, but I’m not completely sure how. I know I could figure it out myself eventually, but I figured it couldn’t hurt to ask for advice in case somebody happens to be able to rattle off part numbers for the whole BOM off the top of their head, or knows exactly the right ESPHome howto to point me towards, or something like that. Any advice is welcome!
(In case it’s relevant: my level of experience is that I programmed an Arduino to run neopixels (WS2812 RGB addressable LEDs) once, I’ve flashed ESPHome on some Sonoff S31 smart switches, and I’m a software engineer by trade but have never worked on anything IoT related professionally.)
Is there a reason you wouldn’t want to just get a zigbee/zwave/wifi smart outlet switch?
That’s what I’m doing now (with one of my Sonoff S31s flashed with ESPHome), since I can’t use the mechanical switch. It’s not ideal because I would like to be able to turn the lamp on and off at the lamp (but in a “smart” way rather than mechanical) and the smart outlet switch is down behind a dresser where I can’t easily reach it.
The only real way I’ve found of doing stuff like this is another smart button or switch nearby. I use my buttons for whole groups of lights and toggles based on current state and whether you short/long/double click the button.
A single ESP32 dev board and a 120VAC-> 5V power supply module should be all the hardware necessary to read a touch sensor, talk to Home Assistant, and control RGBW LEDs. I figured the tricky bits would be (a) the software to get the three different functions to all run at the same time (I’m hoping that ESPHome might reduce that to a “configuration” problem instead of a “programming” one), and (b) finding a nice, bright, RGBW LED in a suitable form factor (one that isn’t a smart light bulb, but instead replaces the lamp socket itself).
I’m not really interested in solutions that require multiple microcontrollers or that aren’t actually better than using a smart switch or smart bulb.
Well yeah. I guess if you want to DIY a solution there’s a lot more you can do. My issue is building a polished finished product rather than exposed wires and a switch, since I have the wife approval factor to consider now. So it’s easiest for me to buy a smart outlet and a button or switch vs wiring up my own solution and trying to 3d print a case these days.
The idea is that, with the exception of the LED assembly and antenna, it’d all fit inside the hollow lamp body. There’s plenty of space: I could even fit a Raspberry Pi Zero (or maybe even Model A) in there if I wanted.
You could even just take the switch apart and rewire it to an IO pin, and then actually control the bulb socket with a relay. In that case you could have it truly integrated and nobody would notice a difference.
That would work if I wanted to settle for just on/off control of the light bulb and give up on the idea of controlling the hue and color temperature of an RGBW LED.
Basically the issue I’m running into is this:
- on/off control of the lamp with HA by itself – easy (it just requires a smart outlet, which is what I’m already doing)
- hue and color temp control of the light by itself – easy (I could just buy a smart bulb to do it)
- capacitive on/off control of the lamp by itself – easy (I could just buy a capacitive switch for <$10)
- capacitive control of the lamp and control with HA – moderate (all I need is an ESP32, but I might have trouble with the lamp body blocking the wi-fi signal unless I figure out a way to add an external antenna)
- capacitive control of the lamp and control with HA and hue and color temp control of the light – hard (it’s a full-blown engineering project involving creating a custom LED housing to replace the lamp’s Edison socket, or at least modifying a smart bulb to add a capacitive touch input attached through the bottom of the socket to the lamp body somehow)
Yeah, I do something similar to Andrew; bought a few IKEA tradfri buttons and remotes, and set them up to toggle lights or media in various rooms.
Do you care about dimming or running an extra cord into the lamp? Someone has done something similar here with just an esp32 and smart switch. If you want just a single cord, you’ll need esp32, AC to DC 5v board, and some dry contact ac relay module. The code would be similar but the esp32 would directly control the relay instead of using a switch.
Edit: thinking about it more, you may also just be able to use a shelly 1 relay flashed with esphome has gpio pins and can run off ac power but it uses an esp8266 so not sure how that would work with capacitive touch.
Do you care about dimming or running an extra cord into the lamp?
I’d prefer to run only 120VAC into the lamp, and yes, I’d like dimming (and ideally, control over the white color temperature and the RGB hue too, while I’m at it).
Edit: thinking about it more, you may also just be able to use a shelly 1 relay flashed with esphome has gpio pins and can run off ac power but it uses an esp8266 so not sure how that would work with capacitive touch.
See, that’s the kind of brainstorming I’m looking for!
It’s hard to tell if it would work because the Shelly website/documentation makes no mention of capacitive touch support, but looking at these pinouts…
…if the numbering scheme is the same then it looks like the switch input is GPIO4, which is also TOUCH0?
That said, the other problem (if I understand correctly) with the Shelly 1 Relay is that if you supply it with 120VAC then the switched output is also 120VAC? If I wanted finer control over the RGBW LED for hue control and dimming, I’d want several low-voltage outputs instead of one 120VAC one, right?
I missed the part about switching to RGB LED, but I’m not sure if any products are bright enough to be useful. You are right that if you powered the Shelly with ac, it outputs ac, which goes against your Edison bulb replacement idea. If you can find something that runs on 12v (like a light strip), that case no relay would be needed. You could replace the AC cord with a 12v DC adapter to power the lights and use a cheap 5-30v to 5v buck converter to power the esp32.
I’m not sure if any products are bright enough to be useful.
I mean, the components they put inside smart bulbs have to come from somewhere, right? As far as the LED part goes, I think I’m probably looking for the kinds of things sold by industrial suppliers, not a consumer product.
Or maybe I should be thinking in terms of taking apart a smart bulb and soldering on extra GPIO…?
I would caution going too far down the custom rabbit hole for something like a light bulb, just because you will eventually have to replace it. At that point I would look at a zigbee/zwave lightbulb with a esp32 in the base powered by a AC to DC converter to control the bulb. You would need a stick to control it but the trade off is a much easier replacement later on.
That is a good point. If I did do something custom, I should probably budget to build some spares. Settling for a smart bulb running ESPHome (and giving up on the touch activation) is also looking better and better.
I’ve used anthom presence detector and it worked well. They sell an esphome bulb. You can always mess around with an esphome using a dupont wire with some copper tape to connect it to the base to trigger the light just through Home Assistant. That way you can decide if you want to open it and integrate it later.
For future reference I recommend the brand “athom” for smart light bulbs, they come flashed with tasmota, wled or esphome and you can also flash whatever you want on them
Try a Lutron Caseta dimmer with a Pico remote. They work together as-is without a gateway, and the Gateway Pro will join it to something like Home Assistant in the future. Or you can simply use the Caseta app.
Isn’t Lutron Casita about as far from a non-proprietary, FOSS system as I could get? I’m trying to minimize vendor lock-in here, not maximize it.
It’s more or less a consumer version of their RA2 system, which is its own protocol. The gateway interacts with the whole system using commands issued over telnet though, so you actually have a command line for operating and configuring it. It integrates with a bunch of closed systems, and it integrates right into Home Assistant with a first-party HA integration.
It’s not like you can inspect the source code for their firmware push up pull requests on GitHub, so I’m this aspect, yes, it is proprietary. However, with tools like Home Assistant, which is something you probably should be using, this becomes much less of a concern, in my opinion. It’s robust, high-quality, and is commonplace, so you can get bits and pieces at Home Depot.
If you’re interested in something that will work with mesh networks and you aren’t interested in running software like Home Assistant, you should look for Z-Wave or Zigbee hardware. Read reviews though; I’ve had a lot of mixed experiences with hardware, even from “trusted” vendors.
Is the base hollow? If yes, you can put a ZigBee module
Yes, the base is hollow.
Is there a reason I should use Zigbee instead of wifi? I don’t currently have a Zigbee Coordinator and it isn’t immediately apparent that there are any Arduino-type microcontroller boards that come with it built in (as opposed to needing a daughter board), so it seems like it’d be more trouble and expense.
One of the bigger reasons is ZigBee is capable of mesh network forming, which is useful if you want more devices to be smart. It’s also low power. And the devices are in their private network isolated from the internet, which is also a desirable quality. In summary, ZigBee is built for smart devices, whereas wifi not so much.
But:
-
It plugs in to the wall anyway (it has to, to power the light).
-
I don’t have any immediate plans to get anything that wouldn’t be like that (I hate the idea of relying on batteries).
-
I already have wifi, but not zigbee.
-
I trust devices flashed with third-party firmware not to be calling out to the Internet nefariously (and also know how to subnet & firewall them off).
I started off WiFi and ended up on zigbee for the most part. The major downside of wifi is how many devices are cloud/proprietary but it sounds like you’re using esphome so that’s not an issue. I definitely like my zigbee devices as they also tend to be slightly cheaper, but starting with WiFi is an easy progression definitely.
Getting a USB zigbee device is about all you need to get up and running and adding to your mesh, which I definitely recommend eventually.
Yes, for one device, I’d do wifi too. ZigBee does add complexity, but it also adds many possibilities. Esphome is a good solution, I use it also. In fact it seemlessly integrates with HA, so it doesn’t matter
-
Many reason to prefer ZigBee, can handle more devices than WiFi, better security as it is separated from WiFi devices, mesh system, response quicker than WiFi, low energy, built for smart home (unlike wifi), and a few other reasons I don’t have in mind at the moment.
I think the easiest way is using zwave plug + zwave button to control it. If you have zigbee hub then you can use zigbee light bulb + zigbee button for greater control of the light. Quick search on Amazon doesn’t show any zwave light bulb tho