My aqara door sensors do not trigger automation

Trying to make some alarm automations with my Aqara door sensors, but it will not trigger the automations and I can not understand why. Automations triggers when I do them directly from HA, but when I open door nothing happens.

Hopefully some of you can see what I am doing wrong here.

- id: '1595944448528'
  alias: Test alarm NYTT panel
  description: test av alarm
  trigger:
  - entity_id: binary_sensor.openclose_3
    from: 'off'
    platform: state
    to: 'on'
  condition:
  - condition: state
    entity_id: alarm_control_panel.alarm
    state: arm_home
  - condition: or
    conditions:
    - condition: state
      entity_id: alarm_control_panel.alarm
      state: arm_away
  action:
  - data: {}
    entity_id: alarm_control_panel.alarm
    service: alarm_control_panel.alarm_trigger
  mode: single
- id: '1595945146903'
  alias: Trigger alarm
  description: ''
  trigger:
  - entity_id: alarm_control_panel.alarm
    platform: state
    to: triggered
  condition: []
  action:
  - data:
      message: Stue åpnet!
      title: ALARM STUE!
    service: notify.mobile_app_iphone
  mode: single

Don’t understand your condition on the first one. The way it’s indented suggests that the overall condition is always false, as the arm_home is not under the condition: or but at the top level (see docs).

I suspect you mean:

  condition:
    condition: or
    conditions:
      - condition: state
        entity_id: alarm_control_panel.alarm
        state: arm_home
      - condition: state
        entity_id: alarm_control_panel.alarm
        state: arm_away

…and with 0.113 you can do this instead:

  condition:
    condition: state
    entity_id: alarm_control_panel.alarm
    state:
      - arm_home
      - arm_away

Have you checked that the state of the sensor is working via Developer Tools / States?

2 Likes

Thanks, changed the code now. Also checked the sensor, and it shows on when door is opened, and off when door is closed. But still does not trigger the automation.

My new code is now:

- id: '1595944448528'
  alias: Test alarm NYTT panel
  description: test av alarm
  trigger:
  - entity_id: binary_sensor.openclose_3
    from: 'off'
    platform: state
    to: 'on'
  condition:
  - condition: or
    conditions:
    - condition: state
      entity_id: alarm_control_panel.alarm
      state: arm_away
    - condition: state
      entity_id: alarm_control_panel.alarm
      state: arm_home
  action:
  - data: {}
    entity_id: alarm_control_panel.alarm
    service: alarm_control_panel.alarm_trigger
  mode: single
- id: '1595945146903'
  alias: Trigger alarm
  description: ''
  trigger:
  - entity_id: alarm_control_panel.alarm
    platform: state
    to: triggered
  condition: []
  action:
  - data:
      message: Stue åpnet!
      title: ALARM STUE!
    service: notify.mobile_app_iphone
  mode: single

Can you post a screenshot of Dev Tools / States for the alarm please? Are you certain it’s in one of those two modes when you open the door?

I am not sure, pretty newbie on HA. So I am thankful for all help I can get.

Screenshots:

The automations will not trigger with the alarm in the disarmed state due the conditions: it will only trigger in the armed_home or armed_away states.

Try setting it to one of those states and then open the door; or alternatively, temporarily change one of the condition states to disarmed.

1 Like

Thanks Troon. That was the problem, I used arm_home etc. instead of armed_home as you wrote. Thank you for all your help.

1 Like

Well spotted. Sorry I didn’t notice that simple typo in your code.

1 Like