Mushroom Template Card: Your Own State Description, No New Automation

Mushroom Template Card: Your Own State Description, No New Automation

Module 15 · Lesson 3

Start Pro v1 has separate tiles, temperature, humidity, the LED. The household sees three numbers side by side and has to assemble them into a picture of "how's the office doing" on their own. This lesson combines that data into one block, a Mushroom Template Card called "Office Now." One tile, one readable description, zero new automation.

Template Card is genuinely a presentation layer. It doesn't replace Module 12's logic. You're not creating an "office state" helper. You're not writing an automation that stitches text together every minute. You're using Jinja templates inside the dashboard to show what the entities already know.

Plan on roughly thirty-five minutes. You need a working Start Pro v1 from Lesson 2. If Mushroom isn't installed, go back to Lesson 2 first.

Before you start: don't delete Lesson 2's cards yet

In Lesson 2 you built Start Pro v1 with separate tiles for temperature, humidity, the status LED, and the scene. Don't delete them right away. First add the "Office Now" Template Card beneath them, or on the Office view instead. Only after testing do you decide whether Template replaces some of those tiles or stays as a room summary alongside them.

The working rule, add Template as a test first. Remove duplicates only afterward. Don't tear apart a working Start Pro before the new card is confirmed working on your phone.

A custom card doesn't fix a bad dashboard. A custom card improves a good one. Template Card is a front-end layer, a better description of state, not new home logic.

Template Card versus Entity Card

Mushroom Entity Card shows one entity, a value, an icon, maybe a toggle. It's great on Start when the household needs a quick "72.4°F" or a way to flip the "Status LED" card. Mushroom Template Card assembles several entities into one description, something like "Office, 72.4°F, humidity 45%, LED on." The household gets a sentence, not a three-tile puzzle to piece together themselves.

A single entity needing a quick read or toggle calls for Entity Card. Several entities folded into one "right now" description calls for Template Card. A list of diagnostic helpers should stay a Module 13 entities card. And a twenty-four-hour trend chart belongs on Climate, not in a Template.

On Start Pro you can genuinely keep both, a separate Entity card for quick LED control and a Template "Office Now" as a summary. Or put Template on the Office view and leave Start with plain Entity cards. Pick one primary spot so you're not duplicating the same information five times over.

Jinja templates: text, not logic

In Template Card you use Jinja2 syntax inside the primary, secondary, and icon fields. You read entity states through states('sensor.office_temperature_esp') or the state_attr shorthand. It's the same language used in template sensors, but here the result lands on the dashboard screen, not in a new Home Assistant entity.

The key difference, a dashboard template genuinely doesn't trigger any action. It doesn't turn the LED on. It doesn't switch a light off. It only describes state. Control stays with Entity Card, Button Card, or the automations from Module 12. When someone on a forum suggests "make a template sensor and an automation that keeps it updated" just for one card, that's genuine overkill at this stage of the course.

Keep templates short. Two lines of text are plenty. If a template balloons into thirty lines of if/else, move part of that logic into a separate YAML template sensor, outside this lesson's scope, or simply simplify the description.

Jinja in Template Card: three functions to start with

Three Jinja constructs are genuinely enough for the "Office Now" card. Save the rest of the Jinja2 documentation for later, when you're writing your own YAML template sensors.

states('entity') returns the current value as text, {{ states('sensor.office_temperature_esp') }} gives you "72.4" or "unavailable." is_state('entity', 'state') returns true or false, is_state('switch.led_status_office', 'on') checks whether the status LED is lit. And state_attr('entity', 'attribute') reads an attribute, units or a friendly name, say, though you'll rarely need it here since you're typing names in by hand.

Conditionals, {% if %}, {% else %}, {% endif %}, let you swap a technical "unavailable" for something like "no reading." That's the only logic you genuinely need in this lesson. You're not building loops, filtering lists of entities, or calling HA services.

A sketch for handling an unavailable entity sets a variable to the sensor's state, checks whether it falls into unknown, unavailable, or none, and shows "Office, no reading" in that case, or "Office, [value]°F" otherwise.

Once the ESP32 comes back online, the text updates itself at the next state refresh. You don't need to restart the dashboard or Home Assistant.

Template is NOT an automation

Worth repeating, since it's the most common beginner mistake on forums, a template inside Mushroom Template Card genuinely doesn't trigger an action. It doesn't turn the LED on. It doesn't switch a light off. It doesn't start the hallway timer. It only renders text based on the entities' current states at the moment the card refreshes.

Module 12's automation decides "when." Template says "what's visible right now." When someone suggests "build a template sensor and an automation that updates it every minute" just for one dashboard card, that's overkill. Template Card refreshes whenever its source entity's state changes. That's genuinely enough for an "Office Now" description.

LED control stays with Entity Card or Lesson 4's Button Card. A template sitting next to a button is a genuinely good pairing, a state description plus an action beside it, not crammed into one template.

Performance: brief, and no need to panic

One Template Card with three entities genuinely won't strain Home Assistant. Problems start when a single view carries twenty cards each running long Jinja loops over every entity in the house, or when you refresh templates every second through your own timer. None of that happens in Module 15.

