Hourly on/off if device is off

Hi,

My well pump is set to work on specific schedules, but I want to add an hourly turn-on, then runs for 20 seconds and turns off every hour. BUT only when the specific schedules are not running, in other words, when it is off.
I got to the code below, but I don’t know to add a wait for 20 seconds between on and off.
Any input?
Thank you guys!

- id: 'well_hourly'
  alias: Well hourly
  description: ''
  trigger:
  - platform: time_pattern
    hours: '1'
  condition:
  - condition: device
    type: is_off
    entity_id: switch.well
  action:
  - type: turn_on
    entity_id: switch.well
  - type: turn_off
    entity_id: switch.well

I think you are looking for this:

  action:
  - type: turn_on
    entity_id: switch.well
  - delay: "00:00:20"
  - type: turn_off
    entity_id: switch.well

Hope this helps.

Thanks @TinyDoT.
I managed to get an error free automation (see below), but it is not running every hour. actually only runs if I order it to do so. Any suggestion?

- id: "WellHourly"
  alias: Well on every hour
  trigger:
  - platform: time_pattern
    hours: '1'
  condition:
  - condition: state
    state: "off"
    entity_id: switch.well
    for:
      minutes: 30
  action:
  - service: switch.turn_on
    entity_id: switch.well
  - delay: "00:00:20"
  - service: switch.turn_off
    entity_id: switch.well

Your time pattern runs on the “1” hour, meaning 01:00 then waits until the next day.
To get every hour the pattern must be "/1"

Yeah what @Hellis81 said.

Thank you to both of you!