Pool Pump Automation

Dear HA community,

First of all, I am new to the topic of HA and the automations are also new to me.

I would like to create an automation that is started every evening at 7pm and starts my pool pump depending on the time it has already run. For this I have created a sensor that measures the time the pool pump has already run today. The goal is that the pool pump runs for a maximum of 3 hours per day. So if the pump has already been running for >= 3 hours at 7 pm, the automation should not start. However, if the time is < 3 hours, then the pump should only run for the difference between the sensor and 3 hours.

It’s certainly not easy, but maybe someone has an idea.

BR
Patrick

trigger:
  - platform: time
    at: "19:00:00"
condition:
  - condition: numeric_state
    entity_id: sensor.pool_pump_run_hours
    below: 3
action:
  - service: switch.turn_on
    target:
      - entity_id: switch.pool_pump
trigger:
  - platform: numeric_state
    entity_id: sensor.pool_pump_run_hours
    above: 3
condition:
  - condition: time
    after: "19:00:00"  # allows pool pump to run for longer than 3 hours during the day. 
action:
  - service: switch.turn_off
    target:
      - entity_id: switch.pool_pump

This are two different Automation?

Yes. One to turn it on at 7pm if required, and one to turn it off when the run time gets to 3 hours, but only if that is after 7pm.

Doing it with one automation is possible but more complicated.

trigger:
  - id: "pump_on_at_7_pm"
    platform: time
    at: "19:00:00"
  - id: "pump_off_after_7_pm"
    platform: numeric_state
    entity_id: sensor.pool_pump_run_hours
    above: 3
action:
  - choose:
      - conditions:
          - condition: trigger
            id: pump_on_at_7_pm
          - condition: numeric_state
            entity_id: sensor.pool_pump_run_hours
            below: 3
        sequence:
          - service: switch.turn_on
            target:
              - entity_id: switch.pool_pump
      - conditions:
          - condition: trigger
            id: pump_off_after_7_pm
          - condition: time
            after: "19:00:00"
        sequence:
          - service: switch.turn_off
            target:
              - entity_id: switch.pool_pump

I’m using a Shelly Plug S1 for my pool pump, which is quite simple for automation:

This Shelly is also working at HA in the energy dashboard:

In addition I can manually turn it on of off with my mobile or much simpler with Alexa.

A “standard” automation is also not the problem. However, I have a PV system (without battery) and a script runs here which starts the pool pump when there is a surplus. Now it can also happen in summer that it is cloudy. I therefore need to be able to check how long the pump has been running during the day in order to decide whether I need to switch it on in the evening or not.

This is now my automation. Thank you @Tim_I

alias: Pool Pump 3h
description: Check if Pool Pump runs for 3h
trigger:
  - id: pump_on_at_7_pm
    platform: time
    at: "19:00:00"
  - id: pump_off_after_7_pm
    platform: numeric_state
    entity_id: sensor.pool_pump_on
    above: 3
action:
  - choose:
      - conditions:
          - condition: trigger
            id: pump_on_at_7_pm
          - condition: numeric_state
            entity_id: sensor.pool_pump_on
            below: 3
        sequence:
          - type: turn_on
            device_id: d9066f6fe027fe43fe54cc81e34e1e14
            entity_id: switch.pool_up_pool_state
            domain: switch
          - service: automation.turn_off
            data:
              stop_actions: true
            target:
              entity_id: automation.pv_pool
      - conditions:
          - condition: trigger
            id: pump_off_after_7_pm
          - condition: time
            after: "19:00:00"
        sequence:
          - type: turn_off
            device_id: d9066f6fe027fe43fe54cc81e34e1e14
            entity_id: switch.pool_up_pool_state
            domain: switch
          - service: automation.turn_on
            data: {}
            target:
              entity_id: automation.pv_pool
mode: single

BR
Patrick

1 Like