Hi,
I like to add a last changed to a custom:mushroom-template card.
It’s for a simple open/closed sensor.
I did found a one-liner that will include the absolute time of the last change.
{{ as_timestamp(states.binary_sensor.front_door.last_changed,
default=0)|timestamp_custom('%d.%m.%Y %H:%M', default=0) }}
But I’m looking for “x minutes/hours ago”.
As far as I know I need to use this template card the make the battery badge icon work.
If I use a entity-card the badge will not show up.
Here a image what I have now:
Hope someone can help me with this.
Bug thanks in advance.
The full code:
type: custom:mushroom-template-card
entity: binary_sensor.sliding_door
primary: Sliding door
secondary: >-
{{ as_timestamp(states.binary_sensor.front_door.last_changed,
default=0)|timestamp_custom('%d.%m.%Y %H:%M', default=0) }}
icon: |-
{% if is_state("binary_sensor.sliding_door", "on") %}
mdi:door-open
{% elif is_state('binary_sensor.sliding_door', 'off') %}
mdi:door-closed
{% endif %}
badge_icon: |-
{% if is_state('sensor.contact_sensor_battery_state', 'high') %}
mdi:battery
{% elif is_state('sensor.contact_sensor_battery_state', 'medium') %}
mdi:battery-50
{% elif is_state('sensor.contact_sensor_battery_state', 'low') %}
mdi:battery-10
{% endif %}
badge_color: |-
{% if is_state('sensor.contact_sensor_battery_state', 'high') %}
green
{% elif is_state('sensor.contact_sensor_battery_state', 'medium') %}
orange
{% elif is_state('sensor.contact_sensor_battery_state', 'low') %}
red
{% endif %}
tap_action:
action: more-info
hold_action:
action: none
double_tap_action:
action: none
icon_color: |-
{% if is_state('binary_sensor.sliding_door', 'on') %}
blue
{% endif %}