Automating a bedtime routine is harder than you might expect. You don’t want your smart home to shut down for the night when someone is still up, or you’re reading a book in bed. An NFC tag stuck under the nightstand was all it took to solve the problem.
Why bedtime is hard to automate
Being in bed doesn’t mean it’s time to shut everything down
Credit: Stock-Asso/Shutterstock.com
The problem with triggering a bedtime routine is that there’s no simple signal that will definitely show when it’s time to run the automation. For example, you could use a bed presence sensor to trigger the automation when both people are detected as being in bed, but if one person wants to stay up reading in bed, triggering the automation may turn out all the lights.
If you trigger the automation when a phone is connected to a charger after a set time, it will run when one person plugs their phone in, but the other person may still be up and won’t want to be plunged into darkness or have the TV turn off.
I wanted to find a method that would ensure that the bedtime routine would only run when both of us were in bed, and we’d both decided that we were ready to go to sleep. The simplest solution I could think of was to use NFC tags.
Dimensions (exterior)
4.41″L x 4.41″W x 1.26″H
Weight
12 Ounces
Home Assistant Green is a pre-built hub directly from the Home Assistant team. It’s a plug-and-play solution that comes with everything you need to set up Home Assistant in your home without needing to install the software yourself.
I put an NFC tag under each nightstand
Each person has their own tag to scan
Credit: Adam Davidson / How-To Geek
It’s often the case that when we go to bed, one of us will stay up reading or using our phone longer than the other person. Sometimes one of us will stay up a little later than the other to watch a show or do a bit of gaming.
The solution was to use two NFC tags and place one under each nightstand. That way, we could each scan our tag to indicate that we were ready to go to sleep. The bedtime routine would then only run once both tags had been scanned.
Scanning the tag only takes a second to do, and the phone vibrates when the tag has been scanned, so you don’t even need to check the phone to ensure that the tag has been scanned correctly. It’s a simple way to tell our smart home that each of us is ready to go to sleep. Setting up tags through the iOS Home Assistant app requires you to tap the notification when you scan them, so I created iOS shortcuts instead, which can fire Home Assistant actions.
When you scan an NFC tag in Home Assistant, it can pass on the ID of the device that scanned it, which is useful when different people are using the same tag. In this case, however, since we always sleep on the same sides of the bed, the device ID isn’t required. When the tag on my side of the bed is scanned, it’s always me who scans it, and the same for my wife.
Home Assistant waits until everyone is in bed
It can even handle things if one person is away
With the tags in place, I created a helper for each tag that turns on whenever the NFC tag is scanned. An automation turns both helpers off again at 5 AM each morning.
My bedtime routine is in the form of a script that does things such as turning off the bedroom lights, powering off devices such as the TV, ensuring that the smart lock is locked, and turning off any smart plugs that don’t need to be on overnight. I then created an automation that only runs once both helpers have been turned on and fires the bedtime script.
This worked perfectly when we were both at home; the bedtime routine would only fire once the second person had scanned their tag. The problem was that if one of us was away for the night, the other person would have to scan both tags to get the bedtime routine to fire.
I updated the conditions so that the automation runs when both tags have been scanned if both of us are detected as being at home, or when one tag is scanned if one of us is detected as being away from home.
One tap per person starts the bedtime routine
Everything gets shut down when we’re ready
Credit: Irine and Andrew/Shutterstock.com
Now that my NFC tags are in place and the automation is set up, running my bedtime routine is no longer a frustration. We both scan our tags when we’re ready to go to sleep, and neither of us ends up being plunged into darkness or having the TV turn off unexpectedly.
After a few nights of using it, I added a little more to the automation. When the first person scans the tag, the main bedroom light turns off, and the other person’s bedside lamp turns on or stays on at a fairly low level. This means that if one of us is reading and the other wants to go to sleep, the main light turns off and only the bedside lamp on the appropriate side stays on.
Once the second person scans the tag, their bedside lamp turns off, and the rest of the bedtime routine runs. It works really well, and scanning the tags is quick and painless.
Sometimes, simple solutions are the best
There are plenty of complex ways to determine when to run a bedtime routine, but scanning an NFC tag is simple and effective. What’s more, it’s incredibly cheap as NFC tags can cost just a few cents each.
