Presence Detection Using Ping Help

I am pretty new to Home Assistant (HA) and Node Red. I am trying to get presence detection to work within HA using ping. Below is some additional information.

In my configuration.yaml file, I have the following;

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
#   base_url: example.duckdns.org:8123

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

# Device Tracker
device_tracker:
  - platform: ping
    track_new_devices: False
    consider_home: 0:05
    hosts:
     John: xxx.xxx.xxx.129
     Jenny: xxx.xxx.xxx.184

I checked the config file in HA and it parses fine. No errors.

In the known_devices file, I have the following after restarting HA.

john:
  hide_if_away: false
  icon:
  mac:
  name: john
  picture:
  track: true

jenny:
  hide_if_away: false
  icon:
  mac:
  name: jenny
  picture:
  track: true

In the known_devices.ymal file, nothing is filled in. Should this be the case?

Also, in the overview of HA, across the top, I do not have a round icon that say’s John or Jenny. How do you get that added as a tracker?

Thank you in advance for your help.

Do you mean the icon: mac: picture: etc?
Then yes, you can fill these in manually for aesthetic reasons or for more details.

At the point you are right now, have a look at your developer tools → states tab.
There should be entries like device_tracker.john and device_tracker.jenny
Like this:

Using those items you ll be able to set up your automations.

As for why they are not showing up at the top in circles, hit the 3 dot icon at the upper right and then the little pencil on your current tab.

In the following pop-up window there should be a badges tab.

There you can add your badges as you like.

Hope I understood your issue correctly and i helped out a bit :slight_smile:

Edit: Moreover, since i dont like those badges there, i have created a card using monster-card add-on, that only shows who is home currently.
I just noticed it’s been depreciated and you should use auto-entities instead.

Anyway, here’s my monstercard config, in case it helps:

card:
  columns: 6
  show_header_toggle: false
  type: glance
filter:
  exclude:
    - entity_id: device_tracker.google_maps_***
      state: home
  include:
    - entity_id: device_tracker.*
      state: home
show_empty: false
type: 'custom:monster-card'

I am guessing auto-entities will work similarly, the idea here is that the card will only show all the device_tracker.* items that are currently in the state:home.

To use this card, add a new card, hit custom, and replace the code in there with your code.

@krash

That seemed to work great, thank you so much! It seems the ping is an unreliable way to detect presence with a phone as it seems that it ‘disconnects’ from wifi when not in use. Is there a better way to do so?

Yeah, it’s not the greatest…
I only use it to detect if nobody or somebody is at home (1 of 5 phones should at least work :stuck_out_tongue:)

You could also look into network detection the other way around, as some routers offer HA components (mikrotik, Ubiquity and dd-wrt flashed routers for example), which should be a little more precise.

Other than that you could look into more battery-consuming built-in functionality of the android/ios apps (also see android’s ariela app), google maps or gps_logger location reporting.

You can always combine multiple sensors using bayesian sensor for extra precision. Never had the courage to make it work though :slight_smile:

@krash

Thank you for the info. I did try the router based tracking, but it does not appear HA supports my router. I use the eero hardware. So I guess my other option, as you stated, is to look into gps tracking. Which one would you suggest over the other? google maps or gps_logger?

Thanks!

I found that for my use, Google maps was much more straightforward and easy, with no noticeable bat. drain. I’d start there.

There are also some apps that get location off cell tower numbers and not GPS. I used one called Llama for Android a while back for in phone automations.
They just register the IDs of cell towers around your house and fire automations when you are connected to them. So they should not use any extra power.
I have not looked into it though in association with HA.