How to Use Template Sensors to Create a Composite "Home Secure" Status in Home Assistant
Look, you've worked hard. You've got sensors on all the doors, motion detectors in the hallways, maybe a glass break listener. Every one has its own little status bubble on your dashboard. And to figure out if your house is actually safe? Manually scanning two dozen tiny green icons. It kind of defeats the purpose. This isn't status monitoring. It's busywork. Your security dashboard feels less like Mission Control and more like a confusing, silent alarm clock no one knows how to read.
The Solution: One Ring to Rule Them All (The Template Sensor)
Here's the thing. You need a single, definitive status. A big, chunky "Home Secure" or "Breach Detected" that tells you everything at a glance. The hero for this job? The humble `template` sensor. This isn't another physical gadget you have to buy. It's a logic construct. You tell it to watch your other sensors, apply some rules, and spit out a brand new, custom piece of data. This is how you turn a mess of inputs into one powerful, simple answer.
Building Your "Home Secure" Composite Sensor
Let's get our hands dirty. You're editing your `configuration.yaml`. We'll create a new binary sensor. It'll be `on` (meaning **insecure**) if ANY of our watchdogs are triggered. Otherwise, it's `off` (meaning **secure**). The logic is beautifully simple. See this block of code? This is your foundation.
```yaml template: - binary_sensor: - name: "Home Secure Status" unique_id: home_secure_composite device_class: problem state: > {% if is_state('binary_sensor.front_door', 'on') %} on {% elif is_state('binary_sensor.back_patio_door', 'on') %} on {% elif is_state('binary_sensor.living_room_motion', 'on') %} on {% elif is_state('alarm_control_panel.house_alarm', 'triggered') %} on {% else %} off {% endif %} icon: > {% if is_state('binary_sensor.home_secure_status', 'on') %} mdi:shield-alert-outline {% else %} mdi:shield-check-outline {% endif %} ```
Just swap out my example entities for your real ones. That `>` after `state:` lets you write a multi-line template. The `icon:` part changes the icon based on the state, which is a nice touch. This sensor now represents your entire perimeter.
Getting Clever with States and Thresholds
But what if "secure" isn't just a yes/no? Sometimes you leave a window open for air. That shouldn't scream "BREACH." You can make this smarter. Use a `sensor` template instead of a `binary_sensor`. Give it string states like "Secure", "Aware", and "Breach". The logic gets a bit more complex, but it's worth it. You can even integrate your alarm's armed state. The rule is simple: if the alarm is armed 'away' and a door opens? That's "Breach". Alarm disarmed and a door opens? Maybe just "Aware". This is where you make it truly yours.
Putting It On the Dashboard: Make It Obvious
Don't hide this masterpiece in the entity list. Create a new dashboard view called "Security." Use a `custom:button-card` or Mushroom's chip card. Make it huge. Color it green for "off" (Secure) and red for "on" (Insecure). The goal is that from across the room, you know the status. No squinting. Your days of playing "Where's Waldo?" with tiny sensor icons are officially over.
What Now? Automate All The Things.
This new sensor is now your automation trigger. When `home_secure_status` turns `on` (insecure), you can have the house shout at you. Flash lights red. Send a critical notification with a snapshot from the front door camera. Play a distinct alert sound on all speakers. The composite status is the trigger. The individual sensors are just the reporters. You've centralised the command logic. That's the real power move.