See here for a solution:
Though I’d do it like this:
value_template: "{{ states('sensor.time') == states('input_datetime.switch_off')[0:5] }}"
Also, have you seen this?