Issue with Automation OR condition

Hi folks,

I cant seem to figure this one out and to me it looks like there is an issue with the OR condition used.

The trigger is time @ 12:30 am and the condition is alarm armed to Home or Away, its away set to Home at this time at night generally,

Did I set this up wrong?

alias: House shutdown - Check state
description: >-
  After shutdown home runs, this will run after to see if all devices where shut
  off but only if house is armed
trigger:
  - platform: time
    at: '00:30:00'
condition:
  - condition: device
    device_id: adeebb8492734f1d27e02f4e8afdf4eb
    domain: alarm_control_panel
    entity_id: alarm_control_panel.dublin_alarm
    type: is_armed_home
  - condition: or
    conditions:
      - condition: device
        device_id: adeebb8492734f1d27e02f4e8afdf4eb
        domain: alarm_control_panel
        entity_id: alarm_control_panel.dublin_alarm
        type: is_armed_away
action:
  - type: turn_off
    device_id: b704b07d8281b60f52d5ea66c89b6ec7
    entity_id: light.switchlinc_dimmer_30_9e_a8
    domain: light
  - type: turn_off
    device_id: 3214890744d08140dece4afedbced48a
    entity_id: light.switchlinc_dimmer_43_e0_aa
    domain: light
mode: single

Trace:
Stopped because a condition failed at January 28, 2022, 12:30:00 AM (runtime: 0.00 seconds

Try:

condition:
  condition: or
  conditions:
  - condition: device
    device_id: adeebb8492734f1d27e02f4e8afdf4eb
    domain: alarm_control_panel
    entity_id: alarm_control_panel.dublin_alarm
    type: is_armed_home
  - condition: device
    device_id: adeebb8492734f1d27e02f4e8afdf4eb
    domain: alarm_control_panel
    entity_id: alarm_control_panel.dublin_alarm
    type: is_armed_away
1 Like

zoogara’s reply should fix the problem you reported.


I just want to take a moment to show the difference between using Device Conditions and Device Actions (the default choice when using the Automation Editor) and a Template Condition in shorthand notation and a simple service call.

alias: House shutdown - Check state
description: >-
  After shutdown home runs, this will run after to see if all devices where shut
  off but only if house is armed
trigger:
  - platform: time
    at: '00:30:00'
condition: "{{ states('alarm_control_panel.dublin_alarm') in ['armed_home', 'armed_away'] }}"
action:
  - service: light.turn_off
    target:
      entity_id:
        - light.switchlinc_dimmer_30_9e_a8
        - light.switchlinc_dimmer_43_e0_aa
mode: single
2 Likes

Thus spoke the true coder… Very neat.

Thanks for the feedback folks, I have gone for the 123 Taras suggestion as I haven’s seen conditions approached this way before, ill know tomorrow if it works and will let you know.

Cheers!

Copy-paste this into the Template Editor and experiment with it:

{{ 'iguana' in ['cat', 'bat', 'iguana', 'rat'] }}

The template is asking the question: Is the string “iguana” a member of the following list containing four strings? If it is a member of the list, the result is true otherwise false.

In this example, is 42 in a list containing a mix of strings and numbers? It is, so the result will be true.

{{ 42 in [17, 'bat', 9, 'igloo', 42, 11] }}

Last example, this template checks if the state value of alarm_control_panel.dublin_alarm is in the list containing two strings.

{{ states('alarm_control_panel.dublin_alarm') in ['armed_home', 'armed_away']
1 Like

Thanks all, that worked perfectly.