YAML & Jinja Part 4: Scoping, Literals, Lists, Tuples & Dicts for Home Assistant

Published at : 23 Dec 2025

🚀 Struggling with variables and data types in Home Assistant? Learn scoping, literals, lists, tuples, and dicts in Jinja step-by-step!
💡 Master advanced templating techniques and make your automations smarter and more powerful.

In Part 4 of the YAML & Jinja course, we dive into scoping behavior and literals, showing how to keep variable values across loops using namespace objects and how to work with different data types.

✅ What You’ll Learn in This Episode:
👉 Scoping Behavior: Keep variables accessible across loops using namespaces
👉 Literals: Strings, integers, floats, booleans for calculations and logic
👉 Lists: Add, remove, replace, and iterate through items
👉 Tuples: Immutable sequences for structured data
👉 Dicts: Key-value pairs for structured data access

📌 Make sure you’ve watched previous episodes first, covering If-Then statements, For-loops, expressions, statements, variables, filters, and comments. Check the playlist link to follow the series step by step: https://www.youtube.com/playlist?list=PLKuGrHcHLKMiUTClEE8vb60m9v3ijFEhQ

💖 Support the channel via Patreon, Ko-Fi, or by becoming a member [links in description]. Don’t forget to like, subscribe, and comment—it helps this channel grow and reach more Home Assistant enthusiasts!

⭐ You can download the code that I created for this video 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=PLKuGrHcHLKMiUTClEE8vb60m9v3ijFEhQ

Blog version: https://www.smarthomejunkie.net/yaml-jinja-templating-course-part-4-scoping-and-literals

👉 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/MyDevices

Instagram: https://www.instagram.com/smarthomejunkie/
X: https://www.x.com/smarth0mejunkie
Mastodon: https://mastodon.world/@smarthomejunkie
Facebook: https://www.facebook.com/smarthomejunkie/
TikTok: https://www.tiktok.com/@smarthomejunkie
Discord: https://discord.gg/at8v5hW

00:00:00 Introduction
00:00:38 Scoping behavior
00:02:32 Literals
00:02:41 Strings
00:02:59 Integers
00:03:14 Floats
00:04:40 Lists
00:06:34 Tuples
00:06:55 Dicts
00:07:31 Booleans
00:08:51 Bloopers

#Jinja #YAML #HomeAssistant #JinjaTutorial #YAMLTemplates #HomeAutomation #LearnJinja #PythonTemplates #SmartHome #JinjaScoping