Pinging my Phone

Hi, I know there are NMAP and PING integrations that check at every X seconds if a device is in the network. How, however, can I only once and per request check one IP?

use case: I have a motion sensor at the entrance. only when activated shall it quickly ping my phone if reachable, i.e. at home, and then either turn on my TV or the alarm system depending on the response.

For all the presence detections via HA app etc, there is usually a delay until the sensor gets updated, also I cocnsider it a waste of energy to constantly ping.

hi,
Command line Switch - Home Assistant (home-assistant.io)

You can probably set the update interval on a week or month, then use the update_entity service call to ping when you need.

1 Like

Or, use the companion app where you will have a sensor to see to which SSID you are connected to, or even better: set up a home zone, but I think this is what you are referring to as being slow.

If you have a device tracker, you can also send a special push notification to force a location update, or you can call device_tracker.see.

1 Like

that sounds promising. I do have a device tracker for my phone, but as said before it sometimes hasn’t updated yet when I open the door and hence triggers the alarm. How do I call the command? is it a service, or an entity?

It’s a service: Device Tracker.

This is what I do e.g. on HA start-up, but also some other places, similar to your check to avoid a false positive:

- alias: "See Mobile Devices"
  trigger:
    - platform: homeassistant
      event: start
  action:
    # https://companion.home-assistant.io/docs/notifications/notification-commands#request-location-updates
    - service: notify.mobile_app_ceres
      data:
        message: "request_location_update"

I thought I had a device_tracker.see somewhere, but can’t find it now. Maybe I tried that first and then replaced it with what I have above. Either way, for this or the above, you’ll need zones to be set up.

Maybe also note this option: Proximity - Home Assistant (home-assistant.io). I have a test sensor running using this, but haven’t made any changes to use it, but technically you can do some things when you get near a zone (since you also have a direction). This is nice, because you don’t have to set up a second “phantom” zone that’s larger than your home zone (I’ve seen some people do this, and of course, it works).

1 Like

thats cool, thanks!
i have disabled gps on my app to safe battery, so zones won’t work for me. Unfortunately, I also don’t see the device tracker in my development tools → services section, i only have it as an entity, but without the update option.

I tried the “Home Assistant Core Integration: Update entity” Service on my device tracker, but got another false alarm just this morning. “status unknown”

You’ll need to show your config for all of this. Also check your logs. There’s quite possibly an error telling you it couldn’t update the ping sensor (because it timed out). You can also check the sensor’s history.