Condition: 'or' and 'and'?

Hi everybody,

I am currently trying to create an automation to water our plants twice a day; it is meant for summer, but I’d like to try it already, so I’ll work with summer and spring (explained below).

In order for the automation to work properly, I need it to check

  • whether it is currently spring or summer => this is determined by my sensor.season, which will report the current season
  • whether or not it is supposed to rain that day => determined by openweathermap sensor
  • (whether or not temperature will be above a certain value that day; not sure if/how I will implement this)

So I need the automation to first check, whether or not it is either spring or summer (or condition), and, if either is true, check whether it will not rain that day and if so (and condition).

My current workaround would be to create an extra automation that will set something like binary_sensor.irrigation to true/false depending on the season, then use another automation to check rain probability and/or temperature (binary_sensor.irrigation_two or something like that), then use a third automation to trigger at sundown -01:30:00 and sunset +1:30:00, use and condition on those two binary_sensors, then finally trigger the irrigation.

I’d actually know how to do this, but I’d prefer to use one single automation for this, if possible. So far, all I got is that part below. Can somebody please help me out?

automation:
  - alias: "[Timer] Bewässerung Morgens"
    trigger:
      platform: sun
      event: sunrise
      offset: "-01:30:00"
    condition:
      condition: or
      conditions:
        - condition: state
# (...) not sure how to continue here
    action:
      - service: switch.turn_on
        entity_id: switch.kaercher_pumpe
      - delay: "00:03:30"
      - service: switch.turn_off
        entity_id: switch.kaercher_pumpe

Thank you for your ideas :slight_smile:

Believe it might be easiest to build this in the Automation Editor UI - it does a pretty good job of building these ‘and’ / ‘or’ logics.

Also, think of the conditions as ALL MUST BE TRUE in order to ‘proceed’ with the automation. So the Trigger (sunrise -90 minutes) starts the automations, then the conditions ‘allow’ (if ALL TRUE) to proceed/run.

Condition:

  1. Season SUMMER OR SPRING
  2. Rain that day
  3. temperature > xx

Something ‘like’ this:

You should be able to get this into a single automation w/out making it too complicated.

The documentation for conditions spells out how to combine conditions with an example that matches exactly what you would like to do. Have a look at “Mixed AND and OR conditions” on https://www.home-assistant.io/docs/scripts/conditions/

Thank you. I missed that part, it works fine (or well, Home Assistant won’t throw any errors, I’ll see if the logic works one the sun goes down).