Help with Interval and duration automation for Aeroponics

Hi All,

I`ve been trying to automate my Aeroponics system for months now, I would like to do this with the automation(scripts) without Node-Red.

What I`d like to achieve is turning on the Aeroponics every 5 minutes and stay on for 5 minutes before turning off.

How I tried to achieve this is by having 2 automation scripts the first

  • TURN_ON: checks a TimePattern and Input_Boolean if automation is enabled then turns on the system.
  • TURN_OFF: checks a TimePattern, Input_Boolean and if the switch state is ON and turns it off.

Unfortunatly this does not turn on the system, it does however, turn it Off if it`s On.

What I have so far is:

- id: 1605793810800
  alias: Aeroponics Automation TURN_ON
  description: 
  trigger:
  - platform: time_pattern
    minutes: /5
  condition:
  - condition: state
    entity_id: input_boolean.aeroponics_auto_enabled
    state: on
  - condition: and
    conditions:
    - condition: state
      entity_id: switch.auto_aeroponics
      state: off
  action:
  - service: switch.turn_on
    data: {}
    entity_id: switch.grow_aeroponicspump
  mode: single
- id: 1605794003596
  alias: Aeroponics Automation TURN_OFF
  description: 
  trigger:
  - platform: time_pattern
    minutes: /5
  condition:
  - condition: state
    entity_id: input_boolean.aeroponics_auto_enabled
    state: on
  - condition: and
    conditions:
    - condition: state
      entity_id: switch.auto_aeroponics
      state: on
  action:
  - service: switch.turn_off
    data: {}
    entity_id: switch.grow_aeroponicspump
  mode: single

Does anybody have any insights for me?

Kind regards, Nick

Perhaps this single automation meets your requirements. All it does is toggle the switch’s state every 5 minutes.

- id: 1605793810800
  alias: Aeroponics Automation Toggle
  description: 
  trigger:
  - platform: time_pattern
    minutes: /5
  condition:
  - condition: state
    entity_id: input_boolean.aeroponics_auto_enabled
    state: on
  action:
  - service: switch.toggle
    data: {}
    entity_id: switch.grow_aeroponicspump
  mode: single

The only thing I would add (even if you continue to use your existing two-automation solution) is an automation that turns off the switch when the input_boolean is turned off. Otherwise, there’s a possibility the pump can operate indefinitely (for example, if you turn off the input_boolean while the pump is on, your second automation will not turn off the pump because its condition expects the input_boolean to be on).

- id: 1234567890
  alias: Aeroponics Off
  description: 
  trigger:
  - platform: state
    entity_id: input_boolean.aeroponics_auto_enabled
    to: 'off'
  action:
  - service: switch.turn_off
    data: {}
    entity_id: switch.grow_aeroponicspump
  mode: single

Thanks! I did not even consider a toggle automation…

This helps a lot.