Automatically disable mobile hotspot when no device is connected, using Tasker I am trying to create a task which automatically disables mobile hotspot (tethering) when no device is connected. 
I successfully created similar tasks for bluetooth and wifi, however wifi mobile hotspot I seem not to able to get information on how to check if there are clients currently connected or when no client is connected.
I researched a bit, a got a hint that this code :

ip neigh show dev wlan0  | grep -i -e reachable -e delay | grep 


can give information on clients currently connected to hotspot.

This was the output in terminal:

u0_a209@hws8701:/ $ su
 -i -e reachable -e delay | grep -o' ..\:..\:..'                              &lt;
unknown option --  usage: grep [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZz] [-A num] [-B num] [-C[num]]
        [-e pattern] [-f file] [--binary-files=value] [--color=when]
        [-e pattern] [-f file] [--binary-files=value] [--color=when]
        [--context[=num]] [--directories=action] [--label] [--line-buffered]
        [pattern] [file ...]
[1] + Done                 ip neigh show dev wlan0 |
      Stopped (signal)     grep -i -e reachable -e delay |
      Done (2)             grep -o" ..\\:..\\:.."
2|root@hws8701:/ #


however I don’t know how to manipulate this code to get more useful information to create a variable for zero clients connected.
I know this is an old thread, but i did not find any solution anywhere when i  wanted. So just posting the solution for other enthusiasts. 

Ok so i just added a time profile with 5mins interval (choose the time which suits you better) as the trigger.

I added a new task with actions as follows:

A1:-

    Code &gt; Run Shell

    Command:                     ip neigh show dev wlan0
    Store Output In:             %ipneigh
    Store Errors In:             %ipneigherr
    Continue Task after error:   Yes


A2:-

    Net &gt; Wifi Tether

    Set:                         Off
    IF:
         %ipneigh !~ *REACHABLE*   AND
         %ipneigh !~ *STALE*       AND
         %ipneigh !~ *PROBE*       AND
         %ipneigh !~ *DELAY*   


PS: I don't know the workings of ip neigh command. I implemented this by shear trial and error. But It works for me and i am not sure of any bugs yet. Will update with edits if i encounter or anyone comments with any.