A practical rule, one Template Card equals one room, one "right now" description, a handful of course entities at most. If the dashboard slows down after adding Template, look at the number of custom cards on the view, not the Jinja running over three office sensors.

On the mobile view, keep to one Template Card on Start or Office, not five copies of the same template scattered across every view.

The primary, secondary, and icon_color fields

Primary is the main line, the one the household reads first, the office temperature. Secondary is the second line, humidity and the status LED's state. Both fields in Mushroom Template Card accept Jinja templates. Older configurations sometimes use a secondary_info option, but this course sticks to the explicit secondary field in YAML, since it gives you full control over the wording.

icon_color is a color template for the card's icon. In the "Office Now" map, an LED that's on gives an amber color, off gives blue. That's a subtle visual hint alongside the text, not a substitute for the secondary description. A household member with weaker color contrast still reads the words "on" and "off."

A sketch for an LED-driven icon color checks whether the LED switch is on, giving amber, checks whether it's unknown, unavailable, or none, giving grey, and otherwise gives blue.

Don't overdo conditional colors. Two LED states are plenty. Five temperature colors starts to look like a weather alert and confuses the household.

A minimum, standard, and extended version

The minimum version is one Template card with temperature and humidity, no colors, no conditionals, just understanding the mechanism. The standard version adds the status LED and handles missing readings. The extended version adds an icon color tied to the LED's state and a test run through Developer Tools, Templates.

Building the "Office Now" card

Open the Office view, or Start if you want the summary on the household's hub. Add a Mushroom Template card. Card title, "Office Now." In primary, put temperature. In secondary, humidity and the LED's state in household language, "on" or "off," not raw entity states.

Refer to the switch.led_status_office entity as "Status LED" in the text, the same as the Entity card in Module 13. Consistent naming matters more than a flashy icon.

A minimum YAML sketch, with no conditionals yet, reads type: custom:mushroom-template-card, primary "Office Now: [temperature]°F," secondary "Humidity: [value]%," icon mdi:desk, entity sensor.office_temperature_esp, tap_action more-info.

That version doesn't yet handle "unavailable." It's good for understanding the mechanism. The standard version below adds "no reading" messages and the status LED's state.

A standard-version sketch, with friendly names and missing-reading handling, sets a temperature variable and checks for unknown, unavailable, or none, showing "Office Now: no temperature reading" or "Office Now: [value]°F" accordingly. Its secondary sets humidity and LED variables, showing "Humidity: no reading" or "Humidity: [value]%," followed by "Status LED on," "Status LED off," or "Status LED: no connection" depending on the LED's actual state. The icon stays mdi:desk, with icon_color following the same amber, grey, or blue logic described above, and the entity and tap_action stay the same as the minimum version.

If Template Card gives you trouble, fall back to two plain Mushroom Entity cards, temperature and humidity. The dashboard keeps working, just without the "Office Now" summary.

The entity field points at the card's "main" entity, temperature here. A tap opens that entity's more-info window. If you'd rather a tap do nothing, set action: none. On Start Pro, more-info is often worth keeping, the household can glance at temperature history without opening Developer Tools.

The unknown and unavailable block is genuinely good practice. When the ESP32 goes offline, the household sees "no reading," not an empty tile or a technical-sounding "unavailable."

Friendly text for the household

Template Card's goal genuinely isn't to show off your Jinja skills. It's a sentence your partner understands without ever taking a Home Assistant course.

A poor version reads something like "switch.led_status_office: on, sensor.office_humidity_esp: 45.2." A good version reads "Humidity 45%. Status LED on." And better still is short, plain language, no HA shorthand, one thought per line.

The icon color can signal the LED's state, amber when on, blue when off. That's a subtle visual hint, not a substitute for the text description. A household member with weaker color contrast still reads secondary.

Don't fold test helpers, the hallway timer, or an Auto 3 threshold into Template. Those are information for you on Diagnostics, not for "Office Now."

Where to place "Office Now"

You've got two sensible options, pick one as the primary spot. The Office view keeps Template at the top as a room summary, with Entity or gauge cards below it as in Module 13, a logical spot for "the room's state." Start Pro keeps Template under the "Today at Home" markdown, alongside or in place of the separate temperature and humidity tiles, fewer cards, a faster visual scan.

If you put Template on Start and keep all three Entity cards from Lesson 2, you've got duplication. Either Template replaces the separate temperature and humidity tiles, or it stays on Office. A custom card doesn't fix a bad dashboard, five cards saying the same thing is still clutter, just a prettier one.

Don't add the test scene, scene.office_test, to Template, Start, or the mobile view. It stays on Diagnostics or Admin.

Where not to use Template Card

Test helpers, the timer, and the diagnostic script don't belong in Template. Neither does scene.office_test on Start. Twenty-four-hour trend charts belong on the Climate view instead. And a Zigbee battery list or a list of unavailable entities is Auto Entities' job, arriving in Lesson 7, not Template's.

Testing the template in Developer Tools

Before pasting a long template into a card, you can check it in Developer Tools, Templates. Paste a fragment of your primary or secondary field and preview the result against live entity states. That saves you five rounds of "save the dashboard, see the error, fix the YAML."

