Android Tasker routine to warn if home WiFi is not functioning correctly

Tasker app screen showing Task Edit at top with name WiFi Test. Below that are 4 numbered actions starting at 1 with an action called Variable Set with the variable name %HA_PING to 0. Then action 2 is called Ping and says Host 192.168.1.212 number 2 (for run two ping tests) and further says If %HOME equals 1. Action 3 is called Notify with a title Check WiFi if %HA_PING equals 0 and %HOME equals 1. Action 4 is called Say and has the text "Check Home WiFi" and only if the condition %HOME equals 1 and %HA_PING equals 0.

Been experiencing a bit of an issue the last month with everything seemingly on and connected, but my Chromecast device would not connect across Wi-Fi today, and sometimes my wife says her phone is not connecting, and I’d have to reboot the home router. So, I decided to write a small routine using the Tasker app to check every 10 mins whether my phone can ping the Home Assistant server over the home LAN. If so, all good, but if not pop up an alert. It only runs this while I’m actually home. If I happen to be at home, but using mobile data, then it will still give an error as the mobile data won’t reach the internal IP address.

I’m using the Auto Location 3rd party app for Tasker, which provides more reliable geofencing status, but one could also use the standard Tasker location Profile. Basically, either of these will set a variable called %HOME to 1 if I’m at home, or to 0 if I’m away from home. Below is the Profile that triggers this: If at home it runs task Set Is Home, and if not at home (Exit action) it will run Set Not Home.

Screenshot 20240427 161417 Tasker

The actions are just simple ones that set a variable called %HOME and set it to 1 or 0.

Screenshot 20240427 161511 Tasker
This action sets a variable called %HOME = 1
Screenshot 20240427 161544 Tasker
This action sets a variable %HOME = 0 and also just says audibly I have left home.

The other rigger under Profiles is a time one which just runs the WiFi Test task every 10 minutes.

Screenshot 20240427 161452 Tasker
Profile to run a task called WiFi Test every 10 mins

The Wifi Test task that runs every 10 minutes does the following:
* Creates and sets a variable called %HA_PING = 0. You can call it anything as maybe you want to ping the home router instead. We set this to 0 to check if the ping test then changes it, and to ensure it does not contain some non-zero value from a previous ping action.
* The Ping action is added and I set it to the internal IP address of my Home Assistant server. I said it can try 2 pings, and I also set a condition for IF %HOME = 1. In other words, only run this action if at home. If I did not add the condition, it would run when I’m away, and then give the ping error. One of Ping action’s fields is for Average Result Variable, and in there I just put %HA_PING. In other words, if there is an average ping result obtained, then set the variable %HA_PING to that variable (it will no longer be a 0).
* I added a Notify action but set two conditions to check before notifying: I must be at home, and the %HA_PING must equal 0. If the ping was successful, it sets %HA_PING to whatever the average result was. If it was not successful, the original %HA_PING is still 0.
* I just added an audible alert too, also based on same conditions that I must be home and the ping test did not set %HA_PING to above 0.

Screenshot 20240427 161601 Tasker
The WiFi Test task

To see what it is does under various scenarios, you can view the variable values in the Tasker app in the VARS tab, as shown below. Below we can see both variables after a run, and they show I am at home, and the last average ping response was 29.773ms.

Screenshot 20240427 161631 Tasker

The Tasker app is extremely powerful and fun to use and you can automate so many things with it.