Convert time only to timestamp

I have a template that outputs time as 06:11. I would like to convert it to timestamp so I can use it as a trigger.
TIA

Post the template.

Do you intend to use it in a Template Trigger ?

Sorry, I should have been more elaborate. I want to use it as Time Trigger

In that case, you will need to create a Template Sensor that reports a datetime string in ISO 8601 format and has a device_class set to timestamp. That’s what a Time Trigger expects if you want to use it with a sensor entity.

Reference

Time Trigger - Sensors

If you want my help, I need to see the template you created.

I am making an API call and using this template to extract the time.
{{ state_attr('sensor.prayer_times', 'data' )['timings']['Fajr'] }}

And output of the template is just a string like 06:01 . And I would like to change to a timestamp.

I recommend you use a Template Trigger in your automation. It’s as simple as this:

alias: example
trigger:
  - platform: template
    value_template: >
      {{ now().strftime('%H:%M') == state_attr('sensor.prayer_times', 'data' )['timings']['Fajr'] }}
condition: []
action:
  ... your actions go here ...

This should work fine. Thank you so much for pointing me in the right direction :slight_smile:

1 Like