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:
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
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...
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!!
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.
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?
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)?
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).