A sample test, type in just the temperature line and check whether, with the ESP32 turned off, you get "no reading" rather than an empty string. That's the same condition as in the "Office Now" YAML map. Developer Tools doesn't replace the card, it just speeds up debugging.

Remember, a Developer Tools test is a text preview. It doesn't run a script or a scene. Control still belongs to Lesson 4's Button Card.

Template and automation: a line of responsibility

In Module 12, an automation decides, "when there's motion and the temperature threshold is met, turn on the LED." Template Card only says, "the LED is on." Don't confuse these layers. When a template starts carrying logic like "if temperature's above the threshold, show a red message and call scene.turn_on," you're moving decisions onto the dashboard. Your partner sees a red message and has no idea whether it's an alert or decoration.

Acceptable inside Template, a state description, an icon color, "on/off" text, a no-reading message. Not acceptable at this stage, calling HA services, setting helpers, or simulating an automation inside Jinja. That's what Module 12's rules and scripts are for.

If you ever want a dedicated "office state description" sensor in YAML, you'd build that separately as its own template sensor. This lesson deliberately sticks to a dashboard Template Card, since that's simpler and genuinely enough for an "Office Now" description.

One line or two: the secondary field's variants

In the YAML map, humidity and the LED sit in one secondary field, separated by a middle dot. On a narrow phone screen you can split that into two lines, inserting a line break in the template or shortening the wording, something like "Hum. 45% · LED on." Test on the mobile view. A template that looks elegant on desktop sometimes gets cut off mid-sentence on a phone.

Don't cram five more entities into secondary just because they technically fit. "Office Now" is three course signals, not a service report.

Questions about Template Card

Can Template turn the LED on? Not through the template itself. Toggling stays with Entity or Button Card. Do I need a YAML template sensor? Not for this lesson, a dashboard Template Card is enough. Does "Office Now" replace the gauge from Module 13? It doesn't have to, the gauge can stay alongside Template on Office, or disappear if Template already gives a fuller picture.

A real-world example: template instead of a conversation

Your partner asks, "how's the office?" Without Template, you point to three tiles, temperature here, humidity there, the LED beside them. With Template, you point to one block, "Office, 72°F, humidity 45%, LED on." That's the difference between a technical panel and an answer in the household's own language.

Template doesn't replace the conversation about whether 72°F feels comfortable. It just shortens the path from question to fact. Decisions about heating still belong to the household or the automation, not to a dashboard card.

After saving the card, open the view on your phone and wait a minute for the ESP32 to send its next reading. Template refreshes with the entity's state in real time. You don't need to refresh the page, unless you've edited the YAML itself. If the value sits frozen, the problem lies in the sensor or the ESPHome integration, not in Template Card.

In Lesson 5 you'll use "Office Now" as the top section of the Office Pro room card. That's why it's worth polishing the wording now, short, plain, no technical shorthand.

What can go wrong

A Jinja syntax error, a missing {% endif %}, shows "Template error" on the card, and the YAML editor will highlight the problem. Building an automation instead of a template adds needless complexity, a dashboard template is enough for a description. A raw entity ID left in primary shows the household technical gibberish, fix it with plain names. Duplication with an Entity card, temperature, humidity, and Template sitting side by side with no plan, pick one pattern. And a helper inside a Template on Start is a pretty description carrying the hallway test mode along with it, the wrong view for that information.

Assignment: build the "Office Now" card

Work through this in order, and check on your phone that the text reads clearly without zooming. Add a Mushroom Template Card titled "Office Now." In primary, temperature from sensor.office_temperature_esp, with missing-reading handling. In secondary, humidity and the status LED, on or off. Set a sensible icon color, or leave the default. Place the card on the Office view or Start Pro, one primary spot. And confirm there's no helper, timer, script, or test scene anywhere in the template.

Ask someone in the household to read the card without any context from you. If they say "I can tell the office is fine" or "the LED's on," the template's working. If they ask "what's a switch?", fix the wording.

"Office Now" is a bridge between raw entities and the household's own language. In upcoming lessons you'll add Button Card for control and assemble the full Office Pro view. Template stays a description layer, it doesn't replace buttons or the hallway automation from Module 12.

Key takeaways

Template Card combines several entities into one "right now" description.

Jinja templates in a dashboard are presentation, not automation.

"Office Now" translates temperature, humidity, and the status LED into household language.

Entity versus Template, one entity versus a summary. Don't duplicate without a plan.

Test scenes and helpers stay well away from the "Office Now" card.

What's next

In Lesson 4 you install Button Card and swap buttons over to it, tap for the LED and the scene.office_evening scene, hold for script.office_led_signal, Diagnostics-only. Bigger buttons, more control over the action, the same safety rules as Module 13.

Finish "Office Now" and test it on the mobile view first. Button Card builds on a stable state description, not an empty view.

Once the template's working, copy the card's YAML into your notes. In Lesson 5 you'll paste that same block into Office Pro's vertical stack instead of writing it from scratch, saving time and keeping the wording consistent between Start and the Office view.

Finished this lesson?