Time templates - how to display human-readable timestamp?

Hi, I have a 3D printer ETA that I want to display as a part of a markdown panel.

Problem is, the markdown panel displays it like this:

How can I get a human-readable timestamp? Simple Hours:Minutes?

I have this in the markdown panel:
ETA is approx. {{states ('sensor.klipper_print_eta') }} remaining

How can I get the short form? Thanks!

EDIT: I have rewritten the post, I want a human-readable “it will be done at Hours:Minutes” time, not “in XX minutes”. Sorry for the confusion.

Many many simialr requests, there are various solutions and one that is not widely known
Have a look here, initial setup is a bit iffy but then it is very nice (imo)
Easy Time Macros for Templates! - Share your Projects! - Home Assistant Community (home-assistant.io)

1 Like

It was working as I wanted it to up to sometime last year, there had to be some sort of breaking change.

For as far as I can see, your eta sensor is a timestamp in the future. It’s unlikely that it will give the time left. So I guess you have to calculate it. I don’t have an ETA sensor, but I guess something like this should work:

   int( (states('sensor.klipper_print_eta') - now()).seconds / 60 )

I assume your sensor value is an actual datetime value and not a string.

It you add the class timestamp then it will behave the same in SOME cards, probably not in markdown. Use the macro as an idea

It does give time left, see the second screenshot. Those two are the same sensor in two different contexts. Your code gives me "TypeError: unsupported operand type(s) for -: 'str' and 'datetime.datetime'"

I’m sorry, I have confused everyone. What I want in the markdown card is the time (o’clock), not time remaining. I’ll reword the OP.

No… there’s no breaking change here. You’re looking at the under the hood state, which has always been a timestamp. It’s because you’re outputting the value from a template and HA doesn’t know how to format it. Been like this from day 1. You have to make it friendly using a template. Hence why I made the easy time library.

So there was probably a change in the sensor itself (Klipper 3D printer integration). The markdown panel was originally displaying a human readable time and I have not made any changes to it. Thanks for clarification.

thanks but for a non-programmer, this is impenetrable

Agree it is a bit more then jinja template…but not much. As with many areas where you want to make it ‘yours’ you’d have to use a bit more techy stuff. Actually, easy_time macro’s reduce a lot of complexity.
Anyhow, my 2cts …good luck :slight_smile: