Presence detection with multiple devices & multiple trackers

Hi Fellow HA Users!
I’m quite new with it, but I learn more day after day. I hope, I can post my problem here, because I think, it’s related to the topic’s address:
I’ve set up HA with my phone (Asus Padfone S, android 6, stock rom) and Owntracks 4 days ago. It worked untill today. I’ve set up my wife’s phone too (Samsung S5, stock rom. Owntracks) with different username, which I have configured together with mine in mosquitto 4 days ago. Today, I just installed the app, and set up the connection. After this, my avatar disappeared from the map, it showed only my wife’s icon for a few minute. After that, the map only shows the zones.
I’ve tried to send ‘null’ messages to the topics, removed all the know devices. nothing changed.
HA gets the coordinates, my batteri sensor shows the battery %, but the map is empty.
Do you have any suggestions?
Thank you!

If you are ‘home’ the map doesn’t show your icon.

umm this link doesn’t seems to work :frowning:

I have updated the link.

1 Like

@mchinery I am trying to do the same thing - can you share your solution that you used with the template sensor?

Thanks!

Tom

I did not implement it in the end. I changed presence detection to Bluetooth only and this has proved very reliable.

I’ve tried editing your code but I’m just getting started with home assistant and being a real linux newb I seem to get stuck…
So i copied your code an added the devices that I want to track (my iphone, wife’s iphone wit router and with owntracks). But it doesn’t seem to do anything. Probably a newby mistake. Could you please look at the code?

# Automation Update
- alias: 'Update Available Notifications'
  trigger:
    platform: state
    entity_id: updater.updater
  action:
    service: notify.notify
    data:
      message: 'Update for Home Assistant is available.'

###############################################################
## Presence
################################################################
- id: update_meta_tracker
  alias: "Update Device Meta Tracker"
  initial_state: 'on'
  trigger:
    # Delayed action for router-based and Owntracks trackers that are not 100% reliable
    - platform: state
      entity_id:
        - device_tracker.iphone1
        - tracker.owntracks1
        - device_tracker.iphone2
        - device_owntracks2
      to: 'not_home'
      for: '00:07:00'
    - platform: state
      entity_id:
        - device_tracker.iphone1
        - tracker.owntracks1
        - device_tracker.iphone2
        - device_owntracks2
      to: 'home'
  action:
    - service: python_script.meta_device_tracker
      data_template:
        entity_id: '{{trigger.entity_id}}'
    - service: logbook.log
      data_template:
        name: "Tracker updated: "
        message: >-
          {%- for state in states if state.entity_id == trigger.entity_id -%}
            {{ state.attributes.friendly_name }} is {{ trigger.to_state.state }}.
          {%- endfor -%} 

This is my view (playing arround with it). But I don’t understand how I can merge the two trackers?
bewoners:
name: Super personen
entities:

  • device_tracker.iphone1
  • device_tracker.iphone2

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