💡 Want to create custom sensors in Home Assistant to track lights and rooms easily?
📊 Learn step-by-step how to build template sensors with Jinja & YAML for your smart home dashboards!
In Episode 7 of the YAML & Jinja Templating Course, we dive into creating custom template sensors in Home Assistant. This tutorial shows you how to display the number of lights on, which lights are on, and even lights per room on your dashboard. Perfect for home automation enthusiasts and those wanting to enhance their smart home dashboards.
✅ What You’ll Learn in This Episode:
👉 Template Helper Method: Quickly create a sensor to return a single state value
👉 Advanced Template Sensors: Store multiple values in attributes for more detailed data
👉 Counting Lights On: Build a sensor to track the number of lights currently on
👉 Tracking Lights Per Room: Filter sensors by area to see lights on per room
👉 Attribute Management: Add custom attributes like light_names to display exact lights
👉 Dashboard Integration: Display your sensor values using markdown cards for a clean visual
👉 Editing Templates: Use Studio Code Server or File Editor to manage all templates centrally
💻 Pro Tips:
👉 Always use a unique_id for template sensors for easy editing in Home Assistant
👉 Chain filters to refine which devices are counted
👉 Apply the same method to doors, windows, or other devices for automation monitoring
📌 Recommended Viewing: Make sure you’ve watched Episodes 1-6 for a complete understanding of loops, math, date/time, and filtering in Jinja. Playlist link:
https://www.youtube.com/playlist?list=PLKuGrHcHLKMiUTClEE8vb60m9v3ijFEhQ💖 Support this channel via Patreon, Ko-Fi, or channel membership to help continue these Home Assistant tutorials. Don’t forget to like, subscribe, and comment with your custom sensor creations!
⭐ 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:
https://www.youtube.com/playlist?list=PLKuGrHcHLKMiUTClEE8vb60m9v3ijFEhQBlog version:
https://www.smarthomejunkie.net/yaml-jinja-templating-course-episode-7-create-your-own-sensors👉 Get the desktop clock/message ticker that I use in the video:
https://youtu.be/N0NKPJzGHuA⭐⭐⭐
* Join this channel to get access to perks: 📺
https://www.youtube.com/c/smarthomejunkie/join* Please consider becoming my patron 🏅 at
https://www.patreon.com/join/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/review-and-advertisement-information/ ⭐
My Devices:
https://github.com/smarthomejunkie/MyDevicesInstagram:
https://www.instagram.com/smarthomejunkie/X:
https://www.x.com/smarth0mejunkieMastodon:
https://mastodon.world/@smarthomejunkieFacebook:
https://www.facebook.com/smarthomejunkie/TikTok:
https://www.tiktok.com/@smarthomejunkieDiscord:
https://discord.gg/at8v5hW00:00:00 Introduction
00:01:18 How do you create your own sensor in Home Assistant?
00:01:23 Deploying a Template Helper
00:03:27 Creating advanced templates
00:03:44 Install Studio Code Server or File Editor
00:06:04 Adding your first sensor
00:07:56 What lights are exactly on?
00:09:07 What lights are on in a specific room?
00:10:02 Show the values of a custom template sensor on a dashboard
00:11:53 Outtakes
#HomeAssistant #JinjaTemplates #YAMLTemplates #HomeAutomation #TemplateSensors #SmartHome #HomeAssistantTutorial #LightsOnCounter #DashboardSensors #LearnJinja #HomeAssistantDashboard #SmartHomeAutomation