Presence detection with multiple devices & multiple trackers

This worked best for me: https://www.domoticz.com/wiki/Presence_detection_(Bluetooth_4.0_Low_energy_Beacon)

I don’t get it right. Would you post your solution? THX

Hi,

Thanks for sharing your scripts/automations.

I’ve been trying to apply your config to my setup but not following how you have don your device tracking.
From what I can see you have an automation is triggering two meta trackers (which act as a proxy for each person in your household) but you also have a bayesian sensor that is looking at the devices too. How are you using each of these in your setup ?

Thanks in advance

I currently use meta trackers for presence. I am experimenting with the Bayesian sensors and they are working well so far.

Wonderfull thanks for the reply. When you are ready, would be great to share how you end up getting on with the Bayesian sensor.

I have provided a detailed explanation for my Bayesian sensor here

1 Like

Sorry, one additional question. What are the devices that are device_tracker.alok_alok ? I see these are used as a part of the startup process but wondering their purpose and where they are created?

I want to do the same thing you are trying to do which is use simple device_tracker on two of the same routers. Did you ever get this to work?

Those are Life360 trackers.

Hello. I need hep with the automation.yaml. The presence detection. Apart from presence detection I also want the switch motion detect to work. I am not sure whether below is correct or wrong. I have check yamllint nothing wrong but nothing happen. My HA is 0.58.1 The switch.office_camera_motion is make from command line switch.

- id: away
  alias: "Away"
  initial_state: True
  hide_entity: False
  condition:
    condition: state
    entity_id: input_boolean.sunhome
    state: 'off'
  trigger:
    - platform: state
      entity_id: device_tracker.sun_iphone
      state: 'away'
      for:
        minutes: 1
    - platform: state
      entity_id: device_tracker.me_sun_iphone
      state: 'away'
      for:
        minutes: 1
    - platform: state
      entity_id: device_tracker.diana_diana_iphone
      state: 'away'
      for:
        minutes: 1
  action:
    - service: input_boolean.turn_on
      entity_id: input_boolean.sunhome
- id: home
  alias: "Home"
  initial_state: True
  hide_entity: False
  condition:
    condition: state
    entity_id: input_boolean.sunhome
    state: 'on'
  trigger:
    - platform: state
      entity_id: device_tracker.sun_iphone
      state: 'home'
      for:
        minutes: 1
    - platform: state
      entity_id: device_tracker.me_sun_iphone
      state: 'home'
      for:
        minutes: 1
    - platform: state
      entity_id: device_tracker.diana_diana_iphone
      state: 'home'
      for:
        minutes: 1
  action:
    - service: input_boolean.turn_off
      entity_id: input_boolean.sunhome
    - delay: '00:00:10'
    - service: homeassistant.turn_on
      entity_id: automation.away
- id: office_camera_motion_on
  alias: "Office Camera Motion On"
  initial_state: True
  hide_entity: False
  trigger:
    platform: state
    entity_id: input_boolean.sunhome
    from: 'off'
    to: 'on'
    for: 
      seconds: 5
  action:
    - service: switch.turn_on
      entity_id: switch.office_camera_motion
- id: office_camera_motion_off
  alias: "Office Camera Motion Off"
  initial_state: True
  hide_entity: False
  trigger:
    platform: state
    entity_id: input_boolean.sunhome
    from: 'on'
    to: 'off'
    for: 
      seconds: 5
  action:
    - service: switch.turn_off
      entity_id: switch.office_camera_motion
    - delay: '00:00:05'
    - service: homeassistant.turn_on
      entity_id: automation.office_camera_motion_on

Please format the codeblock properly or use hastebin.

Thank you for your advice. Please help with the automation above.

the states should be to: ‘away’ if you are using HA 5x I think

I use 0.58.1

I have tried both not_home and away.

From the docs…

automation:
  trigger:
    platform: state
    entity_id: device_tracker.paulus, device_tracker.anne_therese
    # Optional
    from: 'not_home'
    # Optional
    to: 'home'

Note from: or to: not state:

This presence detection not working. i check with yamllint and automation create and edit in HA. Although all device trackers list in are shown as away. The input_boolean won’t change the status according to the automation I pasted here.

- id: away
  alias: Away
  hide_entity: false
  condition:
  - condition: state
    entity_id: input_boolean.sunhome
    state: 'on'
  trigger:
  - entity_id: device_tracker.sun_iphone
    for:
      minutes: 1
    from: home
    platform: state
    to: not_home
  - entity_id: device_tracker.me_sun_iphone
    for:
      minutes: 1
    from: home
    platform: state
    to: not_home
  - entity_id: device_tracker.diana_diana_iphone
    for:
      minutes: 1
    from: home
    platform: state
    to: not_home
  action:
  - data:
      entity_id: input_boolean.sunhome
    service: input_boolean.turn_off
- id: home
  alias: Home
  hide_entity: false
  condition:
  - condition: state
    entity_id: input_boolean.sunhome
    state: 'off'
  trigger:
  - entity_id: device_tracker.sun_iphone
    for:
      minutes: 1
    from: not_home
    platform: state
    to: home
  - entity_id: device_tracker.me_sun_iphone
    for:
      minutes: 1
    from: not_home
    platform: state
    to: home
  - entity_id: device_tracker.diana_diana_iphone
    for:
      minutes: 1
    from: not_home
    platform: state
    to: home
  action:
  - data:
      entity_id: input_boolean.sunhome
    service: input_boolean.turn_on
  - delay: 00:00:10
  - data:
      entity_id: automation.away
    service: automation.turn_on

Another automation which works fine if I manually turn on the input_boolean from the previous post.

- id: office_camera_motion_on
  alias: Office Camera Motion On
  hide_entity: false
  trigger:
  - entity_id: input_boolean.sunhome
    for:
      seconds: 5
    from: 'on'
    platform: state
    to: 'off'
  action:
  - data:
      entity_id: switch.office_camera_motion
    service: switch.turn_on
- id: office_camera_motion_off
  alias: Office Camera Motion Off
  hide_entity: false
  trigger:
  - entity_id: input_boolean.sunhome
    for:
      seconds: 5
    from: 'off'
    platform: state
    to: 'on'
  action:
  - data:
      entity_id: switch.office_camera_motion
    service: switch.turn_off
  - delay: 00:00:05
  - data:
      entity_id: automation.office_camera_motion_on
    service: automation.turn_on

Couple of things, what state is the input_boolean in before any of the phones changes state to ‘away’?

What exact state is the device tracker displaying in the states table for the phone that is ‘away’?

States should be in quotes. So, you need to use to: 'home' or to: 'not_home'

1 Like