So this was something I’d been looking at doing for a long time. A while back I bought a load of NFC tags on Amazon for use in some projects around the house. Up until now, I’d struggled to see the use case for many of them as quite frankly, we’ve been putting voice assistants to good use. The fact that I’ve been able to create custom entities and flows with Google and Alexa has allowed me to literally set up whatever I wanted. However, I was keen to give these a try.
I’ve recently purchased a variety of Reolink Cameras to trial and play with. You can read more on that here. I have used the wireless camera to provide monitoring for an old diesel boiler that we’ve been using. We are currently living on a mountain where there is no gas, so diesel it is unfortunately. Recently, one of the pumps got blocked and we suffered a fuel leak. I have put the wireless Reolink into action monitoring the situation from a far. At night though, we need to use the IR lights to be able to see anything. Note, I’m using this to monitor, not from a security perspective. Thus I don’t leave the IR lights on all the time. The main reason, is because it attracts spiders, and unfortunately, spiders are my kryptonite! I can’t stand the little buggers. So I came up with this solution.
I’ve integrated the Reolink cameras into Home-Assistant using a custom add-on you can find here. It works perfectly, and exposes the various attributes of the camera directly into lovelace.
Tags in Home-Assistant
I set about creating a simple automation to turn the IR lights on for 1 minute when the NFC tag is scanned, and then off again, so as not to give the spiders any excuse to create their love nest in our boiler room. In order to start this, I opened the Home-Assistant app on my phone, and went to App Configuration -> NFC
Click on “write tag” and then hover over the tag you want to use. It will come up with some JSON once it’s read it. You can put the phone down now and go over to your desktop/laptop and access your Home-Assistant interface. Go to Configuration -> Tags and there you should see an entry for the tag you just scanned.
Click on the little robot head on the right which will take you to the automations screen. Here I’ll just show you what I have filled in, rather than try and talk you through each step.
In a nutshell, scan the tag, the IR lights come on, then after 1 minute the lights go off. This will only work between sunset and sunrise, i.e. when it’s dark.
One thing you need to be aware (Thanks to Pete Guy for his help on this!). When trying to add the time (sun) conditions, you need to add two separate entries. I originally just had after sunset and before sunrise on the same condition and it refused to work. You need to edit some yaml here unfortunately.
We need to combine the conditions using OR.
Once complete, save the automation and scan the tag (as long as it’s dark). Job done.
So keep this in mind when looking at doing your automations in Home-Assistant. Thankfully, there’s more than one way to skin a cat! Let’s take a look at Node-red.
Tags in Node-Red
Ok, so it’s still in beta but it’s working perfectly well. In Node-red as long as you have the Home-Assistant palette, which I’m assuming you all do, you can drag out the Tag node and take care of the automations from there.
One thing to keep in mind. Make sure you add a name to the tag in Home-Assistant. Initially I couldn’t see the tag in Node-red, no matter how many times I updated the tag list or restarted the server etc. When you bring the tag into Home-Assistant initially it has that long identifier. I thought that was enough, but for the Node-red flow to work, I needed to add a name to it. Once done, i updated the tag list and it popped in immediately.
Just for checking, i attached it to a service call node and am using it to toggle a sonoff basic on and off. Everytime I tap the NFC tag with my phone, the light toggles on and off. (I showed the full flow for completeness). If you’re not up to speed with Node-red and want to get started I have a 3 part tutorial which might help. If you’ve not even got it set up yet, well I have you covered too. See below for the links:
- The Beginner’s Guide to Node-red with Home-Assistant (Part 1: MQTT)
- The Beginner’s Guide to Node-red with Home-Assistant (Part 2: Switch Node)
- The Beginner’s Guide to Node-red with Home-Assistant (Part 3: Timers)
- Basics: Connecting Home-Assistant to Node-red
If I was going to replicate the Home-Assistant automation in Node-red, this is what I would be going for:
Going forwards, I would probably use Node-red for the automation side of things but I wanted to try it both ways. I can add the time condition (i.e. when dark) in the same way I did here with my nightlight.
Now I’m trying to think what else I can use these for. I thought maybe to put one in the car. Thinking that as we pull up to the drive, we can tap the phone on the dashboard to turn some lights on etc according to the time of the day. Now that I’ve set up tailscale, I have permanent access to my Home-Assistant installation where ever I am, so there’s no stopping me!
If anyone else has got any other ideas where these would be better than a simple voice command, pop them in the comments, or in our facebook group.
If you’re considering a renovation and looking at the structured wiring side of things, or maybe you just want to support the blog, have a look below at my smarthome book, it’s available in all the usual places (including paperback)!