YOU CAN BUILD A REAL HARRY POTTER WAND THAT CONTROLS YOUR HOME
Wave a wand in the air and your room turns blue, red, green or dark: a Python project that brings Harry Potter spell casting to a smart home.
by Adam Thole
AutomationHome
Built withRaspberry Pi3D printing
- difficulty
- ●●●●○
- time
- a weekend-plus
- license
- MIT
- repo
- repo FINISHED48 stars
●●●●○ · a weekend-plus · MIT · 48 stars · repo FINISHED
WHAT YOU’LL NEED
Jump to section
COMPAREE VERDICT
PyPotter is a Python project that watches an infrared camera, recognises the shape you draw in the air with a reflective-tipped wand, and triggers Home Assistant automations: change the light colour, play a song, pop popcorn. The idea comes from the interactive wands at Universal's Wizarding World of Harry Potter. The hardware is a Raspberry Pi Zero W with a Pi NoIR Camera V2, infrared LEDs taken from a ready-made IR illuminator and a 3D-printed case; the wand is a 3D-printed stick with reflective tape on the tip. The Pi only streams video. PyPotter runs on a computer, tracks the tip with OpenCV and matches the path against the included training images for nine spells. The GitHub README is short and points to the creator's blog, where three posts cover the wand, the camera (with a full parts list and setup steps) and the software. Two things to know: the case must be printed in a heat-resistant material such as PETG, because the IR LED board gets hot, and the setup steps date from 2019 (Raspbian Stretch, last code update October 2020), so newer system versions may need adjustments. If you already run Home Assistant and know some Python, this is a weekend-plus project with a great party payoff.
IN THE REPO
GOOD TO KNOW
- —Python code, an example Home Assistant YAML file, training images for nine spells plus a "mistakes" set, and STL and STEP files for the camera case are in the repository.
- —Full parts list and Pi setup steps are in Part 2 of the creator's blog series, not in the repository.
- —Three blog posts cover the wand, the camera and the software; the README links only to the blog's smart home category.
- —Recognition uses the included training images; an optional training mode lets you add your own wand paths.
- —MIT licence, so commercial use is allowed.
- —Last code update: October 2020.
Parts to buy
11 itemsFrom our check of the build. Exact quantities and part numbers are in the creator’s BOM.
- Raspberry Pi Zero WFind
- Pi NoIR Camera V2Find
- Pi Zero camera cableFind
- High-power IR LED illuminator to take apartFind
- 5 V converterFind
- Optional IR filterFind
- Micro SD cardFind
- 12 V power supplyFind
- M2 and M3 screwsFind
- White micro prismatic reflective tape for the wand tipFind
- Smart home devices in Home AssistantFind
Can I build this?
Build at your own risk. Projects involve tools, electronics and sometimes mains voltage — follow the creator’s safety notes.
Videos
Controlling Smart Home With Harry Potter Wand0:41
Adam Thole's own 41-second video of the finished smart wand. The build instructions are in the three blog posts, not in the video.
More builds like this
All projectsStart here
Navigation into the creator’s own docs — we don’t rewrite the guide, we route you to the source.
- 1.Read the three blog posts (Part 1 covers the wand, Part 2 the infrared camera with its parts list, Part 3 the software.)
- 2.Print the camera case from the Mechanical folder (Base, Camera_Shell and Electronics_Holder. Print in PETG, not PLA; the creator used 0.1 mm layers because the shell has a thread.)
- 3.Build the infrared camera unit (Pi Zero W, Pi NoIR Camera V2, the LED board and power board from an IR illuminator, and a 5 V converter so one 12 V supply powers everything.)
- 4.Set up video streaming on the Pi (The blog uses mjpg-streamer at 640 x 480 and 41 fps, started automatically on boot.)
- 5.Run PyPotter on a computer (It takes three arguments: the camera stream URL, your Home Assistant URL and a Home Assistant access token.)
- 6.Set up the Home Assistant automations (Use Home Assistant/smart_wands.yaml as a template and point it at your own lights and switches.)
Resources
Documentation, files and community threads for this build — we link straight to the original sources and never rehost the creator’s files.
KNOWN ISSUES
- The GitHub README has no parts list or guide; it links only to a blog category page. The parts list and setup steps are in Part 2 of the blog series.
- Print the camera case in PETG or another heat-resistant material. The creator says PLA will not work because the IR LED board gets hot.
- The setup steps date from 2019 (Raspbian Stretch Lite, mjpg-streamer) and the code was last updated in October 2020, so newer Raspberry Pi OS versions may need adjustments.
- The Pi Zero W only streams video. PyPotter runs best on a separate PC, which has to be on whenever you want to cast spells.
- You need Home Assistant already running with lights, switches or speakers set up. The included YAML defines automations for a light named light.office, which you will rename to your own devices.
- Frame rate and field of view matter: the creator streams at 41 fps to use a narrower part of the camera sensor and notes that at 90 fps one of his Pi Zeros kept shutting down, likely from overheating.
Does the wand have electronics in it?
No. Infrared light from the camera unit bounces off a reflective tip and the camera tracks it. The creator tested reflective paint, IR reflective tape and white micro prismatic reflective tape, and the white tape worked best. He says the official Universal interactive wands also work.
Can I use a regular Raspberry Pi camera instead of the NoIR?
The build uses the Pi NoIR Camera V2 because it has no infrared-blocking filter, so it sees the infrared light reflected from the wand. A regular Pi camera blocks most infrared, so stick with the NoIR. The extra IR filter in the parts list is marked optional.
Do I need a separate computer, or can the Pi Zero do the recognition?
The Pi Zero W streams the video and PyPotter runs on another machine. The creator says PyPotter can run on a Pi, but a standard PC gives better performance; if you do use a Pi, he recommends turning off background removal.
How many spells can it recognise?
The repository includes training images for nine spells (aguamenti, alohomora, incendio, locomotor, reparo, revelio, silencio, specialis revelio, tarantallegra) plus a "mistakes" set that catches random movements. The example code triggers Home Assistant actions for seven of them. A training mode saves your own wand paths so you can add or improve spells.
Does this work with Alexa, Google Home, or other non-Home Assistant systems?
Not directly. PyPotter calls the Home Assistant REST API. The creator says you can modify the code to control devices another way, which means rewriting HassApi.py.
Community builds
No community builds yet — be the first, we feature the best ones.
Discussion1
FROM THE COMPAREE TEAM
Nine spells ship as training images: aguamenti, alohomora, incendio and six more. Which one would you map to your lights first?
Adam Thole
Adam Thole got the idea from the interactive wands at Universal's Wizarding World of Harry Potter, but built it for his son's Harry Potter-themed birthday party, written up in March 2019. Two wand stations let the kids cast spells to play a song, change the lights, turn on a fountain and pop popcorn, and every guest took home a 3D-printed wand.
DISCLAIMER
- Comparee is not the author of the projects featured here. All rights to each project belong to its creator — every page links to the original source, and we never host creators’ files.
- Information is provided without warranty and may become outdated as projects evolve. Prices are indicative bands only — always check the creator’s parts list for current costs.
- Building and operating any project is at your own responsibility. Protective equipment, safe workshop practice and compliance with local regulations are the builder’s responsibility.
CompareeTEAM4d ago
What you get: working code, an example Home Assistant config, training images for nine spells and the camera case files on GitHub, plus a three-part write-up on the creator's blog with the parts list and setup steps. The catch: the README links only to the blog's category page, so go straight to the three posts. Print the case in PETG, because the IR LEDs get hot, and remember the Pi only streams video; a separate computer does the recognition and talks to Home Assistant.