"Or" condition not working in script

I’m trying to unlock a door if I can detect that either one of two phones are home after I’ve tripped one of my sensors. My YAML appears to be valid - but HASS is not liking it.

Scripts do accept or conditions, right?

Here’s what it says:

ERROR (MainThread) [homeassistant.bootstrap] Invalid config for [script]: [condition] is an invalid option for [script]. Check: script->script->unlock_auto->sequence->0->condition.

And here’s what it doesn’t like:

unlock_auto:
  sequence:
    - condition:
        condition: or
        conditions:
          - condition: state
            entity_id: 'device_tracker.phone1'
            state: 'home'
          - condition: state
            entity_id: 'device_tracker.phone2'
            state: 'home'
    - service: lock.unlock
      entity_id:
        - lock.lock1_lock_locked_20_0

Did you try moving that or one step up so there is no second ‘condition’ block. If this does not work just use a template condition.

~Cheers

Try:

unlock_auto:
  sequence:
    - condition or:
        conditions: 
          - condition: state
            entity_id: 'device_tracker.phone1'
            state: 'home'
          - condition: state
            entity_id: 'device_tracker.phone2'
            state: 'home'
    - service: lock.unlock
      entity_id:
        - lock.lock1_lock_locked_20_0

I did try moving the block up, but it didn’t work. The script condition docs appear to say my syntax is right:

I tried @Danielhiversen’s example - but condition or: doesn’t appear to be valid:
ERROR (MainThread) [homeassistant.bootstrap] Invalid config for [script]: [condition or] is an invalid option for [script].

Well conditions are a bit weird imho. Just use a template condition then :slight_smile:

unlock_auto:
  sequence:
    - condition: template
      value_template: '{{ is_state("device_tracker.phone1", "home") or is_state("device_tracker.phone2", "home")  }}'
    - service: lock.unlock
      entity_id:
        - lock.lock1_lock_locked_20_0

~Cheers

1 Like

That worked perfect - thank you! Looks like templates are definitely the way to go.