QR Codes Were Stupid, Home Assistant Proved Me Wrong
- Scan speed
- m/min
- Result
- Time to scan (min)
- 2 min
- You entered
- Distance to scanner (m)
- 5 m
- You entered
QR codes seemed like a pointless, clunky way to share a link—until they became the most reliable trigger in a smart home setup. This article explains why QR codes are actually a powerful tool for Home Assistant automations, how to use them, and what to watch out for.
Why QR Codes Seem Stupid (and Why That’s Wrong)
Most people first met QR codes as ugly black squares on posters or restaurant menus. They required a camera app, a steady hand, and often led to a slow-loading website. That experience made them feel like a gimmick. But in a home automation context, QR codes are not about scanning a menu—they are about giving a physical object a unique, machine-readable identity. A QR code is essentially a barcode that can store up to about 3KB of data, including URLs, text, or even commands. When you stick a QR code on a door, a shelf, or a child’s backpack, you turn that object into a trigger. Scanning it with a phone or a fixed camera can tell Home Assistant exactly what you want to happen, without needing a voice assistant, a button, or a complicated sensor.
How Home Assistant Uses QR Codes
Home Assistant is an open-source home automation platform that runs on a Raspberry Pi, a NAS, or a small PC. It connects to hundreds of devices and services, and it can react to events. A QR code scan is one such event. The typical setup involves a phone with a camera and a companion app, or a fixed USB camera connected to the machine running Home Assistant. When the camera sees a QR code, it sends the decoded text to Home Assistant, which then runs an automation. The text can be anything: a room name, a command like “start movie,� or a URL. The automation reads that text and acts on it. For example, a QR code on the front door could trigger a “guest mode� that turns on lights, unlocks a smart lock, and sends a welcome message. A QR code on the coffee table could start a “movie night� scene that dims the lights and lowers the projector screen.
Why QR Codes Beat Other Triggers
Voice assistants like Alexa or Google Home are convenient, but they can misinterpret commands, require wake words, and fail in noisy rooms. Physical buttons are simple but require wiring or batteries, and they are easy to press accidentally. Motion sensors detect presence but not intent—they can’t tell if you’re entering a room to read or to clean. QR codes are explicit and unambiguous. You scan the exact code you want, and the action is always the same. They also cost almost nothing: a sheet of printable labels costs a few dollars, and you can generate codes for free. They are also reliable—no Wi-Fi needed for the code itself, only for the device that scans it. And they are easy to change: if you want a different action, you just print a new code and stick it over the old one.
How to Set Up a QR Code Automation
Setting up a QR code automation in Home Assistant is straightforward. First, generate a QR code that contains a unique text string, such as “guest_mode� or “movie_night�. You can use any free QR generator website or a command-line tool. Then, print the code and place it where you want it. Next, you need a way to scan it. The easiest method is to use the Home Assistant companion app on a smartphone. The app has a built-in scanner that can send the scanned text to Home Assistant as an event. Alternatively, you can use a USB camera with a QR code scanner integration, such as the “qr_code� platform that uses OpenCV. Once you have the scan event, create an automation in Home Assistant that listens for that event and triggers your desired actions. The automation can be as simple as turning on a light or as complex as running a script with multiple steps.
Common Problems and How to Fix Them
The most common issue is that the camera can’t read the code because it’s too small, too far, or in bad lighting. The fix is to print the code larger and ensure it’s well-lit. Another issue is that the companion app might not send the scan event if the phone’s battery saver mode is on, or if the app is not running in the background. You can work around this by using a dedicated scanner device that is always on. A third issue is that the QR code contains a URL that opens a browser instead of sending a text event. To avoid this, make sure the code contains only the text you want, not a URL. Finally, if you have multiple cameras, make sure they are not all trying to scan the same code, which can cause duplicate events. You can filter by camera entity in the automation.
Comparing QR Codes to Other Smart Home Inputs
QR codes are not the best choice for every situation. For frequent, quick actions, a physical button or a motion sensor is faster. For hands-free control, voice is better. QR codes shine in scenarios where you want a specific, location-based action that doesn’t happen often, and where you want to avoid accidental triggers. For example, a QR code on the garage door to open it is better than a motion sensor, which might open it when a cat walks by. A QR code on the front door for guests is better than a voice command, because guests don’t have your voice assistant linked. They are also useful for temporary setups—like a QR code on a table for a party that turns on party lights—because you can remove it later without rewiring anything.
Costs and Safety Considerations
The cost of a QR code system is minimal. You need a printer and paper or labels, which you likely already have. The scanning device can be a phone you already own, or a USB camera that costs around $20. There are no subscription fees for the QR code itself. Safety-wise, QR codes are safe to use in a home environment. They are just printed patterns. However, be careful about what you put in the code. If you use a URL that points to a web service, that service could change or go down, breaking your automation. For critical actions like unlocking a door, consider adding a second factor, such as a PIN or a fingerprint, to prevent someone from scanning the code and unlocking your door when you’re not home. Also, be aware that a camera that is always on might raise privacy concerns for family members; place it in a common area and inform everyone.
Alternatives to QR Codes
If QR codes don’t fit your use case, there are other ways to trigger automations. NFC tags are similar but require a phone to tap them, which is faster and works offline, but they are more expensive and can be damaged. RFID cards are another option, but they require a reader. Barcodes are less common in home automation but can be used with a barcode scanner. Bluetooth beacons can trigger actions based on proximity, but they are less precise. The best choice depends on your budget, the frequency of use, and whether you want a physical or contactless trigger.
Frequently Asked Questions
Can I use a QR code to unlock my smart lock?
Yes, you can. You would set up an automation that listens for a specific QR code scan and then calls the unlock service on your lock. However, this is not secure because anyone with a photo of the code can scan it. For a lock, it’s better to use a secure method like a PIN code or a fingerprint, or to combine the QR scan with a second factor like a presence sensor.
Do I need a special camera for QR code scanning in Home Assistant?
No, you can use any USB camera that is compatible with your Home Assistant device. The easiest way is to use the companion app on your phone, which has a built-in scanner. If you want a dedicated camera, look for one that supports the “qr_code� platform in Home Assistant, which uses OpenCV. Many standard webcams work.
Can I use a QR code to trigger an automation without a phone?
Yes, you can use a fixed USB camera connected to your Home Assistant server. The camera must be positioned so the QR code is in view. When the code is detected, the automation runs. This is useful for a permanent setup, like a QR code on a wall that you scan with a dedicated camera.
What should I put in the QR code to make it work?
Put a simple text string that is unique and meaningful, such as “guest_mode� or “start_coffee�. Avoid putting a URL unless you want the automation to open a webpage. The text is sent to Home Assistant as an event, and your automation can match it exactly. Make sure the text is not too long, as some scanners have limits.
Can I use a QR code to control multiple devices at once?
Yes, an automation can have multiple actions. For example, a QR code on a desk could turn on a lamp, start a playlist, and set the thermostat. You just add all those actions to the automation that triggers on that specific QR code. This is one of the main advantages of using QR codes—one scan can do many things.
Is there a limit to how many QR codes I can use?
No, you can create as many as you want. Each code just contains a unique text string. The only practical limit is the number of automations you can manage in Home Assistant, which is very high. You can print as many codes as you need and place them anywhere.
Related
Formula used
in t | Time to scan (min) | min | 2 | 0 in d | Distance to scanner (m) | m | 5 | 0 out pace | Scan pace | min/m | t / d | 2 out speed | Scan speed | m/min | d / t | 2
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.