Never leave your home with lights still on again.
Learn how to count active devices in Home Assistant using YAML & Jinja templates.
In this sixth episode of my Home Assistant YAML & Jinja course, I show you how to filter and count entities using templates. You’ll learn how to display how many lights are currently on—and how to exclude groups and dummy devices for accurate results.
This technique can also be used for doors, windows, sensors, and more.
📌 What You’ll Learn in This Video
✅ How to count lights in Home Assistant
✅ Filtering entities with Jinja templates
✅ Using selectattr and rejectattr
✅ Excluding groups and dummy devices
✅ Creating dashboard counters
✅ Applying templates to other sensors
✅ Preparing data for automations
💡 Why This Matters
Knowing how many lights are still on helps you:
✔️ Save energy
✔️ Avoid forgetting devices
✔️ Create smart notifications
✔️ Improve automations
✔️ Build smarter dashboards
📂 Course Resources
You can download the full template examples via the link in the description to save time and support the channel.
💬 Do you use counters in your smart home? Let me know in the comments!
👍 Like, subscribe, and support the channel if this tutorial helped you.
📌 Recommended Viewing: Make sure you’ve watched Episodes 1-5 for a full understanding of variables, loops, math, date/time, and previous filters. Playlist link: • YAML & JINJA Templating Course
💖 Support the channel via Patreon, Ko-Fi, or channel membership to keep these Home Assistant tutorials coming. Don’t forget to like, subscribe, and comment to share your results!
⭐ You can download all the code that I created for the course at: https://ko-fi.com/s/84ab3c5875 ⭐
Links referred to in this video:
The YAML and Jinja Course Playlist: • YAML & JINJA Templating Course
Blog version: https://www.smarthomejunkie.net/yaml-...
👉 Get the desktop clock/message ticker that I use in the video: • This is the BEST MATRIX DISPLAY CLOCK for ...
⭐⭐⭐
Join this channel to get access to perks: 📺 / smarthomejunkie
Please consider becoming my patron 🏅 at / smarthomejunkie
Or please support me by buying me a ☕ at https://ko-fi.com/smarthomejunkie/
Or sponsor me through PayPal at https://paypal.me/smarthomejunkie
⭐⭐⭐
⭐ If you want me to create a review of your product, please visit this page for information and rates: https://www.smarthomejunkie.net/revie... ⭐
My Devices: https://github.com/smarthomejunkie/My...
Instagram: / smarthomejunkie
X: https://www.x.com/smarth0mejunkie
Mastodon: https://mastodon.world/@smarthomejunkie
Facebook: / smarthomejunkie
TikTok: / smarthomejunkie
Discord: / discord
00:00:00 Introduction
00:01:28 Counting all the lights in your house
00:05:03 How many lights are on in the house?
00:06:27 Bloopers
#HomeAssistant #YAMLJinja #SmartHomeTutorial #HomeAutomation
#HomeAssistantTemplates #Jinja2 #SmartHomeJunkie
#HomeAssistantDashboard #HomeAssistantYAML #IoTSmartHome
#HomeAssistantTips #HomeAssistantCourse