Circulation pump on 5 minutes and off for 30 minutes

Hi guys,

i a newbie and i need your help for a automation for my circulation pump. the pump must be on for 5 minutes and then off for 30 minutes, the conditions are we are at home and the time 05:45 - 22:45

alias: Zirkulationspumpe
description: Tag-/Nachtumschaltung/Anwesenheit
trigger:
  - platform: time_pattern
    minutes: "30"
condition:
  - condition: time
    after: "05:45:00"
    before: "22:45:00"
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
      - sun
  - condition: state
    entity_id: group.anwesenheit
    state: home
action:
  - service: switch.turn_on
    data: {}
    target:
      entity_id: switch.zirkulationspumpe
mode: single

thank you and best regards.

alias: Zirkulationspumpe
description: Tag-/Nachtumschaltung/Anwesenheit
trigger:
  - platform: time_pattern
    minutes: "/30"
condition:
  - condition: time
    after: "05:45:00"
    before: "22:45:00"
  - condition: state
    entity_id: group.anwesenheit
    state: home
action:
  - service: switch.turn_on
    target:
      entity_id: switch.zirkulationspumpe
  - delay:
      minutes: 5
  - service: switch.turn_off
    target:
      entity_id: switch.zirkulationspumpe
mode: single

be aware that it will not turn off if you restart HA during the 5 minute delay.

there are ways to protect against that if that’s a concern.

thank you :slight_smile:

Whtat do you recommend for the restart problem?

thank you i will test it in the nex days.

is that right?

alias: Asymmetric Timer Cycle
description: ""
trigger:
  - platform: event
    id: timer
    event_type: timer.finished
    event_data:
      entity_id: timer.pump
  - platform: time
    at:
      - "05:45:00"
      - "22:45:00"
condition:
  - condition: state
    entity_id: group.anwesenheit
    state: home
action:
  - variables:
      on_time: "00:05:00"
      off_time: "00:30:00"
      next_interval: >-
        {{ iif( is_state('switch.zirkulationspumpe', 'off'), on_time, off_time)
        }}
  - choose:
      - conditions:
          - condition: trigger
            id: timer
        sequence:
          - service: switch.toggle
            data: {}
            target:
              entity_id: switch.zirkulationspumpe
          - service: timer.start
            data:
              duration: "{{ next_interval }}"
            target:
              entity_id: timer.pump
      - conditions:
          - condition: time
            before: "05:46:00"
        sequence:
          - service: switch.turn_on
            data: {}
            target:
              entity_id: switch.zirkulationspumpe
          - service: timer.start
            data:
              duration: "{{ on_time }}"
            target:
              entity_id: timer.pump
    default:
      - service: switch.turn_off
        data: {}
        target:
          entity_id: switch.zirkulationspumpe
      - service: timer.cancel
        target:
          entity_id: timer.pump
        data: {}
mode: single