Closed Stooovie closed 2 years ago
Well templating is the only real way to make that happen, but luckily it's quite easy with Home Assistant's Jinja2 templates, something like the following should work. You could also use Jinja to format the time however you want.
# ...
secondary_info: {{ relative_time(as_datetime(states("sensor.home_assistant_uptime"))) }}
Thank you, it works. What threw me off was that I had to convert he sensor state to datetime first before getting the relative time.
Awesome, yeah I forgot that as well, was confused for a hot second 😁
Hi, Im using Canary to get a last-completed date/time of a different entity.
It works properly:
2021-11-05T10:07:40
but I'm unable to format it into a nice relative time (either "11.5. 10:07" or "xx days/hours ago"). The sensor entity is "sensor.xiaomi_vacuum_cleaner_last_clean_end".
I have asked on HA forums but to no avail. I'm not a programmer and templating is just inscrutable for me. Thanks!