Automation does not run multiple times

I have two door sensors (aqaras). I have one attached to my back door and one attached to my aircon (it is a wall hung unit). I want to get a notification (via the home assistant ios app on my phone) when the aircon is on (ie the aircon sensor is “open”) and the back door is open.

It ran the first time when I tested it I received the notifications. Even though I have closed both sensors and opened them again, I have yet to receive any other notifications. Any ideas what I am doing wrong? Below is my automation script:-

- id: '1635414627791'
  alias: Notify when door is open and aircon is on
  description: ''
  trigger:
  - type: opened
    platform: device
    device_id: 335c4df678f50a2891b76107ad9eade4
    entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_acbc7507_on_off
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 30
      milliseconds: 0
    id: DoorOpenTooLong
  - type: opened
    platform: device
    device_id: 19339859d4d94085b07f9088b4e3d301
    entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_on_off
    domain: binary_sensor
    id: AirConOn
  condition:
  - condition: and
    conditions:
    - condition: trigger
      id: DoorOpenTooLong
    - condition: trigger
      id: AirConOn
  action:
  - service: notify.mobile_app_the_iphone
    data:
      message: Aircon is on and the door is open
      title: CLOSE THE GOD DAMN DOOR
  mode: queued
  max: 10

Do you somehow set your sensor to “closed” again?
Alot of door sensors only register the opening and not the closing, so its more like a button, than a switch.

I can see in the app when the sensor is open or closed it changes state.

Perfect, then some else need to help you with the automation, because I do those in Node-Red :slight_smile:

I would make this much simpler by having one trigger of the door opening and have one condition of the AC being on.

Your automation won’t work as you are listing conditions as requiring both triggers, so unless they both trigger at exactly the same time it will never pass the and conditions.

Also as a side note conditions are always ‘and’ by default so you don’t need the ‘and’ just list the conditions.

@WallyR can you show me an example of how to configure this in node red easily?

As already mentioned your conditions can never be true since the automation is only triggered by one of the sensors.

Additionally to your triggers you need to check in a condition if both sensors are on.

condition:
  - condition: state
    entity_id: 'binary_sensor.lumi_lumi_sensor_magnet_aq2_acbc7507_on_off'
    state: 'on'
  - condition: state
    entity_id: 'binary_sensor.lumi_lumi_sensor_magnet_aq2_on_off'
    state: 'on'

Here is an example how it can be done:

First node check if the door is opened, but do not start the flow untill 30 seconds have passed. If the door is closed during those 30 seconds, then the flow is cancelled again.
If the 30 seconds pass with a door open, then the next node checks the status of the AC and if that is on, then the last node is reached, which then sends the notification.

[{“id”:“7e0ecc935767dd5a”,“type”:“server-state-changed”,“z”:“c95455d8071012f0”,“name”:“Door being opened”,“server”:“c796e8c1333341fa”,“version”:3,“exposeToHomeAssistant”:false,“haConfig”:[{“property”:“name”,“value”:""},{“property”:“icon”,“value”:""}],“entityidfilter”:“binary_sensor.lumi_lumi_sensor_magnet_aq2_acbc7507_on_off”,“entityidfiltertype”:“exact”,“outputinitially”:false,“state_type”:“str”,“haltifstate”:“opened”,“halt_if_type”:“str”,“halt_if_compare”:“is”,“outputs”:2,“output_only_on_state_change”:true,“for”:“30”,“forType”:“num”,“forUnits”:“seconds”,“ignorePrevStateNull”:false,“ignorePrevStateUnknown”:false,“ignorePrevStateUnavailable”:false,“ignoreCurrentStateUnknown”:false,“ignoreCurrentStateUnavailable”:false,“outputProperties”:[],“x”:180,“y”:160,“wires”:[[“1f8a9d0da8dc8275”],[]]},{“id”:“1f8a9d0da8dc8275”,“type”:“api-current-state”,“z”:“c95455d8071012f0”,“name”:“Check state of AC”,“server”:“c796e8c1333341fa”,“version”:2,“outputs”:2,“halt_if”:“opened”,“halt_if_type”:“str”,“halt_if_compare”:“is”,“entity_id”:“binary_sensor.lumi_lumi_sensor_magnet_aq2_on_off”,“state_type”:“str”,“blockInputOverrides”:false,“outputProperties”:[],“override_topic”:false,“state_location”:“payload”,“override_payload”:“msg”,“entity_location”:“data”,“override_data”:“msg”,“x”:450,“y”:140,“wires”:[[“414d985152977f66”],[]]},{“id”:“414d985152977f66”,“type”:“api-call-service”,“z”:“c95455d8071012f0”,“name”:“Send Notification”,“server”:“c796e8c1333341fa”,“version”:3,“debugenabled”:false,“service_domain”:"",“service”:“notify.mobile_app_tablet”,“entityId”:"",“data”:"{“message”:“The garage door has been open for 10 minutes.”,“title”:“Your Garage Door Friend”}",“dataType”:“json”,“mergecontext”:"",“mustacheAltTags”:false,“outputProperties”:[],“queue”:“none”,“x”:690,“y”:100,“wires”:[[]]},{“id”:“c796e8c1333341fa”,“type”:“server”,“name”:“Home Assistant Test”,“version”:1,“legacy”:false,“addon”:false,“rejectUnauthorizedCerts”:true,“ha_boolean”:“y|yes|true|on|home|open”,“connectionDelay”:true,“cacheJson”:true,“credentials”:{“host”:“http://localhost:8123”,“access_token”:""}}]