Pool Pump Scheduler

This blueprint aims to simplify scheduling a simple pool setup with a pump (filter). You set the pool size (volume) and the pump’s flow rate and the automation takes care of controlling the pump for the optimal circulation turnovers. You can limit the hours of day the pump should work as well.
All you need is your pool setup specs and a switch to control the pump.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled. Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

blueprint:
  name: Pool Pump Scheduler
  description: Schedules pool pump based on its capacity and pool size. Just set your pools ize (volume), your pump flow rate and desired time limit the pump can rum daily. The automation will calculate the turnover rate and swithes on and off the pump as required.
  domain: automation
  input:
    pool_pump:
      name: Pool Pump
      description: A switch that controls the pool pump
      selector:
        entity:
          domain: switch

    pool_volume:
      name: Pool Volume
      description: The capacity of the pool. This will be used to calculate the turnover rate of your pool. Use the same bas unit for Pool Volume and Pump Flow Rate!
      selector:
        number:
          min: 1
          max: 100000
          unit_of_measurement: "gal/m3/l"
          mode: box
    
    pump_flow_rate:
      name: Pump Flow Rate
      description: The flow rat eof your pool pump. This will be used to calculate the turnover rate fo your pool. Use the same bas unit for Pool Volume and Pump Flow Rate!
      selector:
        number:
          min: .5
          max: 1000
          unit_of_measurement: "gph/m3ph/lph"
          step: .5
          mode: box

    maximum_run_time:
      name: Maximum Pump Run Time Per Day
      description: The deisred pump run time per day.
      selector:
        number:
          min: 0
          max: 24
          mode: slider
          unit_of_measurement: hours
      default: 8

    season_toggle:
      name: Pool Season toggle
      description: Adds ability to completely turn on-off the automation using a switch or boolean helper
      selector:
        entity:
          domain: 
            - input_boolean
            - switch
  

variables:
  var_pool_pump: !input pool_pump
  var_pool_volume: !input pool_volume
  var_pump_flow_rate: !input pump_flow_rate
  var_maximum_run_time: !input maximum_run_time
  var_turnover_rate: '{{ (var_pool_volume | float(1)) / (var_pump_flow_rate | float(1)) }}'
  var_turnover_per_day: '{{ 24 / var_turnover_rate }}'
  var_runs_per_day: '{{ ((var_maximum_run_time | int(1)) / var_turnover_rate) | round(0) }}'
  var_pump_state_changed_sice: '{{ (now().timestamp() - as_timestamp(states[var_pool_pump].last_changed)) / 3600 }}'
  var_max_off_time: '{{ (24 - var_maximum_run_time | int) / var_runs_per_day }}'

trigger:
  - platform: time_pattern
    minutes: /1
  # proper trigger after variables in trigger will be supported
  # - platform: template
  #   id: on_trigger
  #   value_template: >-
  #     {% if is_state(var_pool_pump, 'on') and (var_pump_state_changed_sice > var_turnover_rate) %}true{% endif %}
  # - platform: template
  #   id: off_trigger
  #   value_template: >-
  #     {% if is_state(var_pool_pump, 'off') and (var_pump_state_changed_sice > var_max_off_time) %}true{% endif %}
condition: []

action:
- choose:
  - conditions:
    - condition: state
      entity_id: !input pool_pump
      state: 'off'
    - condition: state
      entity_id: !input season_toggle
      state: 'on'
    - condition: template
      value_template: >-
        {{ var_pump_state_changed_sice > var_max_off_time }}
    # - condition: trigger
    #   id: on_pattern
    sequence:
    - service: switch.turn_on
      target:
        entity_id: !input pool_pump
  - conditions:
    # - condition: trigger
    #   id: off_pattern
    - condition: state
      entity_id: !input season_toggle
      state: 'off'
    - condition: state
      entity_id: !input pool_pump
      state: 'on'
    - condition: template
      value_template: >-
        {{ var_pump_state_changed_sice > var_turnover_rate }}
    sequence:
    - service: switch.turn_off
      target:
        entity_id: !input pool_pump
  - conditions:
    - condition: state
      entity_id: !input season_toggle
      state: 'off'
    sequence:
    - service: switch.turn_off
      target:
        entity_id: !input pool_pump
  default: []
