ESPHome Between 2 time settings

I have A switch that I only want to be on or off between 10PM and 8AM.

I first let the switch go off at a certain time but then suddenly the switch is on again. I think maybe ESPhome is rebooting sometimes and is then passed the offtime so he will switch on agian. So I tought if the time settings is between 2 times then when esphome reboots this will fix the problem. But cant figure it out
This is what I have so far. I’m a newbie with esphome so every help is appriciated

  - platform: sntp
    id: sntptime
        seconds: 0
        minutes: 45
        hours: 21
        seconds: 0
        minutes: 00
        hours: 08
            - if:
                  - id(sntptim) = > on_time && < off_time;
                  - switch.turn_ff: outside_leds