Time formatting template help

I am currently scraping a time from a website into a sensor. The data being scraped is just a bunch of numbers, e.g. 610 which should be 06:10.
I know I need a template to get his converted to the correct format. I’ve tried to add the 0 manually before the sensor which works but it’s still not type cast as time. Can anyone offer some advise as to what I can do?
I’ve tried using strptime but not getting too far so below is just my very simple attempt to add a padded 0.



{% set webtime = "610" %}
{{ strptime(webtime, "%H%M").time() }}

Note that you need to add a sensible default to strptime, but you need to determine that. Check the templating docs for more info.

1 Like

That is brilliant. Really appreciate the help mate.

1 Like