This is the very first automation I did after setting up Home Assistant on a Raspberry Pi 4 earlier this year. I cannot even describe how happy I was when I finally managed to get it working, solving a problem we had ever since we bought this house years ago. Accomplishing something in a new field gives you that needed boost of confidence that helps you to go on, one step at a time.
The problem
Since the first renovation of the house our laundry room always had only a one way light switch to control lights. Fine you’d say. Problem is that the laundry has 2 doors: one opens to the dining room (where the light switch is), the other one opens to my home office (where there’s no light switch to control laundry lights when going through it).
Adding in wall wiring was never an option considering the hassle of having to free the room for that before drilling walls and producing a ton of dust: concrete walls here, no drywall. I also always procrastinate with adding external conduits (PVC ones) because of laziness plus a difficult route for the conduits from one door to the other (there’s a mezzanine in the middle, just to complicate things).
Then at night going from the dining room to the home office is easy, coming back not that much if lights got switched off at some point. And leaving the lights always on didn’t sound like the right solution…
The solution
Long story short the problem was solved with less than $20 of smart devices. In fact I had available the following devices that I got from AliExpress (you can find them on Amazon as well if you prefer, they will be a bit more expensive though):
a smart switch: Sonoff ZBMINI Extreme (no neutral required!)
a smart button: Aqara wireless mini switch
a smart motion sensor: Sonoff SNZB-03
Important to note that all these devices are connected to the Home Assistant instance using Zigbee protocol: this means they are locally connected and managed directly by the Raspberry Pi I have in my home rack without going through any external cloud service (security first!).
First of all, I connected the Sonoff ZBMINI Extreme smart switch replacing the physical switch: live wire into ZBMINI, live wire out to the lights. Then to preserve the user experience I wired the physical switch on S1-S2 contacts for the ZBMINI: this way nothing changes for the user switching on/off the lights from the dining room as the physical switch is still there and working as always. After discovering the device in Home Assistant it was already possible to switch on/off the lights from there without even touching the real switch! How amazing!
As a second step I started the Aqara wireless mini switch button (battery powered) so that Home Assistant could recognise it. This button has 3 functions: single press, double press, long press. Tested all three and double checked to see them in the logbook for the integration. Check. Eventually I stuck the button on to the frame of the home office door.
But pressing the button does nothing yet. What’s missing? Well, the button is just a button and does not know about the lights nor about the smart switch. I needed to put all the pieces together. Here comes the automation! In fact the button press needs to be used as a trigger in a new automation that as action will toggle the Sonoff smart switch previously wired. And BOOM! Lights go on and off just pressing the wireless button! Can you imagine how big my smile was at this point?
Okay but what about the motion sensor then? That is optional here but nice to have. And since I had one spare bought only for testing I decided to use it for something useful. Then I added another automation that is a bit more sophisticated: motion detected is the trigger but then a couple of conditions are checked before actually switching on the light as action. First condition is to check that the light is off, if not there’s nothing to do. Second condition is to check that we are in a moment after sunset and before sunrise (there is a “sun” api integration providing a lot of information day by day). Doing so when outside is dark already, anyone can go into the laundry and have light even if no switch was touched. And this is especially helpful for my kids as they always forget to switch on that light!
Just as my kids always forget to switch on the light when entering they also forget when leaving the laundry. For energy saving and being a bit more friendly to the planet I added a final automation. It is triggered after five minutes of lights on, checks if there’s no motion detected for one minute and eventually switches off the lights.
All in all it was a success: problem was solved, convenience was added, energy saving put in place. I love it!
Until next time!
Daniel
This is such a valuable article for someone trying to implement smart circuitry at home.