docker-apps/home-assistant/mushroom chips card - animated.yml

22 lines
1.3 KiB
YAML

type: custom:mushroom-chips-card
alignment: justify
chips:
- 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: >
{{ states['binary_sensor.motion_detected'].state | title }} · {{ states['binary_sensor.motion_detected'].last_changed | relative_time }}
label: "{{states['binary_sensor.motion_detected'].name}}"
tap_action:
action: more-info
card_mod:
style:
mushroom-template-chip:nth-child(1)$: |
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%); }
}