Pool pump Timer please save me arrrrrrr

Hey guys I am trying to write a simple pool automation timer to turn my pump on at a certain time at night and run for 8 hours no matter what i try it just will not trigger the pump please help.

sensor below / Time

- platform: worldclock
  name: Time Brisbane
  time_zone: Australia/Brisbane

automation below

- alias: 'Pool Pump Schedule'
  trigger:
    platform: worldclock
    entity_id: sensor.time_brisbane
    at: '14:38:00'
  action:
    - service: switch.turn_on
      entity_id: switch.pool_pump
    - delay: '08:00:00'
    - service: switch.turn_off
      entity_id: switch.pool_pump

switch below

- platform: mqtt
  name: "Pool Pump"
  state_topic: "stat/PoolPump/POWER"
  command_topic: "cmnd/PoolPump/POWER"
  qos: 0
  payload_on: "ON"
  payload_off: "OFF"
  optimistic: false
  retain: true
action:
  - service: homeassistant.turn_on
      data: 
         entity_id: switch.pool_pump
  - delay: ‘08:00:00’
  - service: homeassistant.turn_off
      data:
        entity_id: switch.pool_pump

thanks I tried that but got errors think your spacing was wrong so i changed it seems ok as per below

> - alias: 'Pool Pump Schedule'
>   trigger:
>     platform: worldclock.time_brisbane
>     at: '16:32:00'
>     action:
>       - service: homeassistant.turn_on
>         data: 
>           entity_id: switch.pool_pump
>       - delay: ‘08:00:00’
>       - service: homeassistant.turn_off
>         data:
>           entity_id: switch.pool_pump

but I see in error log my world clock is not correct.

Invalid config for [automation]: platform worldclock.time_brisbane does not exist for automation for dictionary value @ data[‘trigger’][0][‘platform’]. Got None

and

2017-09-12 16:37:24 ERROR (MainThread) [homeassistant.loader] Unable to find component automation.sensor.time_brisbane

Ive had to use world clock because using the ( time ) version gives me incorrect time for my region and had to use this config below for my time sensor.

platform: worldclock
name: Time Brisbane
time_zone: Australia/Brisbane

its entitie id shows as

sensor.time.brisbane

but i did try it as the platform and no triggering

also have tried it like this but still no trigger must be something to do with the world clock omg.

- alias: 'Pool Pump Schedule'
  trigger:
    platform: time
    at: '16:53:00'
  action:
    - service: homeassistant.turn_on
      entity_id: switch.pool_pump
    - delay: '08:00:00'
    - service: homeassistant.turn_off
      entity_id: switch.pool_pump

I believe time is correct platform.

I would create a switch in frontend to test “action”
After confirm “action” OK, I would change back to time trigger.

I presume switch turn ON/OFF through some other HA resource?

Also, if you display this automation in the frontend you may manually trigger.

I am currently using these light automation and they work perfectly

- alias: Turn on Theater Room Light when there is movement
  trigger:
    platform: state
    entity_id: binary_sensor.theater_pir
    to: 'on'
  action:
    service: homeassistant.turn_on
    entity_id: light.theater_room_light

- alias: Turn off kitchen light 10 minutes after last movement
  trigger:
    platform: state
    entity_id: binary_sensor.theater_pir
    to: 'off'
    for:
      minutes: 10
  action:
    service: homeassistant.turn_off
    entity_id: light.theater_room_light 

by memory the time platform uses a different time to my time zone way off my system time by like half a day this is why im using world clock as to get correct time so as to use for my automation you would think this would be a easy fix lol. has been driving me up the wall for days ill just use sun as trigger until we can find a solution for world clock / time.
thanks for all your help too much appreciated.

I think the error is in the ’ character of (‘08:00:00’)

if you copy his code the ’ is different from ‘

A couple of proposals/ideas:

  • You are saying that a time trigger doesn’t work for you and it appears to be shifted by half a day. Queensland is 10 hours ahead of UTC - is that maybe the time difference you see? Have you explicitly set your timezone in the configuration? If not, I believe UTC is the default timezone.
  • Once you have your time zone fixed and local time showing up correctly, try a simple time-triggered automation just to make sure it is working as expected. Then change to turning switches on/off and adding a delay.

