Automation - Triggered entities with AND operation

Hi ha community,

I have multiple humidity sensors (for different bathrooms). I would like automate the switch on/off of my ventilation based on the humidity percentage.

For switch on, if one of my sensors has an numeric state above 65%, no problem:

- alias: 'ventilation on'
  trigger:
    platform: numeric_state
    entity_id: sensor.xxxxxxxxxxxxx_relative_humidity, sensor.xxxxxxxxxxxxx_relative_humidity_2
    above: 65
  action:
    - service: switch.turn_on
      entity_id: switch.xxxxxxxxxxxxx_switch

But for the switch off, it’s more complicated cause every sensors must be below 60%, and I can’t do that:

- alias: 'ventilation off'
  trigger:
    platform: numeric_state
    entity_id: sensor.xxxxxxxxxxxxx_relative_humidity, sensor.xxxxxxxxxxxxx_relative_humidity_2
    below: 60
  action:
    - service: switch.turn_off
      entity_id: switch.xxxxxxxxxxxxx_switch

How can you specify an AND operator in the entity_id list?

Thanks in advance.

Leave the rest of your automation as is but add conditions :

   condition:
    condition: and
    conditions:
    - condition: numeric_state
      entity_id: sensor.xxxxxxxxxxxxx_relative_humidity
      below: 60
    - condition: numeric_state
      entity_id: sensor.xxxxxxxxxxxxx_relative_humidity_2
      below: 60

So any one sensor dropping below 60 will trigger the automation, but with the AND condition, only when both sensors are below 60 will the action run.

Thanks for your help!

Does it behave as you’d expect ?

After testing few days, it seems ok.
Thank you :wink: