Date Created:
Date Last Modified:



Description:
This snippet uses two entities, a door lock and door sensor, and displays the status to the user. Using combination of icons, icon color and text, the user can determine if the door is open, closed and locked.
Code:
- type: custom:mushroom-template-card
primary: Basement Door
secondary: >-
{{ 'Closed and Locked' if
is_state_attr('binary_sensor.basement_door', 'raw_state_text',
'Closed') and is_state('lock.basement_door_lock', 'locked') else
'Open' if is_state_attr('binary_sensor.basement_door',
'raw_state_text', 'Opened') else 'Closed and Unlocked' if
is_state_attr('binary_sensor.basement_door', 'raw_state_text',
'Closed')}}
icon: >-
{{ 'mdi:door-closed-lock' if
is_state_attr('binary_sensor.basement_door', 'raw_state_text',
'Closed') and is_state('lock.basement_door_lock', 'locked') else
'mdi:door-open' if is_state_attr('binary_sensor.basement_door',
'raw_state_text', 'Opened') else 'mdi:door-closed' if
is_state_attr('binary_sensor.basement_door', 'raw_state_text',
'Closed')}}
icon_color: >-
{{ 'light-green' if is_state_attr('binary_sensor.basement_door',
'raw_state_text', 'Closed') and
is_state('lock.basement_door_lock', 'locked') else 'yellow' if
is_state_attr('binary_sensor.basement_door', 'raw_state_text',
'Closed') else 'red' is
is_state_attr('binary_sensor.basement_door', 'raw_state_text',
'Opened')}}
entity: binary_sensor.basement_door
hold_action:
action: more-info