which switch are you using?

M8 your a champion lol i must have missed setting this up in main configuration.yaml
omg spent ages working out how to get the correct time I feel so dumb thank you.
now i just tried this code below and pump has turned on correctly via automation.
we will see if it turns off in 8 hours when i wake up. ill post my results. thank you so much.

  • alias: ‘Pool Pump Schedule’
    trigger:
    platform: time
    at: ‘20:13:00’
    action:
    • service: homeassistant.turn_on
      entity_id: switch.pool_pump
    • delay: ‘08:00:00’
    • service: homeassistant.turn_off
      entity_id: switch.pool_pump

You may want to split it into two automations, one to turn on and one to turn off. That way if HA gets rebooted during the 8 hours it will still turn off the pump.

1 Like

Good idea have change my code allot ill share below seems nicer for me to have more control via interface and also split the on n off into there own automatons my best pump automatons and sliders bellow.

automations.yaml

- alias: "auto_pump_on enabled"
  trigger:
    platform: state
    entity_id: input_slider.auto_pump_minutes, input_slider.auto_pump_duration
  action:
  - service: homeassistant.turn_on
    data:
      entity_id:
        - automation.auto_pump_on
  - service: homeassistant.turn_on
    data:
      entity_id:
        - automation.auto_pump_off
- alias: 'auto_pump![Pool Pump slider|690x354](//community-home-assistant-assets.s3-us-west-2.amazonaws.com/original/2X/7/70ce0352bf985503fe4ed0fc4f77aa4115b0d72f.png)_on'
  initial_state: True
  trigger:
    - platform: time
      minutes: '/1'
      seconds: 10
  condition:
    - condition: template
      value_template: '{{ (now().strftime("%s") | int | timestamp_custom("%H:%M")) == states.sensor.auto_pump_start.state }}'
  action:
    - service: homeassistant.turn_on
      entity_id: "group.Pool"
- alias: 'auto_pump_off'
  initial_state: True
  trigger:
    - platform: time
      minutes: '/1'
      seconds: 10
  condition:
    - condition: template
      value_template: '{{ (now().strftime("%s") | int | timestamp_custom("%H:%M")) == states.sensor.auto_pump_stop.state }}'
  action:
    - service: homeassistant.turn_off
      entity_id: "group.Pool"

switches.yaml

- platform: mqtt
  name: "Pool Pump"
  state_topic: "stat/PoolPump/POWER"
  command_topic: "cmnd/PoolPump/POWER"
  qos: 0
  payload_on: "ON"
  payload_off: "OFF"
  optimistic: false
  retain: true

input_slider.yaml

auto_pump_minutes:
  name: Minutes after sunset
  icon: mdi:timer
  initial: 30
  min: 0
  max: 1200
  step: 10
auto_pump_duration:
  name: Duration hours
  icon: mdi:timer
  initial: 4
  min: 0
  max: 8
  step: 0.5

groups.yaml

  Pool:
   name: Pool Pump
   entities:
     - switch.Pool_Pump
     - sensor.auto_pump_start
     - sensor.auto_pump_stop
     - sensor.auto_pump_minutes
     - sensor.auto_pump_duration
     - input_slider.auto_pump_minutes
     - input_slider.auto_pump_duration

sensors.yaml

- platform: template
  sensors:
    auto_pump_start:
      friendly_name: 'Pump on at'
      value_template: '{{ (as_timestamp(states.sun.sun.attributes.next_setting) + (states("input_slider.auto_pump_minutes") | int)  * 60)  | timestamp_custom("%H:%M") }}'
    auto_pump_stop:
      friendly_name: 'Pump  off at'
      value_template: '{{ ( as_timestamp(states.sun.sun.attributes.next_setting) + (states("input_slider.auto_pump_minutes") | int)  * 60 + (states("input_slider.auto_pump_duration") | float) * 60 * 60  )  | timestamp_custom("%H:%M") }}'
    auto_pump_minutes:
      friendly_name: 'Pump  on '
      value_template: '{{ "%d minutes after sunset" | format(states("input_slider.auto_pump_minutes") | int) }}'
    auto_pump_duration:
      friendly_name: 'Pump on for'
      value_template: '{{ "%0.1f hours" | format(states("input_slider.auto_pump_duration") | float) }}'
