“Those who can make you believe absurdities, can make you commit atrocities.”
“Those who can make you believe absurdities, can make you commit atrocities.”
Now that I have a shiny new iPhone, I’ve realised that I can finally start playing with NFC tags, and, in particular, they can do interesting things around the house by making them trigger actions in my Home Assistant system.
I do alread have various Zigbee buttons around the house, and in general these are more convenient, since you can just press them without needing a phone in your hand! There are a couple in the sitting room, for example, which toggle our ‘movie mode’. When movie mode is switched on, the lights in the hall, kitchen and sitting room dim to a low warm glow, any lights that reflect in the TV screen turn off completely, the temperature in the room is raised by a degree or two, and the TV & DVD player switch on. When movie mode is switched off, everything reverts to its previous state. I don’t want to have to pull out a phone to do this; it’s much easier to turn it on and off with a button, or to use voice. “Alexa, it’s movie time!”
A Xiaomi Zigbee button on the left; one of my NFC tags on the right. The NFC tag is an inch in diameter.
But if you don’t mind pulling out your phone, NFC tags have some key advantages: they’re small, weatherproof, require no battery and can do more things. You can also arrange that they do different things depending on who’s scanning them, so, for example, you could stick one beside your garage door; when you scan it, it unlocks your car, when your spouse scans it, it unlocks theirs, and when anyone else scans it, it does nothing (or perhaps causes your security camera to take a photo of them!)
NFC tags each have a fixed unique ID, and for simple interactions you can just arrange that your phone does something when a particular ID is scanned.
But they can also be programmed with custom data using a protocol/format known as NDEF. There are standard ways of storing URLs, phone numbers, etc, much as you would with a QR code. So if you want a tag to take you to a web page, for example, without your phone needing to know anything about the tag in advance, this is a good way to do it.
If you want to experiment with this, then the Simply NFC app is a good place to start. Another good and completely free one is NFC TagWriter by NXP, but for the particular issue of reading things with an iPhone, I had more luck with Simply NFC. And a key thing to know if you’re using small tags is that the NFC reader is at the top of the back of your phone near the camera, and this needs to be within about a centimetre of the tag.
Recent iPhones will read a subset of these tag types in the background (i.e. without you having to run an app). As an example, I’ve just programmed a tag here with my email address (a mailto: link), and if I scan it, a notification pops up offering to take me to the mail app to send a message. I can do this with my iPhone at the home screen, or even the lock screen. More complex email variants, though, (for example, including an email subject line), don’t seem to work without running a special app.
Recent versions of the Home Assistant app know how to program NFC tags, and scan them, and associate them with Home Assistant actions. This is very cool, and gives you lots of information about who’s doing the scanning, etc.
But it has a problem on iOS: Apple doesn’t let an NFC tag perform an action on your phone without your confirmation. So instead of just pulling out your phone and tapping it on the tag, you also need to look for the resulting notification and confirm that you want the action to take place, which spoils the magic a bit. This isn’t an issue, I gather, on Android, but Apple are more cautious about doing things behind your back, especially, I guess, since an NFC tag could be hidden and yet still accidentally scannable.
However, there is one way to allow tags to perform actions on an iPhone without requiring your confirmation each time.
If you create an ‘automation’ on your iPhone using the Shortcuts app (not to be confused with a Home Assistant automation), you can choose to trigger this with an NFC tag.
You don’t need to program the tag: this just uses its ID, I think.
Now, an iPhone automation can do all sorts of things, including requesting a URL. And Home Assistant allows you to create webhooks which can trigger Home Assistant automations in response to a URL being requested.
You can find information on how to create a Home Assistant webhook online, depending on whether you create your automations through the GUI or using YAML. Here’s my simple example called study_toggle
, which toggles both ceiling lights in my study:
- alias: Toggle study lights
trigger:
- platform: webhook
webhook_id: study_toggle
action:
- service: homeassistant.toggle
entity_id: light.q_study_back
- service: homeassistant.toggle
entity_id: light.q_study_front
I can cause this automation to be run using the URL `/api/webhook/study_toggle’ on my Home Assistant server.
NOTE: It’s important to remember that webhooks don’t require authentication, so if your server is at all accessible to the outside world you should make sure you use more obscure URLs! Please don’t have one called http://homeassistant.me.org/api/webhook/open_garage
!
OK, back to the iPhone. Now, your phone will need to make an HTTP POST request to that URL, but fortunately, this is easy to do. When adding an action to your automation, go into the ‘Web’ section and use ‘Get contents of URL’:
Then you can put in the URL and expand the ‘Show more’ section, which will let you change the HTTP method from GET to POST.
There’s no need to send any data in the request body, but you can add some JSON if you wish to make use of it in Home Assistant.
And that’s basically it! Make sure you turn off the ‘Ask Before Running’ option on the automation.
Now, the first time you scan the tag, it will still ask you for confirmation, but it’ll also give you the option not to be asked in future, at which point you can just tap the tag to run the action. Your phone does need to be unlocked.
If you use Nabu Casa’s Home Assistant Cloud, they make it easy to get a long obscure URL which will link to your webhook and which will be accessible from anywhere. (If you set this up on your Mac, you’ll really want your ‘Universal Clipboard‘ enabled so you can copy on the Mac and paste on the phone!)
This is handy if you might want to put the tag somewhere away from your home, e.g. if it’s the last thing you scan before you leave the office to notify your spouse that you’re on the way. I’ve also heard of people sticking tags to their car dashboard which will open or close the garage door.
But if you’re only using the tag to control things when you’re actually at home, you’ll make it a lot more snappy if you keep everything on your local network, don’t go via lots of proxies, and you could even use an IP address to avoid a DNS lookup. So my actual tag to toggle my study lights calls a URL which is something like:
http://192.168.0.30:8123/api/webhook/study_toggle_x65fedwibble
and it’s pretty much instantaneous.
This is the best cartoon I’ve seen over the last few days.
It was one of those shared-on-WhatsApp things, so I’m afraid I don’t know whom to credit.
Christmas breakfast on the edge of the Cairngorms, 2019
Hello Everybody, and Happy New Year! I’ve been doing something very foolish in 2020, and now I’ve stopped.
Let me explain…
This time last year, over the Christmas and New Year period, Rose was visiting her family in the States, so after dropping her at Heathrow, I turned our little campervan around, and headed north, accompanied by my cocker spaniel. The only thing I knew at the time was that we were spending the first night in the Lakes, and that we were probably heading for Scotland. The rest would be decided en route, mostly based on the weather forecast. I’m not sure if the Dark Sky app is often used as a route planner…
Anyway, I recorded quite a large chunk of our journey with my GoPro, and came back with a ridiculous amount of video footage, some of which had technical issues to overcome, and I discovered I had a mammoth editing task on my hands. I feared it could be well into the spring before I was able to share any of it. And then we had a spring unlike any other. So then I hoped that lockdown would give me more time to work on projects like this, but actually 2020 has been really quite a busy year for me, and it was only once we got back towards Christmas again that I was actually able to devote any time to it.
“At least”, I said to myself, “I have to finish it before the end of the year.” And I did! I clicked ‘upload’ on the final episodes just before midnight last night. 🙂
Now, let’s be clear here: You’ll note I say ‘episodes’ above. There are, in fact, nine of them, and that’s after I’d edited out enough material for at least four more! This is perhaps the most extreme let-me-bore-you-with-my-holiday-snaps variant one can come up with, and I don’t expect the average Status-Q reader to be interested in watching one, let alone nine of these little narratives.
An AirBnB for New Year’s Eve, December 2019
The van is visible in the bottom right. Click for a larger version.
Amazingly, though, there are people who will enjoy my holiday snaps! Some are watching already.
Those longing for the open road amidst Covid restrictions, or those planning their next motorhome trip in more normal times, do like to get ideas for their next adventure, or relive the memories of journeys past, and road trip videos are very popular on YouTube. I’ve watched a lot of them, and some were partly responsible for me buying the van in the first place.
That’s before you get into the experiences, hints and tips of the full-time motorhomers: try searching YouTube for ‘van life’ if you want to enter another world.
But, even though producing this has, in some ways, been a burden that I wanted to get off my shoulders for a whole year, it’s also been a joy. Rewatching my holiday several times over means that some of the best bits are burned into my memory; there are sites, sounds and places that I would otherwise have forgotten in a month, and that I’ll now remember for ever.
And, in the unlikely event that you want to experience any of it too, there’s a YouTube playlist, and the journey begins here:
Rose suggested a better rhyme for the old carol:
It works better if you pronounce ‘grass’ the way she does, rather than the way I do!
When I was young, you didn’t put your own petrol in your car. Self-service petrol stations were still a novelty in the UK, and you just drove up to the pump, wound down the window and said, “Fill her up with four-star, please!” (That’s a phrase, I realise, that would be unknown to anyone under about forty years of age here.) It was terribly civilised… assuming that an attendant was available when you needed them. Interestingly, in New Jersey (and one or two other small areas of the States), self-service fuelling is illegal. I had this explained to me by the attendant when I tried it once…
Of course, a visit to a petrol station today is often simultaneously smelly, messy and expensive, which is why I’m glad that it’s been a very rare experience for me in the last five years: most of my refuelling comes from just plugging my EV in at home. This has, however, been considerably easier since I had my own driveway; for the first couple of years I had on-street parking only.
About 40% of the homes in the UK don’t have any off-street parking — the vast majority of those being in inner cities — and this does make EV ownership much harder. It’s a lot better than it used to be, today’s cars having much larger batteries and recharging much more quickly than when I started. Going to the charger once a week for a quick top-up is more viable now, if you can’t, say, charge at work, but it’s still not as handy as plugging in your car overnight at home.
So I was interested to receive an email this week from a new service called Zumo. They will appear at your doorstep on their e-scooters, take your car away overnight and return it to you, fully charged, in the morning. I have no idea how commercially viable this is in the longer term, but I think it’s a great idea, and I applaud their ingenuity. The opportunity to add extra services, such as cleaning, checking the tyre pressures and the washer fluid etc — maybe even an overnight MOT test — could make for a very low-hassle car ownership experience!
Eventually, of course, cars will be able to go off and charge themselves. Five years ago, Tesla released a little video (below) showing how they might be able to plug in when they get to the charging station. Cunning, but a little bit creepy!
In the meantime, however, I wish Zumo every success, and I hope they can find a pricing model that works.
I have a new car. It’s rather clever. As I’m driving along it can recognise nearby vehicles, people, cyclists, traffic cones…
But I was somewhat amused yesterday to discover that it can also recognise wheelie-bins.
(Click for a larger image.)
I’m trying to imagine what I would have thought, back in the days of my old rusting Minis and Hillman Imps, if you’d told me that one day my car would have a built-in ability to recognise and draw pictures of the waste-disposal facilities it was passing…
Waitrose are, once again, selling mice pies under the ‘Heston’ brand. Apparently, this is something to do with a celebrity chef and has nothing to do with Ben Hur.
Anyway, they’re rather good, as you can see from the emptiness of the packet.
However, I couldn’t help feeling that since they were mince pies, and in particular ‘Night Before Christmas Mince Pies’, the label ‘Best before 14th January’ might be somewhat superfluous?
Yesterday was an interesting day for me: I part-exchanged my old electric car for a new one, and got a vision of the future.
I had a great fondness for my old BMW i3, despite its foibles; we had been through a lot together in the pioneering early days of EV ownership (that is, about five years ago!) But it definitely represented the past, and, given that part of my plan here has been to try living in the future, it was time for a change. Before selling it, I charged it at the new Gridserve Electric Forecourt (and almost had a charging experience reminiscent of the early days!). But everything worked out in the end.
Here’s a video.
If you don’t want to see me reminiscing about my experiences with the i3, you might want to start 7 minutes in!
Have nothing in your house that you do not know to be beautiful, or believe to be useful, or can connect to Home Assistant .
If buying for others, you may need two of the above.
© Copyright Quentin Stafford-Fraser
Recent Comments