Created
January 13, 2019 13:42
-
-
Save blakadder/7263d4504a2404c08035ce9f8566e829 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
value_template: > | |
{% set time = states('sensor.nasbox_uptime')|int %} | |
{% set minutes = ((time % 3600) / 60) | int %} | |
{% set hours = ((time % 86400) / 3600) | int %} | |
{% set days = (time / 86400) | int %} | |
{%- if time < 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 -%} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment