In my previous post, I showed how any dumb device can be made smart by putting a relais in series to disconnect its power source. This time I do the same to my lamp!
First of all my ikea lamp on the ceiling is complete shit. You have to stand up, go to the light switch, and toggle it by hand just to turn on or off the light. Can’t do it from the bed, can’t do it with automation, this is unacceptable. Also since amazon started to give away free amazon dash buttons to automatically place orders just with a button press, the urge to turn on or off lights with it rises even more.
So the basic plan: Take a ESP8266, a relais and a power supply and shove them all into the ikea lamp housing:
The idea is that the power supply is always connected to AC 230V and the esp will disconnect the lamp to turn it off. Only then it can be turned on programatically. If you ever use the light switch to turn it off again, the esp goes out and there goes the smartness too.
In our living room, we had an unswitched phase and there we could do better, only run 5V through the light switch on the wall and evaluate its on/off state programatically and switch the relais accordingly. This is the nice side effect, the on is not always on the same side on the toggle switch, it depends if you have already “inverted” the state of the button or not over wifi.
If it works, it does not have to look to pretty, I call this art!
And now to the amazon dash buttons, they have to be setup using the mobile app (I think they are using the speaker of the phone and a microphone inside the amazon dash button to communicate the WiFi SSID and password).
Since I didn’t want the amazon dash buttons to contact amazon and order washing powder for me, I created a new firewall rule so they cannot reach the internet, the gateway will not forward any traffic for them.
That means when they are pressed, the boot up and connect to your WiFi, try to get a dynamic IP using DHCP, which is exactly what we will be using to detect button presses. A quick C++Qt application will listen for all DHCP requests on the network and issue a http request to the ESP in the lamp to toggle its state. With this we can finally toggle the lights with free amazon dash buttons!
They come in all sorts of brands:
Leave a Reply