IF with multi condition

Hi
as the code below I try to turn off the relay switch when my all light goes off after 1m but is not work

any help

thanks

light:

  - platform: rgb
    name: "$devicename Right Strip"
    id: right_strip_rgb
    red: right_strip_red
    green: right_strip_green
    blue: right_strip_blue
    on_turn_on:
    - switch.turn_on: relay
    on_turn_off:
    - if:
        condition:
          - light.is_off: "right_strip_rgb"
          - light.is_off: "lift_strip_rgb"
          - light.is_off: "down_strip_rgb"
          - light.is_off: "top_strip_ww"
          - light.is_off: "down_strip_ww"
        then:
          - delay: 60s
          - switch.turn_off: relay


  - platform: rgb
    name: "$devicename Lift Strip"
    id: lift_strip_rgb
    red: lift_strip_red
    green: lift_strip_green
    blue: lift_strip_blue
    on_turn_on:
    - switch.turn_on: relay
    on_turn_off:
    - if:
        condition:
          - light.is_off: "right_strip_rgb"
          - light.is_off: "lift_strip_rgb"
          - light.is_off: "down_strip_rgb"
          - light.is_off: "top_strip_ww"
          - light.is_off: "down_strip_ww"
        then:
          - delay: 60s
          - switch.turn_off: relay

  - platform: rgb
    name: "$devicename Down Strip"
    id: down_strip_rgb
    red: down_strip_red
    green: down_strip_green
    blue: down_strip_blue
    on_turn_on:
    - switch.turn_on: relay
    on_turn_off:
    - if:
        condition:
          - light.is_off: "right_strip_rgb"
          - light.is_off: "lift_strip_rgb"
          - light.is_off: "down_strip_rgb"
          - light.is_off: "top_strip_ww"
          - light.is_off: "down_strip_ww"
        then:
          - delay: 60s
          - switch.turn_off: relay

  - platform: monochromatic
    name: "$devicename Top W W"
    id: top_strip_ww
    output: top_w_w
    on_turn_on:
    - switch.turn_on: relay
    on_turn_off:
    - if:
        condition:
          - light.is_off: "right_strip_rgb"
          - light.is_off: "lift_strip_rgb"
          - light.is_off: "down_strip_rgb"
          - light.is_off: "top_strip_ww"
          - light.is_off: "down_strip_ww"
        then:
          - delay: 60s
          - switch.turn_off: relay


  - platform: monochromatic
    name: "$devicename Down W W"
    id: down_strip_ww
    output: down_w_w
    on_turn_on:
    - switch.turn_on: relay
    on_turn_off:
    - if:
        condition:
          - light.is_off: "right_strip_rgb"
          - light.is_off: "lift_strip_rgb"
          - light.is_off: "down_strip_rgb"
          - light.is_off: "top_strip_ww"
          - light.is_off: "down_strip_ww"
        then:
          - delay: 60s
          - switch.turn_off: relay

Try this:

  - platform: rgb
    name: "$devicename Right Strip"
    id: right_strip_rgb
    red: right_strip_red
    green: right_strip_green
    blue: right_strip_blue
    on_turn_on:
    - switch.turn_on: relay
    on_turn_off:
    - if:
        condition:
          and:
            - light.is_off: "right_strip_rgb"
            - light.is_off: "lift_strip_rgb"
            - light.is_off: "down_strip_rgb"
            - light.is_off: "top_strip_ww"
            - light.is_off: "down_strip_ww"
        then:
          - delay: 60s
          - switch.turn_off: relay

Likewise for the other lists of conditions.

@tom_l thanks for the replay I try it before the same result

any new suggestions ?

No, sorry. That was all I had. If no one else has any ideas here you could try asking in the ESPHome discord channel. There are some very knowledgeable people in that channel.

ok thanks @tom_l

Hi,
i think on_turn_off: is only triggerd one time, when id: right_strip_rgb is triggerd to turn off.
If one light is on, the condition fail (is not true) and the relay wont work.

Try to do more logging to get closer.
ex use else and logger.log

Hi @TiBo
you are right until now i don’t find way to fix it

You could try a slight delay before each automation

    on_turn_off:
    - delay: 500ms
    - if:
        condition:

or an interval

interval:
  - interval: 1min
    then:
      - if:
          condition:
            and:
              - light.is_off: "right_strip_rgb"
              - light.is_off: "lift_strip_rgb"
              - light.is_off: "down_strip_rgb"
              - light.is_off: "top_strip_ww"
              - light.is_off: "down_strip_ww"
              - switch.is_on: relay
          then:
            - delay: 60s
            - switch.turn_off: relay

Edit: moved the action under the condition

I don’t see your output configuration, but is this relay to turn power on/off for the lights? If so take a look at Power Supply Component — ESPHome

thank you @nickrout that works perfectly :smiley: :smiley: