Current State of presence detection

Wait 5 minutes before setting the state away, set hoe as soon as any tracker is detected.
I found the ble tracker using PI3 and the gpsloger are the most reliable

    - alias: 'Set Anil Away'
  condition:
    condition: and
    conditions:
      - condition: state
        entity_id: input_boolean.anilhome
        state: 'on'
      - condition: state
        entity_id: device_tracker.pixel_bt #bluetooth
        state: 'not_home'
      - condition: state
        entity_id: device_tracker.ac37434ce86a #nmap
        state: 'not_home'
      - condition: or
        conditions:
        - condition: state
          entity_id: device_tracker.anils6_pixel #owntracks
          state: 'not_home'
        - condition: state
          entity_id: device_tracker.anils6_pixel
          state: 'away'
        - condition: state
          entity_id: device_tracker.anils6_pixel
          state: 'Work'

  trigger:
    - platform: state
      entity_id: device_tracker.pixel_bt
      state: 'not_home'
      for:
        minutes: 5
    - platform: state
      entity_id: device_tracker.anils6_pixel
      state: 'not_home'
      for:
        minutes: 5
    - platform: state
      entity_id: device_tracker.anils6_pixel
      state: 'Work'
      for:
        minutes: 5
    - platform: state
      entity_id: device_tracker.ac37434ce86a
      state: 'not_home'
      for:
        minutes: 5
  action:
    - service: homeassistant.turn_off
      entity_id: input_boolean.anilhome

- alias: 'Set Anil Home'
  condition:
    condition: state
    entity_id: input_boolean.anilhome
    state: 'off'
  trigger:
    - platform: state
      entity_id: device_tracker.pixel_bt
      state: 'home'
    - platform: state
      entity_id: device_tracker.anils6_pixel
      state: 'home'
    - platform: state
      entity_id: device_tracker.ac37434ce86a
      state: 'home'
    - platform: state
      entity_id: device_tracker.4cd5eae084d35a83
      state: 'home'
      for:
        seconds: 30
      
  action:
     service: homeassistant.turn_on
     entity_id: input_boolean.anilhome

(Thanks Zen for the tip for fromatting)

2 Likes