Help with multiple conditions using or

Hi!

I’m trying to get 2 conditions to work. I get the following errror in my automation condition section:

Unsupported condition: or
{
  "condition": "or",
  "conditions": [
    {
      "after": "20:45",
      "before": "20:47",
      "condition": "time",
      "weekday": [
        "mon",
        "tue",
        "wed",
        "thu",
        "sun",
        {
          "condition": [
            {
              "after": "23:05",
              "before": "23:15",
              "condition": "time",
              "weekday": [
                "fri",
                "sat"
              ]
            }
          ]
        }
      ]
    }
  ]
}

The yaml looks like this:

- action:
  - data:
      entity_id: light.koket
    service: light.turn_off
  alias: Släck - Köket
  condition:
    - condition: or
      conditions:
      - condition: time
        after: '20:45'
        before: '20:47'
        weekday:
        - mon
        - tue
        - wed
        - thu
        - sun
        - condition:
            - condition: time
              after: '23:05'
              before: '23:15'
              weekday:
              - fri
              - sat
  id: '1516446946941'
  trigger:
  - at: '20:46'
    platform: time
  - at: '23:10'
    platform: time

Isn’t or condition supported or have I missed something else?

1 Like

Your spacing is incorrect

your ‘OR’ condition should sit even with your other condition

Thanks!
Could you perhaps show with a code snippet?
I’ve read the page but don’t really get what you mean by “should sit even with your other condition”.

My formatting might be off on this, but you just added too many ‘levels’ of condition. the problem is with this:

       - sun
        - condition:
            - condition: time

Remove the first -condition and line the rows back up.

- action:
  - data:
      entity_id: light.koket
    service: light.turn_off
  alias: Släck - Köket
  condition:
    - condition: or
      conditions:
      - condition: time
        after: '20:45'
        before: '20:47'
        weekday:
        - mon
        - tue
        - wed
        - thu
        - sun
      - condition: time
          after: '23:05'
          before: '23:15'
          weekday:
            - fri
            - sat
  id: '1516446946941'
  trigger:
  - at: '20:46'
    platform: time
  - at: '23:10'
    platform: time

Still struggling… made the changes (I think…) but still getting the same error:

Unsupported condition: or
{
  "condition": "or",
  "conditions": [
    {
      "after": "20:45",
      "before": "20:47",
      "condition": "time",
      "weekday": [
        "mon",
        "tue",
        "wed",
        "thu",
        "sun"
      ]
    },
    {
      "after": "23:05",
      "before": "23:15",
      "condition": "time",
      "weekday": [
        "fri",
        "sat"
      ]
    }
  ]
}

for yaml:

- action:
  - data:
      entity_id: light.koket
    service: light.turn_off
  alias: Släck - Köket
  condition:
    condition: or
    conditions:
      - condition: time
        after: '20:45'
        before: '20:47'
        weekday:
        - mon
        - tue
        - wed
        - thu
        - sun
      - condition: time
        after: '23:05'
        before: '23:15'
        weekday:
        - fri
        - sat
  id: '1516446946941'
  trigger:
  - at: '20:46'
    platform: time
  - at: '23:10'
    platform: time

I’m running Hass.io (Home Assistant 0.61.1) but that shouldn’t matter I guess?

I have the same issue. Did you figure it out?

- action:
  - data:
      entity_id: light.soverom_pernille
    service: light.turn_on
  - delay: '00:15:00'
  - data:
      entity_id: light.soverom_pernille
    service: light.turn_off
  alias: Autolys Pernille
  condition:
    condition: or
    conditions: 
      - condition: time
        after: '08:00:00'
      - condition: time
        before: '19:30:00'
  id: '1518454246987'
  trigger:
  - entity_id: binary_sensor.motion_sensor_158d0001a92a38
    from: 'off'
    platform: state
    to: 'on'

What are you trying to do with that condition? It is always going to be after 8:00 or before 19:30…

If you are trying to trigger the automation only between those times, you do not need an “or” condition. You should be able to use the following:

condition: time
  after: '08:00'
  before: '19:30'
1 Like

Hi!
No, haven’t figured it out yet. For now I’m using one condition for Sunday to Thursday and one condition for Friday to Saturday. Would like to have them in on condition though.

Yes that is what I am trying to do. I thought I got an error by typing like you do, and started trying OR instead. It worked without OR now, thanks.

Are you saying you removed the “or” word and just had

condition:
conditions:
- condition: (1)

Since the condition would always be between “after” and “before” times, I took away anything relating to normal OR method. The automation is just like this now:

condition:

  • after: 09:30
    before: ‘19:30’
    condition: time

Can you please post the yaml code for the automation?

> - action:
>   - data:
>       entity_id: light.tradfri_bulb_e27_w_opal_1000lm_9
>       brightness: 130
>     service: light.turn_on
>   alias: Autolys Emmeline ON
>   condition:
>   - after: 09:30
>     before: '19:30'
>     condition: time
>   id: '1519336547971'
>   trigger:
>   - entity_id: binary_sensor.motion_sensor_158d0001b15df4
>     from: 'off'
>     platform: state
>     to: 'on'

what if i need multiple periods of time?

  condition:
  - condition: state
    entity_id: binary_sensor.door_window_sensor_158d00035831c7
    state: 'off'
  - after: '10:00'
    before: '13:00'
    condition: time
  - after: '15:00'
    before: '23:00'
    condition: time

But automation didnt start at all …

are those conditions supposed to be “or” or are they “and”?

i think its “or”.
actualy i want
door and (time or time)

condition:
  - condition: state
    entity_id: binary_sensor.door_window_sensor_158d00035831c7
    state: 'off'
  - condition: or
    conditions:
      - after: '10:00'
        before: '13:00'
        condition: time
      - after: '15:00'
        before: '23:00'
        condition: time
1 Like

Did you figure this out? I still get the error and I’ve used your formatting ‘finity’, it didn’t help.

  condition:
    - condition: time
      after: '09:30'
      before: '20:30'
    - condition: or
      conditions:
        - state: 'home'
          entity_id: person.derek_bredl
          condition: state
        - state: 'home'
          entity_id: person.elaine_bredl
          condition: state

Is my code and it’s still giving the error.