Just a quick post today about how I replaced our doorbell with a custom Zigbee button and Home Assistant, running on an old Raspberry Pi 2 I had sitting in a drawer, which pings our phones when someone presses the button, instead of ringing a regular chime. If this interests you, read on!
Our cat Harry, who we adopted from the shelter a couple of years ago, is terrified of all humans except us. We don’t know why, he was 10 when we got him, and over the last 2 years we’ve tried to acclimatise him to visitors, but he’s absolutely not having it. He’s super friendly once you’re on “the list”, but getting on “the list” means being one of the people that feeds him for a month or so. Realistically, no-one but us is ever making the list.
He knows that the doorbell often means visitors, so when it goes off, he freaks out and runs to one of his hiding spots, such as under the bed, and won’t leave until he’s sure everyone else has gone. The problem is people ringing the bell for anything else, such as deliveries, set him off as well. Those are more common than actual visitors, so he’s freaking himself out unnecessarily most of the time.
So I wanted to try replacing the doorbell with notifications that pinged us on our phones, rather than a (necessarily) loud house-wide bell. Obviously you can buy products that do this, but pretty much all of them are linked to a door camera and an online service, and I want neither of those things. I just want a button that pings a notification to our phones locally when we’re home, the end.
I don’t really “do” smart home stuff. I don’t want my home to be dependent on the cloud for essential things. I don’t want to bug my own home with microphones. I don’t want to contribute to the 24/7 surveillance society if I don’t have to. But, I’m starting to make exceptions for things that are non-critical, still physical, don’t invade people’s privacy and are entirely functional within my own network.
Enter Home Assistant
Home Assistant is a locally-hosted smart home solution that lets you do an enormous amount of home automation stuff. I only needed the ability to ping a couple of phones in response to a button event; it’s overkill but seems to be the easiest option.
It also runs on extremely modest hardware - I installed it on a Raspberry Pi 2B which I already had sitting around. Their install documentation says to use a Pi 3 or 4, but for my usage the 2B was totally fine - you just have to look at the complete release list and look for the “rpi2” image - they’re still producing them for the latest releases (v9 at time of writing, and v10 beta has rpi2 images too).
You can follow the Home Assistant install exactly as the docs say (barring downloading the right image). All I would advise is that after starting it up, leave it a good 30 minutes at least, connected to the Internet. It seems that HA downloads additional data on first startup and the system won’t be available for a while; initially it’ll just respond to pings and nothing else, and then later you’ll get a “please wait” screen. Just give it a while.
Optionally, after install you might want to reserve an IP address for the Home Assistant device. It responds on homeassistant.local, but it’s nice to know the IP won’t move about at all, IMO.
Zigbee is great little network protocol that’s local and low power, relaying mesh-network style via other devices if needed to achieve the range. For a button that’s going to be idle most of the time, it’s perfect - a full WiFi connection would both increase the cost of the device, and its power draw, wheras Zigbee buttons are cheap and last for ages on a coin battery.
Zigbee is probably going to be replaced by Matter eventually, but it works right and is well understood so it’s the way I went.
Adding Zigbee to Home Assistant
In order to use zigbee devices, we need a coordinator, or hub. Home Assistant can do this, but we need a Zigbee interface - based on what I read online, I went for the Sonoff Zigbee 3.0 USB Dongle Plus.
I plugged this into one of the Raspberry Pi USB sockets and Home Assistant picked it up immediately. Nice!
Adding a button
Apparently IKEA do good cheap Zigbee buttons, but I don’t have easy access to one of those so I bought another button I’d seen recommended: the Aqara Mini Switch.
Those buttons tell you that you need to buy an Aqara Hub, but we’re using our own hub so it’s fine. We just need to pair the button. Unfortunately, this can be a little error-prone as a process.
- In Home Assistant, go to Settings > Devices
- On the Sonoff device, click “Configure”, then “Add Device”
- Hold down the pairing button on the Aqara button for a few seconds until the blue light starts flashing, then release it
- Every 2-3 seconds, briefly press the pairing button again
- Hopefully you’ll get a “Device Found”, “Starting Interview” box coming up
- Keep short-pressing the pairing button every 2-3 seconds
- Eventually a green successful pairing box should come up, and you can name the button
It took me several attempts to get this to work. It seems like the Aqara switch doesn’t stay “awake” long enough after the initial connection to be properly “interviewed” unless you keep short-pressing the pairing button every few seconds. Failing to do this can result in the button being paired but not triggering events, or getting stuck in the “Starting Interview” state forever.
If it doesn’t work, just keep trying. If you get into the state I did when it was paired, but events weren’t being triggered, it seemed to help to remove the device, remove the battery from the button for a while, then repeat the repairing.
Once it’s paired it seems fine (so far). To see it, go to Settings, Devices, and in the “Sonoff” badge area, click the “2 devices” link (or more if you have more buttons).
The battery status may say “Unknown” for quite a while, just give it an hour or two.
If you click on the button device, you can get more info about it, and also on the right hand side you can see when it was last pressed. Press it now to test that it’s working!
These buttons are technically not waterproof, and listed “for indoor use”, but people have reported them to be fine as doorbell buttons so long as they’re in a sheltered spot, such as in a porch. I figure they’re cheap enough that it’s fine to take the risk.
The Phone App
We’ll need something on our phones to receive the notifications, so now we download the Home Assistant app. You need to create user accounts for every user, and get everyone to set it up at least once. It should find the Home Assistant instance on the network automatically.
Personally I opted out of health and location data collection during this setup because health is just weird, and home assistant isn’t visible outside my network anyway so location is pointless. But you will want to allow Critical Notifications. We’ll use those to make sure the doorbell goes even when the phone is on silent (you may prefer not to allow this).
Configuring the automation
Next we want to create an automation connecting the button to sending phone notifications. In Home Assistant we go to Settings > Automation, and create a new one.
Triggers are things that start the automated process, so in this case we want the button press. However, this button can send several events depending on whether it’s a short/long press, or double-click. I just made them all trigger the same thing, but if you wanted you could let select friends know to double-press or long-press the button to give the “secret signal” 😅
You can add conditions to the button press, but I didn’t do that. I imagine some people might want to add quiet times or other constraints.
Finally, you need one or more actions, which in my case is sending a phone notification. To do this we
- Click Add Action
- Pick “Call Service”
- As the service, search for “mobile_app” and pick the phone you want to ping
- In “Message”, set “Doorbell” or similar
This will raise a default notification on the phone in question (you can add one per phone, or start getting more clever with groups and other things). However, if your phone has its volume turned down, or you have lots of other notification, you might not notice it. So let’s fix that.
Critical Notifications, Volume, Sounds
When setting up the phone apps, we allowed Critical Notifications for a reason. These notifications are always on top, and you can override the phone volume settings to make sure the sound is heard. We probably also want to use a non-default sound to differentiate the doorbell from other notifications.
In the action settings, we can add extra data to do this. At the bottom of the action settings, check the “Data” box and enter something like:
push: sound: name: News_Flash.caf critical: 1 volume: 0.9
It looks like this:
name: field refers in this case to an iOS system sound, which needs to
be imported in the Home Assistant phone app, see the
section of the docs.
critical: 1 makes this a critical notification, which pushes it on top of
everything else on your phone.
volume: 0.9 sets the volume of this notification to 90% regardless of the phone
settings. I do this in case our phone volumes are low and you otherwise might not
hear the doorbell sound.
Apart from a bit of hassle with pairing the Aqara button, the whole process was not too bad! I imagined when I envisaged this project that I’d need to get a soldering iron out and do something much more drastic, but this whole thing only cost me just over £30 (plus the Raspberry Pi I already had) and a few hours on a Sunday afternoon.
Fingers crossed it keeps working, and that Harry doesn’t begin to think that the phone notifications are something to trigger his anxiety 😿. At least it’s much more localised so he’s less likely to hear it.