Multiple Ping Device Tracker Instances

Hi, I’m looking to see if it’s possible to set up multiple device tracker instances of the same platform with different intervals. Currently, I have a configuration for my family that works well, but we have some extended family that I’d (or maybe they’d :smiley:) rather not install the home assistant app on their phones.

For my immediate family, I have pretty tight timings and use automations to lock up shortly after departure. However, for the extended family, I primarily just want to make sure that if me or my wife leave and one (or more) of them are home, it won’t turn off the lights and lock up. They all know to manually lock up if they leave while we are still out, so I’m not worried about looser timings to prevent false departures on their iphones (which constantly switch between home and away).

I tried adding two separate ping entries with different configurations, but it doesn’t see to respect the longer interval, i.e. nicoles_phone_ping was still swapping back and forth every 5 minutes, despite consider_home being set to 15 minutes.

- platform: ping
  interval_seconds: 30
  consider_home: 120
  hosts:
    chris_phone_ping: 10.10.18.50
    jennys_phone_ping: 10.10.18.51
- platform: ping
  interval_seconds: 60
  consider_home: 900
  hosts:
    nicoles_phone_ping: 10.10.18.53

Is that not possible? I did restart home assistant after adding the second ping instance, and the logs didn’t seem to complain at all, so I’m not sure if it’s just not supported and silently discards the extra config or not.

I thought about adding the other configuration via nmap, but currently nmap tracker is broken.

consider_home is not a configuration option for the ping integration.

1 Like

Oh wow, haha! I had been running nmap tracker for a long time and recently had to switch away once namp broke as of 2023.2 (nmap fails to obtain mac address in 2023.2.x · Issue #87623 · home-assistant/core · GitHub). I had basically ported over the configuration, just changing the platform and I guess never realized the setting didn’t exist. Thanks for the info!

You could feed your ping binary sensors to template binary sensors and use the delay_off option for that integration.

I didn’t think template binary sensors could be connected to person entities though (even with a presence device class). I thought it needed to basically be a template device tracker, which doesn’t exist, right?

Yeah you’re right. I don’t use the person integration so I missed that. You can do it with an automation though. Using the ping binary sensor (not ping tracker) and this automation:

alias: Presence Chris Phone Ping
trigger:
  - platform: state
    entity_id: binary_sensor.chris_phone_ping
    to: 'on'
  - platform: state
    entity_id: binary_sensor.chris_phone_ping
    to: 'off'
    for: 120
action:
  - service: device_tracker.see
    data:
      dev_id: chris_phone_ping
      location_name: "{{ 'home' if trigger.to_state.state == 'on' else 'not_home' }}"
mode: queued
max: 10

The device_tracker.see service will create the tracker based on the dev_id, so device_tracker.chris_phone_ping

That’s pretty painless. Thanks again for the help with this!

1 Like

Hi @tom_l the automation doesn’t seem to work running into a error:

Executed: November 7, 2023 at 10:03:16 AM
Error: Error rendering data template: UndefinedError: 'dict object' has no attribute 'to_state'

for reference here is the automation, which is basically copy and paste

alias: Presence PersonX Phone Ping
description: Updates a device_tracker sensor for PersonX based on pinging the phone
trigger:
  - platform: state
    entity_id: binary_sensor.personx_phone_ping
    to: "on"
  - platform: state
    entity_id: binary_sensor.personx_phone_ping
    to: "off"
    for: 120
condition: []
action:
  - service: device_tracker.see
    data:
      dev_id: personx_phone_ping
      location_name: "{{ 'home' if trigger.to_state.state == 'on' else 'not_home' }}"
mode: queued
max: 10

the binary_sensor is working and I can see that the state is set to on

You tested this by triggering it manually, which skips the triggers so there is no trigger.to_state variable.

Test it by changing the ping sensor state in developer tools → states. Or by turning off/on your phone’s wifi.

thank you! that did it