2 Likes

Hope this helps someone.
Pool Pump slider

3 Likes

Thank you! i used you´r example. works great! ony issue i have is that HA keep forgetting what i change the sliders to, very annoying. have you solved this?

Hi there ,
Sorry for the delay in response I have my hands full with three younge children at the mo and don’t get much time to work on my HA . I hadn’t noticed the time resetting until you posted I did a restart of Home Assistant and yes mine also resets but I have modified the slider config as to run at the reset time seems to be working fine. But It would be good to keep it set at a predefined value I would also like to add the ability to lock the slider so you can’t accidentally change the time setting when scrolling through the HA main page. When I get time I’ll try come up with something to solve this hopeful someone out there can suggest some ideas

1 Like

Similar to @MyCool’s approach, I have also automated my pool pump, and just finished writing up a first overview of how I have done that: Smarter Swimming Pool 1: Pool Pump

1 Like

Thanks for the link to your code @exxamalte ! Ive tried to use it for my setup , but keep getting errors and not sure where to start troubleshooting. I dont have a WEMO but rather a SONOFF which I assume would change a bit of the code. Could you assist by sharing your .yaml files for this pool automation ?

The following components and platforms could not be set up:
input-select
input-number
input-boolean
Please check your config

1 Like

@Pro2col: All the configuration snippets are in that blog post, including all those controls as well as the automation, monitoring and reporting. Just go through from top to bottom and you will find everything you need.

Replacing the switch could be as simple as replacing the entity id, i.e. replace all occurrences of switch.wemo_insight_pool and you should be good to go. In the custom component I am not making many assumption about the switch; it only needs to support turn_on and turn_off services, and states on and off.

I went through your blog, but im not sure which file to add the code ? I use split configurations
The only file I was sure of was the [config_dir]/custom_components/pool_pump_service.py

Should I add everything to the configuration.yaml and test like this before splitting them ?

Some of the errors I receive, even after it passes the yaml check


SyntaxError: invalid syntax
Failed config
  input_boolean: 
    input_boolean: [source /config/includes/input_boolean.yaml:4]
      swimming_season: [source /config/includes/input_boolean.yaml:5]
        icon: mdi:swim
        name: Swimming Season

  General Errors: 
    - Setup failed for input_boolean: Invalid config.
    - Setup failed for input_select: Invalid config.
    - Setup failed for input_number: Invalid config.

  input_select: 
    input_select: [source /config/includes/input_select.yaml:4]
      pool_pump: [source /config/includes/input_select.yaml:5]
        icon: mdi:engine
        initial: Auto
        name: Pool Pump mode
        options: [source /config/includes/input_select.yaml:9]
          - Auto
          - On
          - Off

  input_number: 
    input_number: [source /config/includes/sliders/sliders_pool_pump.yaml:4]
      run_pool_pump_hours_off_season: [source /config/includes/sliders/sliders_pool_pump.yaml:5]
        max: 6
        min: 1
        mode: slider
        name: Run Pool Pump in Off Season
        step: 1
      run_pool_pump_hours_swimming_season: [source /config/includes/sliders/sliders_pool_pump.yaml:11]
        max: 8
        min: 1
        mode: slider
        name: Run Pool Pump in Swimming Season
        step: 1

Successful config (partial)
  input_boolean:
  input_select:
  input_number:

It could be as simple as removing the first line of each config snippet. The error message sounds as if you for example define having all input_booleans in a separate file, but then have an input_boolean statement in that file again. Instead you would only need the definition in that file:

  swimming_season:
    name: Swimming Season
    icon: mdi:swim

However, what I can highly recommend are packages. This way, you can keep any pool related controls and automations in one file.