Use 2 motions for On/Off cannot seem to get it work in one

Could someone should me how to put these to Automations in one? I use several ON and OFF automations because for some reason it doesn’t work a 100 % when i try to put it in one.

This is one of my automations (two exactly :p)

The ON one.

alias: 01_Hal - Motion AAN
description: ""
trigger:
  - type: motion
    platform: device
    device_id: 0344c938b84bc3274da0590fb434651a
    entity_id: fa0bf10cd5da20b5826af1e202ba25c0
    domain: binary_sensor
    id: Motion-detected
condition: []
action:
  - if:
      - condition: trigger
        id: Motion-detected
      - condition: and
        conditions:
          - condition: device
            type: is_off
            device_id: 1eb269cd591b1fc7f387bee6c06f03a0
            entity_id: 85fe4bd8a5c1bde28c6a6574ffe42d60
            domain: light
    then:
      - type: turn_on
        device_id: 1eb269cd591b1fc7f387bee6c06f03a0
        entity_id: 85fe4bd8a5c1bde28c6a6574ffe42d60
        domain: light
        brightness_pct: 80
    else: []
mode: restart

The OFF one

alias: 01_Hal - Motion UIT
description: ""
trigger:
  - type: no_motion
    platform: device
    device_id: 0344c938b84bc3274da0590fb434651a
    entity_id: fa0bf10cd5da20b5826af1e202ba25c0
    domain: binary_sensor
    id: Motion-detected
    for:
      hours: 0
      minutes: 2
      seconds: 0
condition: []
action:
  - if:
      - condition: trigger
        id: Motion-detected
    then:
      - type: turn_off
        device_id: 1eb269cd591b1fc7f387bee6c06f03a0
        entity_id: 85fe4bd8a5c1bde28c6a6574ffe42d60
        domain: light
    else: []
mode: restart
alias: 01_Hal - Motion AAN
description: ""
trigger:
  - type: motion
    platform: device
    device_id: 0344c938b84bc3274da0590fb434651a
    entity_id: fa0bf10cd5da20b5826af1e202ba25c0
    domain: binary_sensor
    id: Motion-detected
  - type: no_motion
    platform: device
    device_id: 0344c938b84bc3274da0590fb434651a
    entity_id: fa0bf10cd5da20b5826af1e202ba25c0
    domain: binary_sensor
    id: No Motion
    for:
      hours: 0
      minutes: 2
      seconds: 0
condition: []
action:
  - if:
      - condition: trigger
        id: Motion-detected
    then:
      - service: light.turn_on
        data: 
          entity_id: 85fe4bd8a5c1bde28c6a6574ffe42d60
          brightness_pct: 80
    else:
      - service: light.turn_off
        data: 
          entity_id: 85fe4bd8a5c1bde28c6a6574ffe42d60
mode: restart
1 Like