Set input_datetime with automation

The trigger is a door opening.
I want this helper to be that time when it opens.
What should be the data?

image

"{{ now().timestamp()|timestamp_custom('%H:%M', true) }}"
1 Like

@tom_l
Is this also for date and time? And do I put this in data?

Thanks for your reply!

No you only asked for time.

You can adjust the format of timestamp_custom() to include the date in the format the input_datetime expects.

%Y-%m-%d %H:%M:%S

Actually, you can just use the timestamp for this:

"{{ now().timestamp() }}"

I assume so, but I don’t use the UI so I don’t really know what format it is expecting.

I tested this and another comment I found somewhere else.
It works in the UI.

This is the other I found:

datetime: β€˜{{ now().strftime(β€™β€˜%Y-%m-%d %H:%M:%Sβ€™β€˜) }}’

And @tom_l solution:

β€œ{{ now().timestamp() }}”

Thank you!

1 Like