Reply to my own challenge earlier.
So situation is that this binary_sensor fails (it is off after a HA restart right after midnight)
- platform: tod
name: Darkness
after: sunset
before: sunrise
Unless the sun integration is also been affected by the same bug as TOD (Time Of Day) this may work
You create a template binary sensor like this
- name: "Darkness"
unique_id: darkness_template_sensor
state: >
{{ is_state('sun.sun', 'below_horizon') }}
I need to verify tonight if this gets the correct value a few minutes past midnight after a HA restart. If so this is a simple work around.
Edit. I verified that the Sun based sensor works fine and not affected by the TOD bug so my Darkness sensor above works