Conditional card
The conditional card displays another card based on conditions.

Most options for this card can be configured via the user interface.
Adding the conditional card to a dashboard
- In the top right of the screen, select the edit
button. - If this is your first time editing a dashboard, the Edit dashboard dialog appears.
- By editing the dashboard, you are taking over control of this dashboard.
- This means that it is no longer automatically updated when new dashboard elements become available.
- Once you’ve taken control, you can’t get this specific dashboard back to update automatically. However, you can create a new default dashboard.
- To continue, in the dialog, select the three dots
menu, then select Take control.
- If this is your first time editing a dashboard, the Edit dashboard dialog appears.
- Add a card and customize actions and features to your dashboard.
Note that while editing the dashboard, the card will always be shown, so be sure to exit editing mode to test the conditions.
The conditional card can still be used. However, it is now possible to define a setting to show or hide a card conditionally directly on each card type, on its Visibility tab.
YAML configuration
The following YAML options are available when you use YAML mode or just prefer to use YAML in the code editor in the UI.
Configuration Variables
List of conditions to check. See available conditions.
Examples
Only show when all the conditions are met:
type: conditional
conditions:
- condition: state
entity: light.bed_light
state: "on"
- condition: state
entity: light.bed_light
state_not: "off"
- condition: user
users:
- 581fca7fdc014b8b894519cc531f9a04
card:
type: entities
entities:
- device_tracker.demo_paulus
- cover.kitchen_window
- light.kitchen_lights
- lock.kitchen_door
- light.bed_light
Example condition where only one of the conditions needs to be met:
type: conditional
conditions:
- condition: or
conditions:
- condition: state
entity: binary_sensor.co_alert
state: 'on'
- condition: state
entity: binary_sensor.rookmelder
state: 'on'
card:
type: entities
entities:
- binary_sensor.co_alert
- binary_sensor.rookmelder
Conditions options
You can use conditions about the person viewing the dashboard and their device, such as User, Screen, Location, and Time. You can also use the same conditions as in automations, such as Entity state, Entity numeric state, Template, Sun, Zone, and Device.
When you add or change an Entity state or Entity numeric state condition in the UI, it is saved in the same format as in automations, with entity_id instead of entity. The format described in this section keeps working.
State
Tests if an entity has a specified state.
condition: state
entity: climate.thermostat
state: heat
condition: state
entity: climate.thermostat
state_not: "off"
*one is required (state or state_not)
Numeric state
Tests if an entity state matches the thresholds.
condition: numeric_state
entity: sensor.outside_temperature
above: 10
below: 20
*at least one is required (above or below), both are also possible for values between.
Screen
Specify the visibility of the card per screen size. Some screen size presets are available in the UI but you can use any CSS media query you want in YAML.
condition: screen
media_query: "(min-width: 1280px)"
User
Specify the visibility of the card per user.
condition: user
users:
- 581fca7fdc014b8b894519cc531f9a04
Location
Specify the visibility of the card based on the current user’s location. The location is based on the person entity associated with the current user. If the current user does not have a person entity, this condition will always resolve to false.
Select zones directly, or by label, area, or floor. By default, the card is visible when the person is in any of the selected zones. This matches against the in_zones attribute of the person entity, which lists every zone the person is in, including passive zones and zones that contain a smaller zone. Set match_mode: active_zone to only match the zone shown as the person’s state instead. Some older device trackers don’t report the zones a person is in, other than Home. For those, both match modes compare the person’s state with the names of the selected zones. Set away: true to also show the card when the person is away (state not_home). Passive zones don’t change the person’s state, so a person who is only in passive zones is away.
In the dashboard editor, the Location condition has the following options.
How the zones are matched. Any zone they are in is true when the person is in any of the selected zones, including passive zones. Zone shown as their state is true only when one of the selected zones is shown as the person’s state, so passive zones never match. Default: Any zone they are in.
In YAML, these options are target, match_mode, and away.
condition: location
target:
label_id: grocery_stores
away: true
In this example, the card is shown when you’re in any zone with the grocery_stores label, or when you’re away.
Configuration Variables
The zones to match. You can select zones directly, or by label, area, or floor.
One or more label IDs. Every zone with one of these labels is matched.
How the zones are matched. any_zone is true when the person is in any of the zones, including passive zones. active_zone is true only when one of the zones is shown as the person’s state, which is the smallest non-passive zone they are in, so passive zones never match.
Also show the card when the person is away (state not_home), including when they are only in passive zones.
At least one of target, away: true, or locations must be used for this condition to be valid. target and away can be combined; the condition is true if either matches. locations can be combined with away, but not with target or match_mode.
Conditions using locations keep working. When you open one in the dashboard editor, the editor shows it as zones with Zone shown as their state selected, so it matches the same way as before. Each zone name is shown as every zone with that name, home as the Home zone, and not_home as Away. Names that match no zone are kept and shown as not found, so you can remove them.
Opening the condition does not change your configuration. It keeps using locations until you change something in it. When you do, it is saved as target with match_mode: active_zone.
Time
Specify the visibility of the card based on the current time and day of the week.
condition: time
after: "08:00"
before: "17:00"
weekdays:
- mon
- tue
- wed
- thu
- fri
At least one of after or before must be used for this condition to be valid. Both can be used together to define a time range as in the example above.
Template
Tests if a template renders true. This condition works the same way as the Template condition in automations and uses the same options.
Sun
Tests the position of the sun, for example, whether it is after sunset. This condition works the same way as the Sun condition in automations and uses the same options.
Zone
Tests if a person or device tracker is in a zone. This condition works the same way as the Zone condition in automations and uses the same options.
Device
Tests a condition that a device provides, for example, whether a light is on. This condition works the same way as the Device condition in automations. Set it up in the UI, because the options depend on the device.
And
Specify that all conditions must be met.
condition: and
conditions:
- condition: numeric_state
above: 0
- condition: user
users:
- 581fca7fdc014b8b894519cc531f9a04
Configuration Variables
List of conditions to check. See available conditions.
Or
Specify that at least one of the conditions must be met.
condition: or
conditions:
- condition: numeric_state
above: 0
- condition: user
users:
- 581fca7fdc014b8b894519cc531f9a04
Configuration Variables
List of conditions to check. See available conditions.
Not
Specify that at least one of the conditions must not be met.
condition: not
conditions:
- condition: numeric_state
above: 0
- condition: user
users:
- 581fca7fdc014b8b894519cc531f9a04
Configuration Variables
List of conditions to check. See available conditions.