Ping automation with known state

Hi guys!

I want to make an automation webhook, with two actions. First, it should ping an IP (let’s say 192.168.0.100), and the second action should find out if the ping was good or without reply… if was good, in any way, I should receive a notification with the result from the ping action.

I don’t want to set a constant frequent ping checking, I just want a ping check only when I trigger the webhook, then to receive the result from ping.

Can someone explain me very good, step by step? I don’t understand very easy :smiley:

Thank you in advance!

Create a ping binary sensor for the device but give it a very long scan_interval (years), see the example in the link above. This effectively disables the sensor from updating.

Write your automation to trigger on your webhook, then in the actions use the homeassistant.update_entity service to update your ping sensor. Wait a short delay and then check the sensor attributes or use them in a notification.

Or just use a commandline sensor to run the ping command.

The output of most commands in linux/unix is 0 if successful or a number if unsuccessful. The failure code usually indicates an error number.

I deleted my comment before you replied because you should be able to use a value template to get the ping time.

Can you explain me how to do this? But step by step please, I’m 3 days new with home assistant :smiley:

But this binary sensor for ping… can’t be without update? I mean, with manual update only? :smiley:
And after I manage how to do this, and I will ping the host in one action, how can I call the variable response in the next action? How can I make something similar with:

If ping_192.168.0.100 = “Good”
do notification
else
do notification

I explained that in my post read it again. or implement Sparky Dave’s idea.

I have 2 command_line sensors with “scan_interval: 3600”.
Usually I need these sensors to be updated every hour.

But - I do not want to run these commands simultaneously.
What I can do is:

  1. Make “scan_interval: 99999999999” or smth.
  2. Create 2 automations: “Run command 1” & “Run command 2”.
    First automation must be triggered at XX:50:00, second one - at XX:55:00.
    Each automation has “homeassistant.update_entity” service call.

So, every sensor will be updated (i.e.command will be run) at its own time (and every 1 hour).
But - what about HA startup, I believed that every sensor is updated automatically on startup?