Ping as automation action


does anyone knows is there possibility to use ping as an action in automation?
What I’m trying to accomplish is to check whether a person is home/not_home (by pinging cellphone) when door opens.

Create a binary_sensor, eg.

  - platform: ping
    name: binarysensorrflink
    count: 2

Then create an automation that triggers on state change of that sensor.

Wouldn’t that poll the device every 5 minutes (default scan interval)?

You can adjust the ping interval, but then maybe it will not see if the person arrives home and opens the door.

I see where are you going.
So, basically, I can’t use binary_sensor/device tracker ping as it is unreliable. iPhones have tendency to save battery and I guess put wifi to sleep when idling.
So my solution was to trigger device_tracker/sensor update only on door opening. That would be beneficial in two ways:

  • I wouldn’t have to ping devices all the time
  • reliable info on devices location

I saw there is shell_command that can execute ping in automation action. Since there is a little documentation around that, does anyone know how to update sensor/device_tracker based on shell_command ping output?