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

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

Managed to do this

time:
  - platform: sntp
    id: sntp_time
    timezone: "Europe/Amsterdam"
    on_time_sync:
      then:
        - logger.log: "Synchronized sntp clock"
        - text_sensor.template.publish:
            id: sntp_text_sync
            state: "Sync SNTP clock"
    on_time:
    - seconds: 0
      minutes: /1
      then:
        - lambda: |-
            int t_now = parse_number<int>(id(sntp_time).now().strftime("%H%M")).value();
            if ((t_now >= 2200) || ( (t_now <= 700) ) ){
              id(outside_leds).publish_state(false);
            } else {
              id(outside_leds).publish_state(true);
            }