Automation to clean a pond filter

I want to automate cleaning a pond filter at different time intervals dependant on the time of year,
in summer more frequent cleans are required than in winter.
I have a shelly 2pm that starts the clean using channel 1 momentary on and channel 2 switches to active during the clean and inactive when its finished
to summarise,
in summer the clean starts
once it ends (channel 2 off), the automation waits 4 hours and starts the clean again
until autumn then the wait time changes to 6 hours
until winter, then the timer changes to 12 hours
until spring then the timer changes to 8 hours
then back to summer
if the clean is operated manually then the next scheduled clean is skipped.

I hope someone can please assist me with this as its far too complicated for me.
thanks

Yes!

Ingredients: 1 date/time helper + 2 automation.

First, create your date/time helper Next Clean Time.

Now, automations:

First automation has following:

Trigger:

State: Next Clean Time is On.

Actions:

  1. Activate your Shelly channels as you need for the cleaning to happen.
  2. Wait for a time, until the cleaning needs to stop.
  3. Deactivate your Shelly channels to end the cleaning.

Second automation has:

Trigger: Shelly Channel 1 changed from Off to On (or Channel 2 changed to Off).

Action: Using a “Choose one” action, create four options in i, one per season. In the condition of each option you can use a sensor for the season, and in the action use a Call service: set the right time in the future on the date/time helper (4, 6 or 8 hours). A template {{now + 4 *3600}} will work for summer e.g.

The net effect is that either manual or automatic cleaning end up pushing the next clean date into the future, and therefore Next Clean Time always keeps on firing.

One caveat is that I don’t know how this would happen if there is an extended outage of HA, and when HA finally restarts the Next Clean Time sensor is already on. You must test this theory somehow, on your own. If the automation doesn’t fire, you might have to extend it such that there is a second trigger “Home Assistant Started” + condition Next Clean Time = On, to cover that case.

You could conceivably combine both into a single automation, but then the mode of the automation must be changed from Single to Parallel.

Hello Rudd-O
Thanks so much for helping, would you mind explaining the following in more detail ?

and in the action use a Call service: set the right time in the future on the date/time helper (4, 6 or 8 hours). A template {{now + 4 *3600}} will work for summer e.g.

If you would like a season sensor:

and in the action use a Call service: set the right time in the future on the date/time helper (4, 6 or 8 hours). A template {{now + 4 *3600}} will work for summer e.g.

service: input_datetime.set_datetime
data:
  timestamp: '{{ as_timestamp(now()) + 4*3600 }}'
target:
  entity_id: input_datetime.next_vacuum_time

That’s great thank you for your help.

1 Like

Hello Rudd-O
Sorry to be a pain, I created the automation and all runs ok when I test run. The helper updates the time but I can’t get the helper to run
Can you help me with getting the helper to trigger the clean please

I cannot because you did not paste the relevant code.

alias: Nexus Next Clean Time
description: "Cleaning schedule "
trigger:

  • platform: state
    entity_id:
    • input_datetime.next_clean_time
      to: “true”
      attribute: timestamp
      condition: []
      action:
  • type: turn_on
    device_id: e6167f5ed11d817e2d24edf961c1db57
    entity_id: 23c2396a97aa7583144beb30cfacd3b9
    domain: switch
  • wait_for_trigger:
    • platform: device
      type: turned_off
      device_id: e6167f5ed11d817e2d24edf961c1db57
      entity_id: 8a14b27a96440c038feae02a800665af
      domain: light
      timeout:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 0
      continue_on_timeout: false
      mode: single

Not sure why you have the wait for trigger at the end. It does nothing.

The trigger for the automation is probably not going to for because you have selected a “to” value of “true”, which is almost certainly wrong (it’s normally “on”).

Hi thanks for the reply
Yes I tried it with “on” originally but it still did nothing
Here it is changed back and still it’s not working

alias: Nexus Next Clean Time
description: "Cleaning schedule "
trigger:

  • platform: state
    entity_id:
    • input_datetime.next_clean_time
      to: “on”
      condition: []
      action:
  • type: turn_on
    device_id: e6167f5ed11d817e2d24edf961c1db57
    entity_id: 23c2396a97aa7583144beb30cfacd3b9
    domain: switch
  • wait_for_trigger:
    • platform: device
      type: turned_off
      device_id: e6167f5ed11d817e2d24edf961c1db57
      entity_id: 8a14b27a96440c038feae02a800665af
      domain: light
      timeout:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 0
      continue_on_timeout: false
      mode: single

I’m going to need the whole automation YAML properly pasted using triple backticks quotation style. There is obviously stuff missing there.

I don’t seem to be able to paste the code without the format changes

What you have there triggers when next_clean_time has arrived. Then it turns on a switch (whose ID I don’t know), and it waits for a light (whose ID I don’t know) to turn off. At no point in time is next_clean_time updated.

This doesn’t at all sound like what you wanted to do.

I made 2 automations and a helper like you said
The first automation (this one) triggers the clean
The second updates the helper time
Here’s the second automation

But the clean is never triggered

Here’s the helper history

Thanks everyone for helping you got me halfway there, the rest I figured out myself…