Automation finishes before sun rising

Hi all, I am a new user with basic(or less) english knowledge and less prgaming expeience than english. I build a garden irrigation sytem with ESP and the optimal watering of the lawn is before sunrise.
Can you help me to do it? The basic is that the full cycle have to finish 10 minutes before sunrising.
Is it possible to do it in Home Assistant? Is there any alternative option?

you’d have to know how long the cycle takes. if It’s variable then that gets tough. but otherwise something like this if it runs for an hour.

trigger:
  - platform: sun
    event: sunrise
    offset: "-01:10:0"
action:
  - service: rainbird.start_irrigation
    data:
      entity_id: switch.rain_bird_sprinkler_1