- Python 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
The repository is ha-mikrotik-presence; the integration domain stays mikrotik_presence. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
| custom_components/mikrotik_presence | ||
| .gitignore | ||
| README.md | ||
MikroTik Presence
A small Home Assistant integration that answers one question: is this device on
the home network right now? It reads the RouterOS REST API and creates one
device_tracker entity per device you configure. No traffic counters, no port
switches, no firmware update entities.
Why not match on the MAC address
Modern phones rotate their Wi-Fi MAC address. When that happens the router hands out a new DHCP lease and any MAC-keyed tracker goes stale forever. The DHCP host name (option 12) is the device name the phone announces and it survives the rotation, so it is the primary matcher here. MAC addresses are still accepted for devices that never rotate, such as wired hosts.
Presence sources
A device counts as present when any of these is true, checked in this order:
- Its MAC is in the wireless registration table (associated to an access point).
- It holds a bound DHCP lease that the router has seen recently.
- It has a complete ARP entry in a live state (optional, on by default).
The result is held for consider_home seconds after the last positive check so
a sleeping phone does not flap.
Setup
- Copy
custom_components/mikrotik_presenceinto your Home Assistant config. - Restart Home Assistant.
- Add the integration and point it at the router. A read-only RouterOS user is
enough. The
wwwservice must be enabled for the REST API. - Add one tracked device per person. Fill in the DHCP host name, for example
S23-korisnika-Maja. Wildcards such asgalaxy-*work.
To find the host names, run this on the router:
/ip/dhcp-server/lease/print detail
Requirements
RouterOS 7.x with the REST API reachable, and no extra Python packages.