I have been pulling my hair out trying to do some time string manipulation without much luck. I have a template sensor which represents a time, and I want to make another sensor based off that. Here is how things look:
The reason I am using a state in strptime ( and not now() ) is because my phone passes the alarm time to homeassistant (from tasker) and I want to create a new time from this alarm eg. alarmtime - 30min.
My alarm gets passed in either of these formats: Mon 6:30 am OR 9-6-17 06.30 but I cant pass them to strptime without getting the TypeError above. All works well when using now().
I will have to look for some other ways to do this, happy to hear suggestions!
I too was struggling with this same issue, I wanted to create an alarm clock that would start a sequence 15 minutes before the alarm went off. I ended up having to convert the alarm time to a datetime object, convert to epoch, do the subtraction in seconds and then convert it back, this is what I ended up with this which appears to work in my tests so far (in the dev console):