Loading...
Loading...
Implements conditional visibility for Home Assistant dashboard cards using state, numeric_state, screen, user, time, and/or conditions via Conditional Card wrapper and per-card visibility property. Use when asked to "hide card when", "show only if", "user-specific dashboard", "mobile vs desktop cards", "conditional visibility", or "show card based on state/time/user".
npx skill4agent add dawiddutoit/custom-claude ha-conditional-cardsvisibilitytype: conditional
conditions:
- condition: state
entity: person.john
state: home
card:
type: entities
entities:
- light.bedroomtype: entities
entities:
- light.bedroom
visibility:
- condition: state
entity: person.john
state: homeconditionsvisibility| Condition | Parameters | Use Case |
|---|---|---|
| | Show when entity has specific state |
| | Show when sensor in range |
| | Show based on screen width |
| | Show for specific users only |
| | Show during specific time window |
| List of conditions | All conditions must be true |
| List of conditions | At least one condition must be true |
type: conditional
conditions:
- condition: state
entity: binary_sensor.motion_living_room
state: "on"
card:
type: camera
entity: camera.living_roomvisibility:
- condition: state
entity: climate.living_room
state_not:
- "off"
- unavailable# In configuration.yaml
template:
- sensor:
- name: "AC Mode Cool"
state: "{{ state_attr('climate.living_room', 'hvac_mode') == 'cool' }}"
# In dashboard
visibility:
- condition: state
entity: sensor.ac_mode_cool
state: "True"type: entities
entities:
- climate.bedroom
visibility:
- condition: numeric_state
entity: sensor.temperature
above: 18
below: 30visibility:
- condition: numeric_state
entity: sensor.battery
below: 20 # Show when battery < 20%visibility:
- condition: numeric_state
entity: sensor.humidity
above: 40
below: 60 # Show when 40% < humidity < 60%visibility:
- condition: screen
media_query: "(max-width: 600px)"visibility:
- condition: screen
media_query: "(min-width: 1280px)"visibility:
- condition: screen
media_query: "(min-width: 601px) and (max-width: 1279px)"# Mobile (portrait)
media_query: "(max-width: 600px)"
# Tablet (portrait)
media_query: "(min-width: 601px) and (max-width: 900px)"
# Desktop
media_query: "(min-width: 1280px)"
# Landscape orientation
media_query: "(orientation: landscape)"
# Portrait orientation
media_query: "(orientation: portrait)"visibility:
- condition: user
users:
- 1234567890abcdef # User ID (not username)type: entities
entities:
- switch.advanced_settings
visibility:
- condition: user
users:
- 1234567890abcdef # Admin user 1
- fedcba0987654321 # Admin user 2/config/person/USER_ID_HEREvisibility:
- condition: time
after: "06:00:00"
before: "22:00:00"visibility:
- condition: time
after: "22:00:00"
before: "06:00:00"visibility:
- condition: time
after: "09:00:00"
before: "17:00:00"
weekday:
- mon
- tue
- wed
- thu
- frivisibility:
- condition: and
conditions:
- condition: state
entity: person.john
state: home
- condition: numeric_state
entity: sensor.temperature
below: 18
- condition: time
after: "06:00:00"
before: "23:00:00"visibility:
- condition: or
conditions:
- condition: state
entity: person.john
state: home
- condition: state
entity: person.jane
state: homevisibility:
- condition: and
conditions:
# Show during daytime...
- condition: time
after: "06:00:00"
before: "22:00:00"
# ...AND (someone is home OR security is armed)
- condition: or
conditions:
- condition: state
entity: person.john
state: home
- condition: state
entity: alarm_control_panel.home
state: armed_awaytype: conditional
conditions:
- condition: state
entity: binary_sensor.motion_living_room
state: "on"
card:
type: camera
entity: camera.living_room# Mobile: Compact view
type: custom:mushroom-chips-card
visibility:
- condition: screen
media_query: "(max-width: 600px)"
# Desktop: Detailed view
type: grid
columns: 3
visibility:
- condition: screen
media_query: "(min-width: 1280px)"type: entities
entities:
- switch.developer_mode
visibility:
- condition: user
users:
- 1234567890abcdef # Admin user ID (Settings → People → URL)references/advanced-patterns.mdreferences/advanced-patterns.md| Issue | Solution |
|---|---|
| Card not hiding | Exit edit mode, check entity state, verify YAML indentation |
| User condition fails | Use user ID (not username), find in Settings → People → URL |
| Time condition fails | Use 24-hour format |
| Numeric condition fails | Verify sensor has numeric state (not "unknown") |
| Screen condition fails | Test on actual device (not browser resize) |
references/advanced-patterns.md