mode: single
9 Likes

Hey man, I love this, saved me a ton of time. One question, request:

Some form of input_boolean blocker. I live in New England, so 9/12 months, pool is covered, I have a boolean for “Pool Season” that changes my lovelace for summer, I would like to also have this automation only run if “Pool Season” is “on”

4 Likes

@swingerman so I’ve imported this blueprint and selected my pool pump switch and entered in the additional details. I’m not quite clear on how this works. I currently have my pump switch turned on, which was on before I imported the blueprint, so will this blueprint turn my pump off and on under some schedule? One aspect that I want to have taken into consideration is when the electricity rates are high, so that I run the pump at off-peak times.

2 Likes

Hey @timnolte . It should turn on-off based on the volume of your pool and the flow rate of your pomp. I will try to add season on-off boolean

Updated the blueprint with season toggle support

1 Like

@swingerman what is the trigger for it to turn on? Does this just turn on the pump when you first enable the automation and then just run for however many hours to cycle your pool based on volume and then turn off for however much time remaining based on a 24 hour timeframe?

Hi, it’s a great job, but I’ll give you several ideas:

Covered or uncovered pool checkbox (times are shorter in the covered pools)

More switch controls, for example chlorine, pH pump… in my case chlorine is enough with 3 hours but I need 5 hours to filter the pool. If I leave it for 5 hours, the chlorine rises too much.

hello very good blueprint thank you

is it possible to add support for the temperature of the water in the filtration time?

1 Like

Could you please elaborate on what we should do with that data?

thank you!

would be nice to limit it to hours, so it could either be used in a cheaper tariff or if you have solar panels during the day…

3 Likes

I’m confused here my pool is 36,000 gallons, how would I need to enter that in this blueprint?

I updated the blueprint for you. Now you can enter a larger number.

1 Like

Hello Miklos, I’ll be trying your blueprint. I have a system that was Arduino and my code that ran 5 years. Now switching to HA era. What is you opinion on how much to put in one (related) automation?? Like:

  1. Circulator Filter pump run timing.
  2. Chlorine pump timing.
    –But should I add:??
  3. Pool solar heater pump with real-time assessment of heat gain decisions.

Or would it be better to have the solar heater in its own automation??

I;m just starting with HA. Have lots of code/electronics background. But I do not yet have HA Smarts :slight_smile:

Regards, Terry King
…In The Woods In Vermont and On The Nile in Egypt
The one who dies with the most Parts LOSES! WHAT DO YOU NEED??

Hello Terry, This blueprint is an easy solution. It may not fully satisfy everyone, though.
You can use the heater’s built-in thermostat in HomeAssistant as a starting point. It should work well. If you need a more sophisticated heating solution that optimizes itself, custom integrations are available in HACS (HomeAsssistant Custom Components). You should install HACS to access custom stuff people create to extend beyond built-in solutions.
There is a lot of pool-related stuff there regarding heating and chemical control.

Thanks for this!

EDIT: Doesn’t seem to work:

Logger: homeassistant.components.automation.pool_pump_scheduler
Source: components/automation/init.py:669
integration: Automation (documentation, issues)
First occurred: 3:04:00 AM (2 occurrences)
Last logged: 3:05:00 AM

Error rendering variables: ZeroDivisionError: division by zero

Hey,
Regarding the temperature data: the warmer the water, the longer the pump “should” run. But in my case as an example: I have 10m² solar absorber to which a temperature sensor is attached. In the skimmer of the pool I have a second temperature sensor. At the ball valve that regulates the flow between pump-pool and pump-solar I have attached a servomotor from a ventilation system for the control flaps (better than finished motorised ball valve there; no water contact possible so 230V suitable, better adjustable, 2 change switches for each open - closed (switch position separately adjustable), in case of defect easily interchangeable without having to open the pipeline because only plugged in and used costs about 40€.
I’m digressing… sorry
To control the ball valve you need at least one sensor that is in full sun but better also one in the pool so that you can control the valve via the difference and / or a heat pump. I hope my English was / has been understandable

For some reason I can’t get this to import correctly. It also looks like the pool size is not updated in the yaml file on GIthub.

I updated the gist.