Run Automation B only if Automation A triggered in the last X minutes?

I have an automation that turns on our room light if my 2 year olds door opens and no ones around, using motion sensors.

Once those lights come on at 3 am its annoying trying to get them off when groggy. I have another motion sensor in bedroom so I thought if lights are on, and automation.a has triggered in last 10
Minutes, then bedroom becomes occupied (motion sensor).

I have not found anything like this searching so my feeble attempt below.

alias:  Parents Are Up Dim Lights
description: Dim the lights if we have just gotten up
trigger:
  - type: occupied
    platform: device
    device_id: 3684e0fc6af82010bfcf8a990288e765
    entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_9f1c7502_occupancy
    domain: binary_sensor
condition:
  - condition: state
    entity_id: automation.notify_me_if_nias_door_opens_after_8
    state: <10 minutes ago
    attribute: last_triggered
action:
  - service: script.dim_bedroom
    data: {}
mode: single

This is automation A for reference.

alias: Notify me if Babies door opens
description: ''
trigger:
  - type: opened
    platform: device
    device_id: fdb71c5b8b154ce38fec5ce2fb5cd9e0
    entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_on_off
    domain: binary_sensor
condition:
  - condition: and
    conditions:
      - type: is_not_occupied
        condition: device
        device_id: 193c0d5533474c1ea3f6377b29f9c316
        entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_occupancy
        domain: binary_sensor
      - type: is_not_occupied
        condition: device
        device_id: 67e32726f1a71592f882e88d87d7ccf0
        entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_d9ec5302_occupancy
        domain: binary_sensor
action:
  - type: turn_on
    device_id: 12621a7eac6e4b7bbcaa7e31d32a9e77
    entity_id: light.sengled_e11_g13_d5320c03_level_on_off
    domain: light
    brightness_pct: 100
    flash: short
  - type: turn_on
    device_id: 3c3bc9fc8e564d9e831ec6f9ad42b7ca
    entity_id: light.sengled_e11_g13_fe6e0b03_level_on_off
    domain: light
    brightness_pct: 100
    flash: long
  - type: turn_on
    device_id: 212cf47316d84a67975df77801b21b90
    entity_id: light.sengled_e11_g13_612f0b03_level_on_off
    domain: light
    brightness_pct: 100
    flash: long
  - service: notify.smtp_both_phones
    data:
      message: Go Get That Baby.
      title: Door Open
mode: single

This condition should work based on what you have above. Not sure if your trigger is working or not…

condition:
  condition: template
  value_template: "{{ (as_timestamp(now()) - as_timestamp(states.automation.notify_me_if_nias_door_opens_after_8.attributes.last_triggered)) < 600 }}"
1 Like

Thanks! I didnt know what to search exactly and finally found something below as you were typing.

Thanks a lot for reassuring me. I noticed in that post the guy says 2.5 hours but writes 220 and it was confusing the hell out of me, thought it should be 600 and you reaffirmed that.

How about having automation A start a timer for length of time X, and then have automation B check on the state of the timer as a condition.