Uptime card question

hello. this is code of my uptime card:
type: tile
entity: sensor.uptime
grid_options:
columns: 12
rows: 1
vertical: false
hide_state: false
show_entity_picture: false

Screenshot_20250119-183911
what is the easiest way to show me a standard uptime like 1 day 12 hours 30 min ?

does anyone have a solution?

Asked that question before, didn’t get a response either :frowning_face:

But I used this to create a template sensor that can be displayed instead - I’m sure I nicked it from somebody else, don’t know who:

 {% set lrm_uptime = as_timestamp(now()) - as_timestamp(states('sensor.uptime')) | int %}
{% set minutes = ((lrm_uptime % 3600) / 60) | int %}
{% set hours = ((lrm_uptime % 86400) / 3600) | int %}
{% set days = (lrm_uptime / 86400) | int %}
{%- if lrm_uptime < 60 -%}
  Less than a minute
{%- else -%}
  {%- if days > 0 -%}
    {%- if days == 1 -%}
      1 day
    {%- else -%}
      {{ days }} days
    {%- endif -%}
  {%- endif -%}
  {%- if hours > 0 -%}
    {%- if days > 0 -%}
      {{ ', ' }}
    {%- endif -%}
    {%- if hours == 1 -%}
      1 hour
    {%- else -%}
      {{ hours }} hours
    {%- endif -%}
  {%- endif -%}
  {%- if minutes > 0 -%}
    {%- if days > 0 or hours > 0 -%}
      {{ ', ' }}
    {%- endif -%}
    {%- if minutes == 1 -%}
      1 minute
    {%- else -%}
      {{ minutes }} minutes 
    {%- endif -%}
  {%- endif -%}
{%- endif -%}
1 Like

doesn’t seem like an “easy” solution

You didn’t ask for ‘easy’ - you asked for ‘easiest’ :stuck_out_tongue_winking_eye:

Either way, it works for me.