Running commands on_boot after deep sleep - access to time?

Hi! I have a water pump that I want to run at night any time between 20 and 23. My device is ESP8266 based and it does not seem to be able to deep sleep longer than 2 hours so I want to be able to let it wake up, set time and then start watering if the current hour is > 20 (or else go back to deep sleep).

I tried the following on_boot script but it seems like it can never access the current time correctly and thus the pump condition will never be true.

How can I make sure the condition has access to a correctly set time object when evaluating the condition? I tried to make sure the api is connected first but it does not seem to help.

/Peter

esphome:
  name: greenhouseesp
  friendly_name: GreenhouseESP
  on_boot:
    priority: -100.0
    then:
      - wait_until:
          condition: 
            api.connected:
          timeout: 30s
      - logger.log: "API connected"
      - if:
          condition:
            and:
              - time.has_time
              - lambda: |-
                  return id(homeassistant_time).now().hour > 20;
          then:
            - logger.log: "It is night. Watering."
            - switch.turn_on: ghpump1
            - delay: 40s 
            - switch.turn_off: ghpump1 
            - deep_sleep.enter: deep_sleep_1
          else:
            - logger.log: "It is day. No watering."              
  on_shutdown:
    then:
      - logger.log: "In shutdown..."
      - switch.turn_off: ghpump1
esp8266:
  board: esp01_1m

time:
  - platform: homeassistant
    id: homeassistant_time

deep_sleep:
  id: deep_sleep_1
  run_duration: 50s
  sleep_duration: 2h

I have issues with time updates as well - the first update can take a while. So much so that my display will show 00:00UTC for the first few secs after boot.

You could do a test to see how long it takes with some lambda and an on_time_synch: to calculate how long you wait. Simpler may be to move your watering time check to an on_time_synch: block.

From @zoogara 's answer I tried delaying 10 secs immediately in on_boot like this:

  on_boot:
    priority: -100.0
    then:
      - delay: 10s
      - ...

And that seems to work! Maybe it gives ESPHome some time to set up time synchronization? Thx!