Hello there,
I’m using strptime to report on the last_changed time of an entity. I’m getting a lot of these entries in my log (manually formatted for your viewing pleasure):
2022-03-01 17:54:22 WARNING (MainThread) [homeassistant.helpers.template]
Template warning: 'strptime' got invalid input '2022-03-01 05:22:51.684293+00:00' when rendering template
'{% set value = states.binary_sensor.kitchen_motion_motion.last_changed %}
{% set last_updated = as_timestamp(strptime(value, "%Y-%m-%d %H:%M:%S.%f%z")) %}
{% set seconds = (now().timestamp() - last_updated) | round(0) %}
{{ seconds }}'
but no default was specified.
Currently 'strptime' will return '2022-03-01 05:22:51.684293+00:00', however
this template will fail to render in Home Assistant core 2022.1
There are many similar entries.
This seems like a mismatch between the date (in this case 2022-03-01 05:22:51.684293+00:00
and the strptime format ("%Y-%m-%d %H:%M:%S.%f%z"
) but I just can’t spot where the problem is.
In fact, running this in python by importing datetime and using datetime.datetime.strptime() with this exact date string and format works perfectly.
Any ideas?