We own a Better Homes & Gardens 61" Iron Cage Floor Lamp that we had on a smart plug relay. The issue was that it kept getting turned off at the switch on the lamp and that violated our our fundamental smart home rule!
So I decided to take a SONOFF Basic R2 and embed it into the base of the lamp to control the bulb.
In order to fix the local control issue I replaced the bulb socket assembly with two parts. The first was a pull chain switch similar to this one that I found at my local hardware store:
I just had to Dremel out the place the twist knob used to be to allow the switch to fit. I attached bell wire to the wires from it and snaked them down the center shaft of the switch to be attached to the SONOFF GPIO.
Then a new low profile socket for the bulb similar to this one also at the local hardware store:
I removed the mounting bracket from it and had to do a little light sanding on the bake-o-lite socket to get it to fit smoothly into the lamp.
Together they look like this in the lamp:
and all put together you cannot tell just looking at the top:
I then grounded one of the wires from the switch and hooked the other up to GPIO3 (the UART RX pin) that was on the header and easy to solder to. I felt that since the switch was already rated for 120VAC it was just fine to use an non-isolated GPIO for a user input, but be sure to evaluate this for your own application as with a low voltage switch this could be a shock hazard.
Then I just used the regular relay and power connectors on the SONOFF Basic R2 to connect to the wall power and bulb socket.
Finally I did a spectacularly messy application of hot melt glue to hold the thing into the base and prevent my kids from putting their fingers into it if the lamp flips over sometime, but this is under the base on the floor, so no one visiting the house ever sees it.
Here is my ESPhome code for it:
esphome:
name: couch_light
platform: ESP8266
board: esp8285
wifi:
ssid: !secret iot_wlan_ssid
password: !secret iot_wlan_pass
# Enable Home Assistant API
api:
password: !secret esphome_pass
ota:
password: !secret esphome_pass
# Enable logging
logger:
binary_sensor:
- platform: gpio
pin:
number: GPIO3
mode: INPUT_PULLUP
inverted: True
name: "Couch Toggle Switch"
filters:
- delayed_on_off: 100ms
on_state:
- switch.toggle: relay
switch:
- platform: gpio
name: "Couch Light"
pin: GPIO12
id: relay
status_led:
pin:
number: GPIO13
inverted: yes