Script to hibernate a PC

Here is what I want to do in a script:

a) Publish MQTT command via IoTLink to hibernate a host
b) Wait couple of minutes
c) Ping the host to see if it is alive
d) If host is alive, go to a), repeating the loop 5 times

I have written all steps except c). How do I accomplish c) without creating a ping binary sensor? It is my understanding that the ping binary sensor would keep pinging the host every 5 minutes 24x7, thus generating unnecessary network traffic.

Thanks,
Arun

I Use this to hibernate my PC. Just call a rest command. works every time. GitHub - karpach/remote-shutdown-pc: Remote Shutdown Manager is a windows application, which gives an ability to shutdown, suspend, hibernate PC or turn screen off using HTTP GET request.

I am using this to execute any type of remote commands;

https://iotlink.gitlab.io/

I did say that I use IoTLink to send hibernate command but I need to ping the PC on demand to make sure that it did go to hibernate. Sometimes, Windows background processes prevent hibernation/suspend and there is a need to repeat sending the hibernate/suspend command. The idea is to make sure that the PC is indeed in hibernation. This is what the question is about.

I guess the title of the question should have read how to ping a host on demand.

Thanks…

There is a simpler program called Sleep on LAN:

http://www.ireksoftware.com/SleepOnLan/

But the issue is NOT how to put PC to sleep, but to VERIFY that it actually went into suspend/hibernate. As I said, I should have asked “how to ping a host on demand”.

Thanks,