docker-apps/home-assistant/Mushroom badge-chop cards.yml

65 lines
2.7 KiB
YAML

# Template badge (can't get animation to work)
# ==============
type: custom:mushroom-template-badge
entity: binary_sensor.motion_detected
content: >
{{ states['binary_sensor.motion_detected'].state | title }} · {{
states['binary_sensor.motion_detected'].last_changed | relative_time }}
icon: "{{ state_attr(\"binary_sensor.motion_detected\", \"icon\") }}"
color: >-
{% set lc = (as_timestamp(now()) -
as_timestamp(states[entity].last_changed))|int %} {{ "#ff0000" if lc < 10 }}
{{ "#4d061c" if lc >= 10 and lc < 20 }} {{ "#d2042d" if lc >= 20 and lc < 45
}} {{ "#fA8072" if lc >= 45 and lc < 90 }} {{ "#ff8c00" if lc >= 90 and lc <
180 }} {{ "#ffa500" if lc >= 180 and lc < 400 }} {{ "#fff700" if lc >= 400 and
lc < 830 }} {{ "#ffff00" if lc >= 830 and lc < 1725 }} {{ "#008000" if lc >=
1725 and lc < 3600 }} {{ "#4682B4" if lc >= 3600 and lc < 21600 }}
label: "{{ states[entity].name }}"
# Chip cards (can't add label)
# ==========
type: custom:mushroom-chips-card
alignment: justify
chips:
- type: template
entity: binary_sensor.alarm_triggered
icon: "{{ state_attr(\"binary_sensor.alarm_triggered\", \"icon\") }}"
icon_color: |
{% if is_state('binary_sensor.alarm_triggered', 'on') %}
red
{% else %}
#4682B4
{% endif %}
content: Alarm
tap_action:
action: navigate
navigation_path: /dashboard-sthome/alarm
- type: template
entity: binary_sensor.motion_detected
icon: "{{ state_attr(\"binary_sensor.motion_detected\", \"icon\") }}"
icon_color: >-
{% set lc = (as_timestamp(now()) -
as_timestamp(states.binary_sensor.motion_detected.last_changed))|int %} {{
"#ff0000" if lc < 10 }} {{ "#4d061c" if lc >= 10 and lc < 20 }} {{
"#d2042d" if lc >= 20 and lc < 45 }} {{ "#fA8072" if lc >= 45 and lc < 90
}} {{ "#ff8c00" if lc >= 90 and lc < 180 }} {{ "#ffa500" if lc >= 180 and
lc < 400 }} {{ "#fff700" if lc >= 400 and lc < 830 }} {{ "#ffff00" if lc
>= 830 and lc < 1725 }} {{ "#008000" if lc >= 1725 and lc < 3600 }} {{
"#4682B4" if lc >= 3600 and lc < 21600 }}
content: >-
{% set motion = is_state('binary_sensor.motion_detected', 'on') %}
{% set elapsed_time = states['binary_sensor.motion_detected'].last_changed | relative_time %}
{{ 'Started' if motion else 'Stopped' }} · {{ elapsed_time }} ago
tap_action:
action: navigate
navigation_path: /dashboard-sthome/alarm
card_mod:
style:
mushroom-template-chip:nth-child(2)$: |
ha-state-icon {
{{ 'animation: clip 2s linear infinite;' if is_state('binary_sensor.motion_detected', 'on') }}
}
@keyframes clip {
50% { clip-path: polygon(0 0, 61% 0, 66% 100%, 0% 100%); }
}