This is a contact sensor and people generally use
them in their smart homes to tell if doors and windows are open or closed.
In this video I’m going to show you how these contact sensors work,
which ones I use in my home, and finally some examples of automations that I have set up.
Contact sensors were traditionally used as part of home alarm systems and come with two parts.
There’s the reed switch part, which is essentially two pieces of metal that are held slightly apart
from each other, connected to a wire. Then the other part, which contains a magnet.
Once you put the two pieces side by side, the magnet pulls the two pieces of metal
together and they make contact - hence the name “Contact Sensor”. This completes the
circuit and the alarm system or smart home hub knows that the two pieces are together.
When you mount these on a door, one part goes on the door frame and the other on the door itself.
When the door is closed, the magnet pulls the metal pieces together to create contact.
This can then be used to trigger an armed alarm system, or any other smart home automation.
You can do the same thing for a window, or a drawer. You can use
them anywhere you want to detect if one thing is close to another thing!
In most home security systems, these contact sensors are hard-wired into the alarm system
which makes it difficult and expensive to fit them to all your doors and windows.
But these days you can buy battery-powered contact sensors that wirelessly connect
to many home automation platforms like Amazon’s, Apple Home Kit or Home Assistant.
They come in many different flavours and can be connected to your home automation system via Wifi,
Z-Wave or Zigbee - depending on which one you buy.
Like most sensors in my smart home, I use a combination of Aqara and Sonoff Zigbee
contact sensors. The Aqara is on the left, and the Sonoff is on the right.
I have paired these directly with Home Assistant
using a Zigbee dongle. If you’re not sure what that is or how it works,
check out my What is Zigbee video which I’ve linked in the description below.
Both these sensors work in the same way. You have the main piece here on the left,
and the magnet piece on the right. They can be mounted side by side like this or in several
other configurations as well. This is great because it allows you to place them on many
different surfaces and devices, such as my here on my washing machine and here on my skylight.
I’ll tell you why I have a contact sensor on
my washing machine door in a bit. But for now, back to the sensors.
The large side of both sensors can be opened up, allowing you to change the battery.
The Sonoff uses a CR2032 battery, which is what most small ZigBee sensors use,
whereas the Aqara uses a CR1632 battery.
This is annoying because I now need to keep different types of button batteries
spare for when these need replacing, but it does mean that the Aqara sensor is a
lot smaller in physical size - which is good for discretely mounting them around the house.
I have been using both these sensors for over 6 months and I’ve never needed
to change the battery. Both manufacturers claim that the battery lasts over a year,
but I’ve not yet been able to validate that. I also assume that battery life will depend
on how often the doors are opened or closed and the temperature of where the sensor is located.
Just like the other sensors I have reviewed on my channel,
the Aqara once again feels a lot more solid and well built when compared to the Sonoff. In fact,
when you shake the Sonoff, it rattles like a spray paint can - something the Aqara does not do.
To pair the Aqara with a hub you can press this button here on the bottom.
To pair the Sonoff you need to put a pin or Sim Pick into this little hole.
Both devices come with specially cut pieces of double sided tape so you can mount them
on your doors, windows or wherever else you want to detect something opening or closing.
When it comes to reliability they’re both as good as each other. I once had a problem with a couple
of the Sonoff sensors dropping off my Zigbee network, but that was after a power failure
and they are located quite far away from my Zigbee coordinator. I don’t think it was a problem with
the sensors themselves, I simply had to re-pair them and they’ve been working solidly ever since.
I pair my sensors with Home Assistant and they
both expose relatively similar pieces of information via their Entities.
You can see here on the left the Aqara sensor, and the Sonoff on the right.
Both will tell you if the door or window is open or closed, they will provide you with the battery
level and voltage, and the signal strength. The Aqara also seems to tell me the temperature of
where the device is mounted, but I’ve found this to be incredibly inaccurate and wouldn’t suggest
using the measurement. Get an Aqara temperature sensor if you want to measure temperature.
With these sensors in Home Assistant, I’m able to create a range of different
home automations which I’ll take you through briefly now.
If you want to recreate any of them in your smart home I’ve written a blog post
which shows each automation in more detail and that’s linked in the description below.
Some of my automations help me keep my house secure. For example, in the summertime I
usually open the doors and windows to get air flowing and to cool down the house. Clearly,
it’s not good for home security if we go out and leave some of these doors and windows open.
To prevent this I have an automation in Home Assistant that is triggered when all of the
residents leave the house and a condition checks to see if any of the doors or windows are in
an Open state. If it finds one that’s open it sends me a notification telling me which one.
A similar automation to this is triggered when I activate Night Mode. This is a boolean helper
in Home Assistant that I turn on when I’m heading to bed. This puts the house into a special state
which makes sure all the curtains and blinds are closed, sets specific lights to go on so I can
easily find my way to the bedroom and turns those lights off again after a certain time.
To turn on Night Mode I can either click this switch in Home Assistant,
turn it on automatically at a specific time or scan a NFC tag somewhere in my house.
When Night Mode is activated this similar automation is triggered,
telling me if I’ve left any doors or windows open and which one.
I have another automation that tells me if a door or window goes from closed to open whilst we’re
out. This tells me if someone has entered the house via a door or window when we’re away. Maybe
this is expected, because I’ve given a key to a guest or cleaner, but maybe someone has broken in?
It’s essentially the same as the automation I just showed you,
but with the trigger and conditions swapped around./
The trigger for this automation is any of the
doors or windows changing state from closed to open.
The condition instead checks to make sure that everyone is out of the house.
You don’t want to get a notification every time you open the door when you’re home.
So if everyone is out, the automation sends a notification telling us which door was opened.
We can then check the security cameras if we think that something suspicious is going on.
It would be surprising if a person could sneak up to my house and open the door or
window without me first being notified by one of my motion sensor automations.
These automations get triggered when one of my security cameras detects a person,
and sends me a notification with a snapshot of what the camera saw.
Whilst these notifications give me peace of mind a lot of the time,
it is really annoying to receive dozens of photos of my own face
when I’m walking in and out of my front door - unloading the car or something.
To prevent this I’ve added a condition to my camera notification automation
to only send these messages if the front door is closed. I generally don’t leave the front door
open unless I’m nearby, popping in and out, so I don’t need to be sent a picture every single time.
Now contact sensors don’t have to be all about security. You can also use
them to make things easier around the house. I have a small attic space in my house and
I can never seem to find the light switch for it - I used to stick my hand into the
dark crawl space and fumble around until I felt the switch, it was really annoying.
Now I use a contact sensor to automatically turn on these lights as soon as the door is opened
and turn the lights off again two minutes after the door is closed. I didn’t want them to turn
off immediately as I’m worried about crawling into the attic space and having the door blow
shut in the wind, plunging me into darkness along with all the spiders that live in there.
It may make more sense to turn the light off instantly when a door is
closed in other spaces though. For example, you could turn the light on when you open a
large pantry or closet door and have it turn off again when you close it.
You could even turn on a totally different light if a door is opened. If you have young children,
you may want to get notified if their bedroom door opens after a certain time in the evening.
Perhaps they had a bad dream, or need to go to the bathroom,
and you want to make sure you know about this so you can go help them.
In this case you could set some of the lights around the house to
flash red when a child's bedroom door is opened.
Here we have the automation that is triggered when the door is opened. A condition here
makes sure that this automation only runs at nighttime - you don’t want the house lights
flashing red randomly through the day as the door is opened and closed normally.
In the action of the automation, I first take a snapshot of what the lights are
currently set to using a dynamic scene. This will keep a record of whether or not
these lights were turned on or off, what colour, and brightness level they were
set at so that they go back to that same state once they are finished flashing.
I then set the Kitchen and TV lights to start flashing red.
The flash is an effect that can be triggered using my Hue LED Light strips.
The automation then waits sixteen seconds, which is how long these lights flash for.
The saved information from the dynamic scene is then reapplied to the lights
so they go back to the brightness, colour and level settings from before.
You can now go intercept your child in the hallway and make sure they’re doing
ok before they make it out to the living room and demand to stay up late watching TV with you.
If you want more information about using scenes like this in Home Assistant then
check out the Scenes video that I’ve linked in the description below.
You can use this same concept in different ways as well. Instead of putting the contact
sensor on a child’s bedroom door, you could put it on a garage door or mailbox flap
and set some lights to a specific colour letting you know that the
garage door is open or that you may have mail in the letterbox.
If you’ve been watching my channel for a while now
you may have seen a previous video I did about making my dumb appliances smart.
In that video, I explained how I often forget to empty the washing machine
and how I used smart switches to send me a message to my phone when it is completed.
I had hoped that this would remind me to empty it and stop my clothes from
smelling like a wet dog because I left them bunched up in the machine for hours on end.
The problem was that these notifications would generally come to my phone whilst I
was busy upstairs and I’d dismiss the message and forget about it.
I needed a way to be reminded to empty the washing machine when I was near it.
My washing machine is under the stairs next to the kitchen, and on those stairs I have a
motion activated LED light strip. I came up with a solution to change these lights to green, rather
than their normal warm white when the washing machine was done. This way I would visually see
that the washing machine needed attention when I walked up the stairs next to the machine.
The only problem was figuring out how to tell the lights to go back to their normal colour
once the machine had been emptied - and that is where a contact sensor came in handy.
In my previous video, which is linked in the description below,
I create an automation that uses an input_select helper in Home
Assistant to keep track of what the washing machine is currently doing.
I’ve now updated my automation so that it switches
the Washing Machine state from Running to Unemptied when the cycle finishes.
If the stair lights get turned on by the motion sensor automation,
the action now checks the washing machine state. If the state is “Unemptied”,
it will turn the stairwell lights on to green. If it’s anything other than Unemptied,
it will turn the lights on to their normal warm white colour.
I then stuck a contact sensor to the door of the washing machine and created a new automation that
is triggered when it’s opened. The condition then checks to see if the current state is Unemptied,
and if it is, the automation will assume that I’ve opened the washing machine door to empty it.
This will then set the Washing Machine state to Off and notify us that it’s been emptied.
This has actually made a big difference and we now consistently remember to hang the clothes
as soon as we walk by the machine. These types of reminders, which remind you to do
something when you’re actually near the place that you need to do it,
are far more effective than a generic message or push notification,
My final contact sensor automation uses a very different style of contact sensor.
This is an Aqara water leak sensor, and it is designed to be placed anywhere you might
be worried about flooding - such as near a boiler, some plumbing or a dishwasher.
The reason I call it a contact sensor is because it detects water using these two
metal probes on the bottom of the sensor. When water passes across these two screws
it completes the circuit, or makes contact, telling you that water is present.
You can use this to trigger an automation to notify you
of a water leak, the same way as we did with the door sensors earlier.
I have built this water leak contact sensor into this 3D printed contraption
and wired it up to a rain detection pad. When a drop of water lands on this pad,
it creates a contact between the two plates and I use this to infer if it is raining or not.
This triggers an automation to send me a notification to tell me that it is raining.
I also have a contact sensor on the skylight in my bedroom
and the rain detected automation checks if the skylight is open.
If it is it lets me know so I can go and close it before my bedroom carpet gets soaked.
If you’d like to know more about my rain sensor and how I use it to
also prevent the watering system from turning on when it has been raining
please let me know in the comments and I’ll consider creating a video entirely about this.
As I mentioned earlier, I’ve written a blog post which goes through all these
automations in more detail in case you want to recreate them in your smart home.
You can find a link to it in the description below.
I regularly release videos like this about home automations and smart home ideas.
Here is a video I made about Smart TV Automations,
and here is another one about my favourite smart lighting automations.
If you found this video useful please click the thumbs up button to let me know.
Why not also click the subscribe button so you can see when I release new home automation videos
and then together, we can make your home smarter.