Run schedule only on specific conditions…

Hi Everbody,

I have a pump which is turned on and off using a schedule. I want to leave the „turn on“ as it is, but only turn it off when a specific switch has a state of false. If it is true, the pump should not turn off.

I‘ve never done anything with automations or helpers. So I’m a little stuck here on how to start it. Coming over from iobroker, where I could use blockly for these conditions, I have no idea how to do this in Home Assistent.

I have no problem adding it via the configuration.yaml if this is easier than from the frontend. I just need to get the initial idea how to solve this…

Thanks, Carsten

The following automation turns on a pump switch according to a schedule. Create a schedule helper and set the time periods when the pump should be on.

alias: Scheduled Pump On
trigger:
  - platform: state
    entity_id: schedule.pump
    from: 'off'
    to: 'on'
condition: []
action:
  - service: switch.turn_on 
    target:
      entity_id: switch.pump

The following automation turns off the pump switch according to the same schedule but only if the state of switch.whatever is off.

alias: Scheduled Pump Off
trigger:
  - platform: state
    entity_id: schedule.pump
    from: 'on'
    to: 'off'
condition:
  - condition: state
    entity_id: switch.whatever
    state: 'off'
action:
  - service: switch.turn_off
    target:
      entity_id: switch.pump

Depending on your requirements, the entity called switch.whatever can be replaced by an Input Boolean. In addition, the two separate automations can be consolidated into a single automation.

1 Like

Thanks…that was really helpful. I’ve setup everything…let’s hope that it’s working as it should.

When is the schedule configured to run the pump?

It works…

I run it as 9am and 3pm for 30 minutes, but then a specific entity is set, it doesn’t not turn off. There is another “turn off” automation with no condition which will make sure that it always turns off at 10pm at night. So three automations in total.

Glad to hear it works.

Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.

For more information refer to guideline 21 in the FAQ.