Im trying to take the time from from my calander that looks like start_time: 2017-11-25 22:00:00 and make that a readable format for tts and other automations. I would like it read 12 hour format just hour and min i dont care about the date.
Ive tried a few things that I found around here but nothing seems to work. Can someone point me in the right direction?
This sensor grabs the start time in the format I mentioned above:
cal_start_time:
value_template: ‘{{ states.calendar.dustin_arbogast.attributes.start_time }}’
friendly_name: ‘Next Meeting Start Time’
Couple examples of what I have tried…
{{ states.calendar.dustin_arbogast.attributes.start_time.strptime("%H:%M") }}
I’m having the same issue but I’m using the snippet you’ve provided and I get an error message of: Error loading /config/configuration.yaml: while scanning a plain scalar in "/config/sensors.yaml", line 15, column 24 found unexpected ':' in "/config/sensors.yaml", line 15, column 82 Please check http://pyyaml.org/wiki/YAMLColonInFlowContext for details.
I’m guessing you don’t have sensor.time implemented because sensor.time outputs in %H:%M format as is.
Here’s the component that makes sensor.time. You shouldn’t even need your template. I probably should have said that before but I wasn’t thinking straight.
did you copy and paste the template I provided? Post your yaml.
This really isn’t hard. Fundimentally, there has to be something you are doing wrong. Looking at what you are trying to do, all you really need is this code to get the time.