Robust Wifi presence sensing with Mikrotik

A simple solution for robust Wifi based presence sensing (if you have a Microtik router) that has minimal load on the hub.

  1. Create a virtual presence sensor
  2. Use the Maker API app to setup URLs to trigger "away" and "present"
  3. Setup your router to assign a fixed IP address to the phone you want to detect presence on.
  4. Install a script on your Mikrotik router that pings the device (I do it every 5 seconds) and hits the "present" or "away" URL depending on the result. This is my little script:
:local targetIP $0;
:local DeviceID $1;

:while (true) do={
    :local pingResult [/ping $targetIP count=1]
    :if ($pingResult = 0) do={
        :log warning "$targetIP is not reachable!"
         /tool fetch url="http://away" mode=http keep-result=no
    } else={
        :log info "$targetIP is reachable. $DeviceID"
         /tool fetch url="http://home" mode=http keep-result=no
    }
    :delay 5
}

There is a ping app avail for the hub
Other than the ip assignment yoi can do this all in the hub with the.ping driver and a rule.

1 Like

[UPDATED] iPhone WiFi Presence Sensor is a community app that works on most phones and bypasses the need for rules altogether. Give your phone a fixed IP address and add it to the virtual device that is created by the app.

Nice -- I have a separate network for Hubitat and IOT type stuff.

1 Like

i would not say it worksw on most phones when it appears to be iphone specific.

It works on most Android phones too as indicated in the thread. The general idea is still the same. The app creates a virtual device. On the router you set an IP reservation for the phone. In the virtual device's preferences, you put in the reserved IP address of the phone. The virtual device pings the phone and sets presence based on whether the phone gets pinged.

It's only called iPhone because that is what the creator had for testing. Others have verified it works on Android phones too.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.