Hi all,
i search for a Solution:
here my output:
sensor.fritzbox_connection_uptime => 2021-07-24T00:34:26+00:00
But I want to show the time: 1 Week, 2 Days, 3 Hours, 2 Second…
Thanks all
Hi all,
i search for a Solution:
here my output:
sensor.fritzbox_connection_uptime => 2021-07-24T00:34:26+00:00
But I want to show the time: 1 Week, 2 Days, 3 Hours, 2 Second…
Thanks all
here the Solution:
net_uptime_pretty:
friendly_name: Verbunden
value_template: >
{%- set up_time = as_timestamp(now())-as_timestamp(states('sensor.fritzbox_connection_uptime')) %}
{% if states('sensor.last_boot') == '0.0' %}
Soeben neu gestartet...
{% else %}
{%- macro phrase(name, divisor, mod=None) %}
{%- set value = ((up_time // divisor) % (mod if mod else divisor)) | int %}
{{- '{} {}'.format(value, name) if value | int > 0 else '' }}
{%- endmacro %}
{%- set values = [
phrase('W.', 60*60*24*7),
phrase('T.', 60*60*24, 7),
phrase('Std.', 60*60, 24),
phrase('Min.', 60),
phrase('Sek.', 1, 60)
] | select('!=','') | list %}
{{ values[:-1] | join(', ') ~ ' ' ~ values[-1] if values | length > 1 else values | first }}
{% endif %}
How do I use this code to display the value in my dashboard?
This is the code for a template sensor. You can create your own with it, see link. Alternatively, you can copy everything after value_template: >
in a markdown card.
Check my Home Assistant config:
All right, thank you very much!
I wasn’t that wrong, I just had an error in my template sensor.
Do u have the code to change the vacuum card to gardena mower?
What kind of sensor is: sensor.last_boot?