What's the correct way to pass a input_datetime time only helper value into a jinja macro?

OK. I’ve tried everything I could think of and Chat GPT gave me a bunch of fake answers.

What is the correct way to pass the state of a time only input_datetime helper to a jinja macro?

I’m looking to do something like:

{% macro Test(time) %}
{% do stuff %}
{%endmacro%}

{{Test( states('input_datetime.light_debug_time_now'))}}

I’ve tried strptime(), timestamp() and a bunch of other things but keep getting various errors (I’m pretty sure it’s related to the value being a string, but can’t seem to format it correctly)

Thanks in advance.

To get the State of an entity, use the states() function. For a time-only datetime helper states() will return a time string in “HH:MM:SS” format.

Building Templates - States

Your “code” isn’t very helpful since we can’t tell what you expect Test to actually take in or do with what it takes in. (As far as I’m concerned, it probably does stuff, so what’s wrong?)

Show us the state of the helper and then give us an idea of what Test is actually going to do. The latter is important at least since you say you’re only working with a time and not a date.

My apologies, did not add states() in my hastily typed example, did I. I’ve corrected my example.

I was looking for the correct way to convert the string from states() to a usable date time. I believe today_at() will work as it simply adds todays date to the time string.

Yes, today_at() will convert a time string into a datetime object with today’s date.

The state of a time only helper is only a string containing time so jinja doesn’t know what to do with it apparently (it wants a whole datetime object). I needed a way to easily make it useful to jinja so I can use the time set in the frontend within various macros. I’ll need to do some testing, but it seems today_at() works to convert the time string to an actual datetime so jinja use it.

It seems silly to convert it to a datetime in the call just to parse the hrs/ mins back out in the macro, but it gives me errors if I don’t.

I appreciate it