Automation suddenly stopped working

I am having a really weird problem here… I have a set of automations that turns on the pond filter during the day after rain stops if it is above a certain temperature and has not been cleaned in the last hour already. This part works great thanks to some help from everyone here!

Now… that cleaning process is supposed to automatically stop after 20 minutes and has worked great for several weeks. With a really wet spring this has had plenty of exercise. I have not updated home assistant to v .72 so it wouldn’t have been a system upgrade that broke it, but it seems that the stop cleaning automation suddenly stopped working as I came home from work two days in a row to find the pump on for 8+ hours. Does anyone have any idea what the issue with the code below is??

##########################################################
#  Turn On Pond Filter After Rain Stops
##########################################################
- alias: "Clean pond after rain"
  trigger:
    - platform: state
      entity_id:
        - sensor.dark_sky_icon
      from: 'rain'
  condition:
    condition: and
    conditions:
      - condition: state
        entity_id: sun.sun
        state: 'above_horizon'
      - condition: state
        entity_id: switch.waterfallpump
        state: 'off'
      - condition: numeric_state
        entity_id: sensor.dark_sky_temperature
        above: 45
      - condition: template
        value_template: '{{ (as_timestamp(now()) - as_timestamp(states.automation.clean_pond_after_rain.attributes.last_triggered | default(0)) | int > 3600)}}'
  action:
    - service: homeassistant.turn_on
      entity_id:
        - input_boolean.auto_waterfallpump
        - switch.waterfallpump

##########################################################
#  Turn Off Pond Filter After Cleaning Cycle
##########################################################
- alias: 'Pond cleaning complete'
  trigger:
    - platform: state
      entity_id: input_boolean.automation_triggered_pump
      to: 'on'
      for:
        minutes: 20
  action:
    - service: homeassistant.turn_off
      entity_id:
        - input_boolean.auto_waterfallpump
        - switch.waterfallpump

I even attempted to swap out the used-to-be working state trigger with a template trigger to no avail.

- platform: template
  value_template: '{{ (as_timestamp(now()) - as_timestamp(states.automation.clean_pond_after_rain.attributes.last_triggered | default(0)) | int > 1200)}}'

Any help would be amazing. I have rebooted the server, and have ensured the host time is correct so I am not sure what is up. Thanks!

I would say you should either use the switch itself to check how long it’s been on to turn off the pump or check for the boolean status in the Dev Tools - is it really on/off or is it true/false?

- alias: 'Pond cleaning complete'
  trigger:
    - platform: state
      entity_id: switch.waterfallpump
      to: 'on'
      for:
        minutes: 20
  action:
    service: homeassistant.turn_off
    entity_id:
      - input_boolean.auto_waterfallpump
      - switch.waterfallpump

Strictly speaking you shouldn’t need the ‘-’ in the action section because it’s only one action - but that shouldn’t have any impact.

any reason why you are using an input boolean when you have a perfectly good switch to automate off of? I only say this because I could see this automation getting out of sync if your input boolean is on when the first automation fires.

If an input_boolean is on and you tell it to turn on, that second ‘turn on’ gets suppressed and ignored by HA. Essentially making your second automation never fire, because the trigger does not occur. A safe way to make to ensure that this never happens is to turn off the input_boolean before turning it on in the first automation.

When I first looked at this something didn’t seem right. I think I see it now. You’re turning input_boolean.auto_waterfallpump on in the first automation, but you’re using input_boolean.automation_triggered_pump in the trigger of the second automation. Unless there’s another automation somewhere that is changing input_boolean.automation_triggered_pump, this would definitely explain why the pump did not get turned off after 20 minutes. I would think you need to change the entity_id in the trigger of the second automation to input_boolean.auto_waterfallpump.

My guess is he wants the pump to turn off automatically only if it was turned on automatically. Using the pump switch directly would make it turn off automatically even if it was turned on manually.

Agreed! :slight_smile: