Pool level automation help

Hi, hoping someone can help me with an automation I created - I am trying to set up an automatic pool filler. When the water level drops, a float switch triggers a modified Aqara Zigbee door sensor which turns on a zigbee plug to fill the pool. Once the pool is full, it shuts off the plug.

I tried configuring it so that it would wait before filling since I figured that people splashing in the pool and making waves would fool the float sensor.

The way I currently have it seems to not work right since it begins to fill after the waiting period if the sensor has tripped, even if the sensor closes again (in the event of waves).

So, I need to configure it so that it only begins to fill once the float switch has opened, waited the waiting period and only if the sensor remained open the entire time.

I hope that makes sense.

Here is my YAML for my current version of the automation:

alias: Pool Filler
description: ""
trigger:
  - type: opened
    platform: device
    device_id: 7f75010dc6037f597e275351b733cc5c
    entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_opening_2
    domain: binary_sensor
    for:
      hours: 1
      minutes: 0
      seconds: 0
condition:
  - condition: time
    after: "08:00:00"
    before: "19:00:00"
    weekday:
      - sun
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
action:
  - type: turn_on
    device_id: 3c85cc376358a74f399e06d8f566f96a
    entity_id: switch.pool_filler_switch
    domain: switch
  - wait_for_trigger:
      - type: not_opened
        platform: device
        device_id: 7f75010dc6037f597e275351b733cc5c
        entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_opening_2
        domain: binary_sensor
        for:
          hours: 0
          minutes: 10
          seconds: 0
  - type: turn_off
    device_id: 3c85cc376358a74f399e06d8f566f96a
    entity_id: switch.pool_filler_switch
    domain: switch
mode: single

Thank you for any help!!

-David

:grimacing:

For a start I would add a maximum run time for the pump, just in case something goes wrong and you try to empty your entire municipal water supply into your pool.

A better way to do this would be with two automations.

alias: Pool Filler On
trigger:
  - platform: state
    entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_opening_2
    to: 'on'
    for:
      hours: 1
condition:
  - condition: time
    after: "08:00:00"
    before: "19:00:00"
action:
  - service: switch.turn_on
    target:
      entity_id: switch.pool_filler_switch
alias: Pool Filler Off
trigger:
  - platform: state
    entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_opening_2
    to: 'off'
    for:
      minutes: 10
  - platform: state
    entity_id: switch.pool_filler_switch
    to: 'on'
    for:
      hours: 2 # or whatever you want to set the maximum pump run time to.
action:
  - service: switch.turn_off
    target:
      entity_id: switch.pool_filler_switch

Or better yet (for the off automation):

action:
  - repeat: # make sure it turns off
      sequence:
        - service: switch.turn_off
          target:
            entity_id: switch.pool_filler_switch
        # Give it time to turn off
        - delay: 10
      until:
        - condition: or
          conditions:
            - condition: state      # Try until it turns off
              entity_id: switch.pool_filler_switch
              state: "off"
            - condition: template   # Only try 10 times
              value_template: "{{ repeat.index <= 10 }}"

You should also write an alert automation to notify you if the pool filler switch is on for longer than the maximum run time + repeated off attempts time.

alias: Pool Filler Overrun Alert
trigger:
  - platform: state
    entity_id: switch.pool_filler_switch
    to: 'on'
    for:
      hours: 2
      minutes: 1
      seconds: 41
action:
  - service: notify.etc...

Hi @tom_l

Thank you so much! That seems to have worked. It did a successful fill and shut-off yesterday.

I am totally unfamiliar with notifications, though - I have never done them before, but have wanted to. Does HA have notifications built in? Or do I still need a third party service? Any suggestions you have would be greatly appreciated!!

Thank you again.

-David

1 Like

Do you use the Home Assistant companion app?

If so, you have a notification service.

If not you can pick one of these:

I use telegram as that way I have a notification history in the chat groups that I can set up to auto delete after a month. I have 3 chat groups, System, General and NVR.

System: gets all my warnings and important logs about the system. Only sent to me.

General: things like alarm, vacuum, energy, garbage, irrigation and other logs and reminders that everyone gets.

NVR: vehicle and person camera snapshots sent to me only.

It can be a little tricky to set up but its free.

Ah, yes, I do. I will read through that.

Between using the Companion app and Telegram, would you still suggest Telegram for the notification history and ability to use different chat groups?

Thanks again!!
-David

It depends how important having a history of messages is to you.

I haven’t used the companion app notification service for ages but found I often wanted to go back and re-read a message after dismissing it.

Hi all, I am still having some trouble with this automation. I would like it to determine if it is between the hours of 8am and 9pm. If it is, it should run. If not, it should wait until 8am and then run. With the conditional execution in place, if it isn’t between those times, it doesn’t run, but then it never runs (not even at the time I told to to wait until). If I take that condition out, it runs perfectly, but at any hour. Can anyone give me some advice with this?

alias: Pool Filler On
description: With leak sensor
trigger:
  - platform: state
    entity_id:
      - binary_sensor.pool_water_level_sensor_opening
    to: "off"
    for:
      hours: 0
      minutes: 4
      seconds: 0
condition: []
action:
  - service: switch.turn_on
    target:
      entity_id: switch.pool_filler_switch
    data: {}
    enabled: false
  - if:
      - condition: time
        after: "08:00:00"
        before: "21:00:00"
    then:
      - service: switch.turn_on
        data: {}
        target:
          device_id: 3c85cc376358a74f399e06d8f566f96a
    else:
      - wait_for_trigger:
          - platform: time
            at: "08:00:00"
      - service: switch.turn_on
        data: {}
        target:
          device_id: 3c85cc376358a74f399e06d8f566f96a
    enabled: true
  - service: switch.turn_on
    data: {}
    target:
      device_id: 3c85cc376358a74f399e06d8f566f96a
mode: single

Thank you!!

alias: Pool Filler On
trigger:
  - platform: state
    entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_opening_2
    to: 'on'
    for:
      hours: 1
  - platform: time
    at: "08:00:00"
condition:
  - condition: time
    after: "08:00:00"
    before: "19:00:00"
  - condition: state
    entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_opening_2
    state: "on"
action:
  - service: switch.turn_on
    target:
      entity_id: switch.pool_filler_switch

Thank you for this. I am not clear what the time platform in the trigger accomplishes. Can you explain how this will only allow the switch to turn on during the specified times (and will it delay the action until 8am if the trigger occurs outside of the condition time)?

Thank you for the help!!

I mistakenly set it to 8pm. I have edited it to 8am.

What happens:

If the fill required binary sensor is already on when it becomes 8am the fill pump will start (second trigger, and both conditions).

If the binary sensor is not on before 8am but turns on some time between 8am and 7pm the fill pump will start at that time (first trigger, and both conditions).

The "pump off’ automation remains the same.