Is it possible to create 'tod platform' with 'input time'?

Hey,

I’m trying to define times for day and night, and I want to be able to change it from the interface. So i created 2 ‘helpers’ as input times, one for morning start time, and one for night start time (maybe i’ll add evening and more if it works).

I didn’t succeed to make it work from the TOD platform (binary sensor).

# Trying to create 'tod' with input datetime as 'after' and 'before'
# Not working (Configuration invalid)
- platform: tod
  name: Night Time
  after: "{{ states('input_datetime.night_start.state') }}"
  before: "{{ states('input_datetime.morning_start.state') }}"

so I tried to make it work like a regular template (without TOD), but it works only if night time is before 00:00 (23:59).

# Trying to create night time sensor as a template
# Configuration is valid, but getting wrong date if night time is after midnight
- platform: template
  sensors:
    day_time:
      value_template: "{{ states('input_datetime.night_start') [0:5] > states('sensor.time') > states('input_datetime.morning_start') [0:5] }}"    
      friendly_name: "Day Time"
      icon_template: mdi:white-balance-sunny

What is the correct way to do something like this?
Thanks.

Hello,
I have just answered for similar question in post:
https://community.home-assistant.io/t/input-time-as-a-condition/149417/15
I hope you will find it useful.