Using an automation to update a "timestamp" field

I want to use an automation to capture the date/time a certain condition happens and display that date/time on a dashboard.

I got as far as creating an input_text helper entity in the GUI and creating an automation that stores {{ now() }} in the helper when the condition happens. But that entity is not treated as a timestamp, and I haven’t found a way to change that.

Maybe I’m going about this the wrong way. Any suggestions?

You can use an input_text to store the value of {{now()}} for purposes of later reading the input_text and treating the value like a timestamp.

But note that when you read a value from input_text and access it using a template, it is a string. If you want Jinja to understand it as a timestamp value, you have to filter it accordingly.

It’s not clear to me if you mean timestamp as the kind of string that now() gets turned into, like ‘2025-02-12 12:22:00.263509-10:00’, or timestamp in the UNIX sense as a float variable that counts seconds from an epoch. For the former, the as_datetime filter might be appropriate; for the latter, as_timestamp.

For more specific help, post some code so that the people on the forum know what you’re trying to do with the input_text value.

Note also, it might be more appropriate, depending on what you’re trying to do, to use the input_datetime helper.

@d921
Thanks, I think that’s just the hint I needed.
By timestamp I meant device_class timestamp.

If I understand correctly, I will create a template sensor with device_class timestamp that gets its state from the state of the input_text entity passed through the as_datetime filter. Then add this new sensor to my dashboard.

I was trying to display the input_text entity on the dashboard directly.