Automation conditions and or help

Hi guys,

I have the following automation that triggers my sons light, letting him know it’s okay to come and wake me and his mum up.

#Alexander's morning clock
- alias: okay to get up
  hide_entity: false
  trigger:
    - platform: time
      at: '06:45:00'
  condition:
    condition: and
    conditions:
    - condition: state
      entity_id: 'binary_sensor.workday_sensor'
      state: 'on'
    - condition: or
      conditions:
    - condition: state
      entity_id: alarm_control_panel.yale_smart_alarm
      state: 'armed_home'
    - condition: state
      entity_id: alarm_control_panel.yale_smart_alarm
      state: 'disarmed'
  action:
   - service: light.turn_on
     entity_id: light.bedroom_light
     data:
       rgb_color: [0,255,88]
       brightness: 130

now this worked well when I had the condition “binary_sensor.workday_sensor” ‘on’ AND mine and my wife’s phones on the wifi.

The issue was sometimes it would fail to trigger as our phones were off the wifi (iphone sleep mode) at 6.45.

when HA added Yale smart alarm I thought it would be better to base the condition on if the alarm is “Part alarmed” (were in bed) or “disarmed”.

the thing is it won’t work, could someone please tell me where I’m going wrong

Could you be more specific on what you mean by “it won’t work”?

But jut as a guess I think your indents are off.

Try this:

condition:
  condition: and
  conditions:
  - condition: state
    entity_id: 'binary_sensor.workday_sensor'
    state: 'on'
  - condition: or
    conditions:
      - condition: state
        entity_id: alarm_control_panel.yale_smart_alarm
        state: 'armed_away'
      - condition: state
        entity_id: alarm_control_panel.yale_smart_alarm
        state: 'disarmed'
1 Like

Sorry you’re right (my bad)

it doesn’t trigger the light at the set time

I’ve seen problems using the and condition at the top level. Just an FYI, if you omit the and condition from the list, it treats all conditions as being anded together.

Also, I noticed that your or condition didn’t have the correct indentation.

#Alexander's morning clock
- alias: okay to get up
  hide_entity: false
  trigger:
    - platform: time
      at: '06:45:00'
  condition:
    - condition: state
      entity_id: 'binary_sensor.workday_sensor'
      state: 'on'
    - condition: or
      conditions:
        - condition: state
          entity_id: alarm_control_panel.yale_smart_alarm
          state: 'armed_away'
        - condition: state
          entity_id: alarm_control_panel.yale_smart_alarm
          state: 'disarmed'
  action:
   - service: light.turn_on
     entity_id: light.bedroom_light
     data:
       rgb_color: [0,255,88]
       brightness: 130
1 Like

thanks guys,

also want to add it only states “armed_away” as I was testing this today at work, it’s normally “armed_home”