Hi all
Can the conditions within the action ‘Choose’ be made OR instead of AND?
What is the syntax for that?
This is the current YAML:
alias: Evening Check
description: >-
When I put my phone on charge, at home, after 2100, (and am therefore probably
going to bed), check doors are locked etc
trigger:
- type: plugged_in
platform: device
device_id: e47b3d0477733e994567b62fb08d7b7f
entity_id: binary_sensor.galaxy_s10_is_charging
domain: binary_sensor
condition:
- condition: time
after: '21:00'
before: '03:00'
- condition: zone
entity_id: person.nick_elliott
zone: zone.home
action:
- choose:
- conditions:
- condition: state
entity_id: binary_sensor.conexis_l1_the_current_status_of_the_door
state: open
- condition: state
entity_id: binary_sensor.conexis_l1_the_current_status_of_the_door_2
state: open
- condition: state
entity_id: binary_sensor.conexis_l1_the_current_status_of_the_door_3
state: open
sequence:
- service: notify.mobile_app_galaxy_s10
data:
message: Door(s) are unlocked!
title: Home Assistant
default: []
mode: single
I tried adding the line - condition: or after the line - choose:, and although HASS didn’t complain when I saved the YAML, when I next edited the automation, that line had gone again.
- conditions:
- condition: or
conditions:
- condition: state
entity_id: binary_sensor.conexis_l1_the_current_status_of_the_door
state: open
- condition: state
entity_id: binary_sensor.conexis_l1_the_current_status_of_the_door_2
state: open
- condition: state
entity_id: binary_sensor.conexis_l1_the_current_status_of_the_door_3
state: open
- choose:
- conditions: *duplicate key*
- condition: or
conditions: *duplicate key*
- condition: state *Missing property "entity_id"*
entity_id: binary_sensor.conexis_l1_the_current_status_of_the_door *bad indentation of a mapping entry*
state: open
- condition: state *can not read a block mapping entry; a multiline key may not be an implicit key*
entity_id: binary_sensor.conexis_l1_the_current_status_of_the_door_2 *bad indentation of a mapping entry*
state: open
- condition: state
entity_id: binary_sensor.conexis_l1_the_current_status_of_the_door_3 *bad indentation of a mapping entry*
state: open *bad indentation of a mapping entry*
(the Emphasis bits are the errors Studio Code Server reports in red when I try editing automations.yaml to match your suggestion).
Hold on - I didn’t realise white space and indenting was critical in yaml. I’ve tidied it up, using tab instead of space and fiddled with the indenting, and now the errors have gone. Not sure about Taras’s comment regarding on/off instead of open/closed, but perhaps I am getting closer!
So when referencing a binary_sensor’s state in a State Trigger or State Condition or Template Condition or etc, you use its true state values (on/off) not the ones displayed in the Lovelace UI due to its choice of device_class (Open/Closed for door).