Ultra Vehicle Card: Template Mode Guide
Explore the versatility of Template Mode in your Ultra Vehicle Card. These examples demonstrate how to use Jinja2 templates to dynamically display information and control the appearance of your Info, Icon, and Bar sections. For the examples below, the "OFF" preview shows what you might see if displaying a raw entity state or a default behavior. The "ON" preview shows the result after the template is applied or how it influences the card's behavior.
Info Area Templates
Customize the text displayed in an Info Entity within an Info Row using the value_template field. When Template Mode is enabled for that Info Entity, the card will render the output of your template.
1. Conditional Charging Status
Displays a user-friendly charging status based on a binary sensor like binary_sensor.car_charging_status.
{{ 'Vehicle is Charging' if is_state('binary_sensor.car_charging_status', 'on') else 'Vehicle Not Charging' }}off2. Display Range with Units
Appends 'miles' to the numeric range value from sensor.car_range.
{{ states('sensor.car_range') | int }} miles1503. Summarized Window Status
Shows a single 'Windows Open' message if any window (e.g., binary_sensor.car_front_left_window) is open.
{% if is_state('binary_sensor.car_front_left_window', 'on') or is_state('binary_sensor.car_front_right_window', 'on') %}
Windows Open
{% else %}
Windows Closed
{% endif %}off.4. Tire Pressure Alert
Provides a clear OK or Check Tires message based on binary_sensor.car_tire_pressure_low.
{% set pressure_ok = is_state('binary_sensor.car_tire_pressure_low', 'off') %}
{{ 'Tire Pressure: OK' if pressure_ok else 'Tire Pressure: Check Tires!' }}on (means pressure is low).5. Software Update Notification
Displays a notification if binary_sensor.car_software_update is active.
{{ 'Software Update Available!' if is_state('binary_sensor.car_software_update', 'on') else 'Software Up-to-date' }}off.6. Combined Lock and Trunk Status
Consolidates lock.car_doors and binary_sensor.car_trunk status.
Doors: {{ 'Locked' if is_state('lock.car_doors', 'locked') else 'Unlocked' }}, Trunk: {{ 'Closed' if is_state('binary_sensor.car_trunk', 'off') else 'Open' }}locked.7. Enhanced Location Display
Shows the current zone from device_tracker.car_location or 'Away'.
{% if states('device_tracker.car_location') not in ['not_home', 'unknown', 'unavailable'] %}
Location: {{ states('device_tracker.car_location') }}
{% else %}
Location: Away
{% endif %}not_home.8. Preconditioning Status Text
Clear text for switch.car_precondition.
{{ 'Climate Preconditioning Active' if is_state('switch.car_precondition', 'on') else 'Preconditioning Off' }}on.9. Formatted Last Update Time
Displays sensor.car_last_update.last_changed in a custom format.
Updated: {{ as_timestamp(states.sensor.car_last_update.last_changed) | timestamp_custom('%-I:%M %p, %b %-d') }}2023-10-26T10:30:55.123+00:0010. Low Fuel/Battery Warning Text
Shows warning for sensor.car_fuel_level if below 15%, else shows level.
{% set level = states('sensor.car_fuel_level') | int(-1) %}
{% if level == -1 %}Unknown{% elif level < 15 %}Fuel Low!{% else %}Fuel: {{ level }}%{% endif %}10.Icon Area Templates
Use active_template or inactive_template to define the logic (true/false) that determines if an icon uses its "active" or "inactive" appearance properties. You configure these visual properties (icons, colors, texts like active_state_text) in the card editor's UI. The "ON" preview below describes the outcome when the template logic is met, triggering the active state and potentially showing custom text you'd configure for that state.
1. Multiple Garage Door Status
This active_template is true if any of three garage doors are open. The icon's text would ideally show which one.
Utilizing: Active Template (active_template)
{{ is_state('binary_sensor.garage_door_main', 'on') or is_state('binary_sensor.garage_door_side', 'on') or is_state('binary_sensor.garage_door_workshop', 'on') }}Card Configuration Notes:
In UI, set icon_active: mdi:garage-open-variant. For active_state_text, you might use another template like:{%- if is_state('binary_sensor.garage_door_main', 'on') %}Main Open{% elif is_state('binary_sensor.garage_door_side', 'on') %}Side Open{% else %}Workshop Open{% endif -%} (or simplify if only one can be open).
Inactive: icon_inactive: mdi:garage, inactive_state_text: All Closed.
binary_sensor.garage_door_main is 'on', template true. Icon uses active properties (e.g. text "Main Open").2. Security System Detailed Status
Activates if security system is in any armed state. The text shows the specific armed mode.
Utilizing: Active Template (active_template)
{{ states('alarm_control_panel.home_security') in ['armed_home', 'armed_away', 'armed_night', 'arming'] }}Card Configuration Notes:
In UI, set icon_active: mdi:shield-lock, color_active: red. For active_state_text, use: {{ states('alarm_control_panel.home_security') | replace('_', ' ') | title }}.
Inactive: icon_inactive: mdi:shield-off-outline, inactive_state_text: Disarmed.
3. Light Brightness Level Text
Activates if light is on. Text indicates brightness level.
Utilizing: Active Template (active_template)
{{ is_state('light.living_room_lamp', 'on') }}Card Configuration Notes:
In UI, set icon_active: mdi:lightbulb-on. For active_state_text: {% set brightness = state_attr('light.living_room_lamp', 'brightness') | int(0) %}{% if brightness > 200 %}Bright{% elif brightness > 100 %}Medium{% else %}Dim ({{ (brightness/255*100)|round(0) }}%){% endif %}.
Inactive: icon_inactive: mdi:lightbulb-off-outline, inactive_state_text: Off.
4. Thermostat Mode & Target Temperature
Activates if thermostat is heating/cooling. Text shows mode and target temperature.
Utilizing: Active Template (active_template)
{{ states('climate.main_thermostat').state in ['heating', 'cooling'] }}Card Configuration Notes:
In UI, set icon_active: mdi:thermometer-lines. For active_state_text: {{ states('climate.main_thermostat').state | title }} to {{ state_attr('climate.main_thermostat', 'temperature') }}°C.
Inactive: icon_inactive: mdi:thermostat-off, inactive_state_text: Idle.
5. Media Player Status & Title
Activates if media player is playing. Text shows title and artist if available.
Utilizing: Active Template (active_template)
{{ is_state('media_player.living_room_speaker', 'playing') }}Card Configuration Notes:
In UI, set icon_active: mdi:play-circle. For active_state_text: Playing: {{ state_attr('media_player.living_room_speaker', 'media_title') or 'Unknown Title' }}{% if state_attr('media_player.living_room_speaker', 'media_artist') %} - {{ state_attr('media_player.living_room_speaker', 'media_artist') }}{% endif %}.
Inactive: icon_inactive: mdi:pause-circle, inactive_state_text: Paused/Stopped.
6. Window Open Count
Activates if any window in group.all_windows is open. Text shows count.
Utilizing: Active Template (active_template)
{{ expand('group.all_windows') | selectattr('state', 'eq', 'on') | list | count > 0 }}Card Configuration Notes:
In UI, set icon_active: mdi:window-open-variant. For active_state_text:{% set count = expand('group.all_windows') | selectattr('state', 'eq', 'on') | list | count %}{{ count }} Window{{ 's' if count != 1 else '' }} Open.
Inactive: icon_inactive: mdi:window-closed-variant, inactive_state_text: Secure.
7. Mailbox Alert
Activates on new mail, showing a friendly message.
Utilizing: Active Template (active_template)
{{ is_state('binary_sensor.mailbox', 'on') }}Card Configuration Notes:
In UI, set: icon_active: mdi:email-alert, active_state_text: You've Got Mail!, color_active: '#FFD700'.
Inactive: icon_inactive: mdi:email-outline, inactive_state_text: Mailbox Empty.
8. Appliance Cycle Status
Activates if appliance (e.g., sensor.washing_machine_status) is running. Text shows current cycle.
Utilizing: Active Template (active_template)
{{ states('sensor.washing_machine_status') != 'idle' and states('sensor.washing_machine_status') != 'off' }}Card Configuration Notes:
In UI, set icon_active: mdi:washing-machine. For active_state_text: {{ states('sensor.washing_machine_status') | title }} Cycle.
Inactive: icon_inactive: mdi:washing-machine-off, inactive_state_text: Idle.
9. Plant Sensor Low Moisture Alert
Activates if binary_sensor.plant_kitchen_moisture_low indicates low moisture.
Utilizing: Active Template (active_template)
{{ is_state('binary_sensor.plant_kitchen_moisture_low', 'on') }}Card Configuration Notes:
In UI, set: icon_active: mdi:water-alert, color_active: orange, active_state_text: Needs Water!.
Inactive: icon_inactive: mdi:water-check, inactive_state_text: Moist, color_inactive: green.
10. Person Location Summary
Activates if device_tracker.john_doe is at 'Work'. Text confirms location.
Utilizing: Active Template (active_template)
{{ is_state('device_tracker.john_doe', 'Work') }}Card Configuration Notes:
In UI, set: icon_active: mdi:briefcase, active_state_text: John at Work.
Inactive: icon_inactive: mdi:map-marker-question, inactive_state_text: John Elsewhere.
Bar Area Templates (Left/Right Labels)
Use left_template and right_template in a Bar's configuration to display dynamic text on either side of the progress bar. Enable "Template Mode" for the respective label in the editor. The toggle simulates this, showing the change in the label's text.
1. EV Range (Left Label)
Shows EV range from sensor.my_car_ev_range with unit.
Target Area: Left Label (left_template)
{{ states('sensor.my_car_ev_range') }} miles1502. Battery Percentage (Right Label)
Displays 'SoC: XX%' using sensor.my_car_battery_level.
Target Area: Right Label (right_template)
SoC: {{ states('sensor.my_car_battery_level') }}%803. Conditional Charging Rate (Left Label)
Shows charging rate from sensor.my_car_charge_rate if binary_sensor.my_car_charging is 'on'.
Target Area: Left Label (left_template)
{% if is_state('binary_sensor.my_car_charging', 'on') %}
Charging: {{ states('sensor.my_car_charge_rate') }} kW
{% else %}
Not Charging
{% endif %}binary_sensor.my_car_charging): on4. Plug Status (Right Label)
Indicates if binary_sensor.my_car_plug_status means plugged in or unplugged.
Target Area: Right Label (right_template)
{{ 'Plugged In' if is_state('binary_sensor.my_car_plug_status', 'on') else 'Unplugged' }}off5. Time to Full Charge (Right Label, Conditional)
Shows time from sensor.my_car_time_to_full if charging, else '--'.
Target Area: Right Label (right_template)
{% if is_state('binary_sensor.my_car_charging', 'on') and states('sensor.my_car_time_to_full') not in ['unknown', 'unavailable', ''] %}
Full in: {{ states('sensor.my_car_time_to_full') }}
{% else %}
--
{% endif %}sensor.my_car_time_to_full: 2h 30m (assuming charging is on)6. Cabin Temperature (Left Label)
Display sensor.car_cabin_temperature with unit.
Target Area: Left Label (left_template)
Cabin: {{ states('sensor.car_cabin_temperature') | float | round(1) }}°C21.537. Odometer Reading (Right Label)
Display sensor.car_odometer, formatted with commas and unit.
Target Area: Right Label (right_template)
Odo: {{ states('sensor.car_odometer') | int | format_number(grouping_symbol=',') }} km1234568. Fuel/Energy Consumption (Left Label)
Show sensor.car_average_consumption (Wh/mi) as kWh/100mi.
Target Area: Left Label (left_template)
Avg: {{ (states('sensor.car_average_consumption') | float(0) / 10) | round(1) }} kWh/100mi250 (Wh/mi)9. Bar Entity Value with Unit (Right Label)
Display the bar's main entity value (config.entity) and its unit.
Target Area: Right Label (right_template)
{{ states(config.entity) }} {{ state_attr(config.entity, 'unit_of_measurement') or '' }}config.entity: 75 (Unit: %)10. Relative Time Since Last Update (Left Label)
Show how long ago sensor.car_last_seen was updated.
Target Area: Left Label (left_template)
Updated: {{ relative_time(states.sensor.car_last_seen.last_updated) }} agolast_updated: (e.g. a full timestamp)