Help with and\or conditions

Hi Everyone me again.

Looking for some support setting up an automation to run on my living room lights.

I have some conditions that I am trying to meet but I seem to be running into a problem with the Or statement.

I am using light level on an outdoor motion sensor as a trigger which works. There are some conditions that must be met before it runs, I will list these below.

  • Hubitat Sensor must be on home mode (This works during testing)
  • Both Lights must be in the off state (this works also works)
  • I have 3 devices, Living Room TV, Living room PC & Living Room Computer (this is where I have the problem)

What I expect to happen with above is that if any or all of the devices are on the automation should run, So if I add one device as an entity with the state being on it works, if I set the state to off and run it then it does not work, this is expected but when I come to add the second device this is when it stops working, I am adding this as an or condition. If both states are on it works but if one of the states are off then it does not work.

Here is the YAML code:

id: '1637678191203'
alias: Turn on Living Room Lights when Lux level below 300
description: ''
trigger:
  - type: illuminance
    platform: device
    device_id: f55ee4aa6c897bd26753bed686c2059b
    entity_id: sensor.hue_outdoor_motion_sensor_1_light_level_2
    domain: sensor
    below: 100
condition:
  - condition: state
    entity_id: sensor.hub_mode
    state: Home
  - condition: device
    type: is_off
    device_id: 2d2d1e5851d53030469a978a0ab66d02
    entity_id: light.living_room_big_light_1
    domain: light
  - condition: device
    type: is_off
    device_id: 185a1ba6bb4a74965d1be12af31df9b3
    entity_id: light.living_room_big_light_2
    domain: light
  - condition: and
    conditions:
      - condition: state
        entity_id: switch.living_room_tv
        state: 'on'
      - condition: or
        conditions:
          - condition: state
            entity_id: switch.living_room_speakers
            state: 'on'
action:
  - service: light.turn_on
    data:
      brightness_pct: 50
    target:
      area_id: living_room_lights
mode: restart
condition:
  - condition: state
    entity_id: sensor.hub_mode
    state: Home
  - condition: device
    type: is_off
    device_id: 2d2d1e5851d53030469a978a0ab66d02
    entity_id: light.living_room_big_light_1
    domain: light
  - condition: device
    type: is_off
    device_id: 185a1ba6bb4a74965d1be12af31df9b3
    entity_id: light.living_room_big_light_2
    domain: light
  - condition: or
    conditions:
      - condition: state
        entity_id: switch.living_room_tv
        state: 'on'
      - condition: state
        entity_id: switch.living_room_speakers
        state: 'on'

Thanks, this is now working :slight_smile:

1 Like