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' ..\:..\:..'                              <
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 am also looking for a task to automaticly turn off Wi-Fi tethering when there are no devices connected. Did you manage to get this work properly? Commented May 16, 2018 at 8:53
  • @JanEnglund I will relook into this and give you feeback :) Commented May 17, 2018 at 7:53

2 Answers 2


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:


    Code > Run Shell

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


    Net > Wifi Tether

    Set:                         Off
         %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.


I have found a partially working solution to the question.

You will see why I say partial:

Here is the task for mobile hotspot auto-switch off e.g Hotspot Control

  • A1: Code >> Run Shell >> [Command:ip -s -s neigh flush all] (Clear ARP cache)
  • A2: Task >> Wait [Time: 15 Seconds] (Wait for connected devices to ping back)
  • A3: Code >> Run Shell >> [Command: ip neigh show dev wlan0 (Store Output in: %Clients Store errors in: %Error)]
  • A4: Task >> If [Condition : %Clients isn't set] (no device connected)
  • A5: Net >> WiFi Tether >> [Set: Off]
  • A6: Task >> Else (don't turn off mobile hotspot)
  • A7: Task >> Stop
  • A8: Variables >> Variable Clear [Name: %Clients]
  • A9: Task >> End If

enter image description here

Screenshot (click image for larger variant)

Now for the profile/trigger I ran into small problems eventually I decided to try this as beta:


  • State >> Variables >> Variable Value [Conditions: %Tether ~ * wifi* ] (If wifi tethering is active)

Entry Task: Hotspot Control

Exit Task : Anonymous task (Set WiFi Tether Off)

Alternative profile

  • Time >> 5 minutes
  • Variable value: %Error is set (i.e Check if no device is connected to hotspot every 5 minutes)


  • The task works perfectly (i.e it automatically turns off hotspot when no device is connected) but at first instance only. Once the %Clients variable is populated, subsequent triggers won't work even though I explicity included variable clear function (Action 8 above)

  • I couldn't find a suitable profile but for the meantime the first profile works although buggy sometimes.

Iam still trying to find the best (non-buggy) way of doing this, so I just put this as a partial solution, I am still waiting for better answers therefore I will not accept it:)

Special credits and gratitude

This work was hugely inspired by user341464, Squidly and Firelord (I had to learn from their tutorials, and make slight adjustments to meet specific needs but its not perfect yet)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .