Hi!
I’m getting lost in frustration here, hopefully I’m just missing out something really simple…
What I’m trying to achieve is having a time string defined as a datetime helper sorted out in hours and minutes separately.
Sensor config:
- platform: template
sensors:
pump_start_h:
value_template: '{{ strptime(states.input_datetime.pump_startat.state , "%M") }}'
pump_start_m:
value_template: '{{ strptime(states.input_datetime.pump_startat.state, "%M") }}'
pump_stop_h:
value_template: '{{ strptime(states.input_datetime.pump_stopat.state, "%H") }}'
pump_stop_m:
value_template: '{{ strptime(states.input_datetime.pump_stopat.state, "%M") }}'
What I found was that these template sensors were all set as the original date- and timestamps; i.e. 2020-01-01 07:00
. The same goes when I try pasting the templates in Templates Dev page.
I then tried entering this into the Templates dev page:
{{ strptime(now() , "%H:%M") }}
Still resulting in full string: 2021-04-28 11:21:00.001145+02:00
Can someone please point out what I’m missing here…?
Thanks!