PHP Script to get connected devices with Omada Controller by your EAP accesspoints. I use this script to check the state of my wifi devices and control my homeautomation.
The script is not perfect but it works. Help, wishes, improvements are welcome.
Preface: Unifi
Originally I had Unifi hardware in use, there you could query the individual access points or the controller via SSH, which clients are connected. Omada access points support SSH (after activation) but do not offer a command to query the connected clients. You always have to query via the Omada software controller.API The controller version seems to be very important, as not all endpoints always work in every version. The documentation is hard to find, I uploaded a file of another API version (might be helpful). Link to API documentation
- Omada Version 5.4.6 (running at Debian 11 on Proxmox VM)
- EAP610 accesspoints
- login to your omada controller with Google chrome
- (optionally) create a new user (role: viewer) and grant access to site
- open DevTools in Chrome and open 'Network' tab
- select 'Clients' Page on Omada Controller
- wait in DevTools to see an entry like 'clients?currentPage=1..."
- right click on that entry and save as HAR
- open HAR file with editor and search for 'clients?'
- you find an entry: ... api/v2/sites/SITE-ID/clients?currentPage=1 ...
- not the SITE-ID an enter it to the clients.php script
- modify the clients.php script and set the environment variables (ip, user, password)
- only the first 100 clients are returned (tested with GetClients(1,100)
- only pagesizes from omada webinterface are working!
- having 28 clients: tested GetClients(1,10), GetClients(2,10), GetClients(3,10) where the last two returned the same results (hint for fetched all?)
- errorhandling / optimize programflow
- automation of getting site-id
- reuse cookies until expiring
- clients disconnected for long time don't show up in list (you have to temporary fix this if your homeautomation needs the json entry, modify output, add entry with state 'off')
thanks to mbentley and his shell script
- /api/v2/sites/Default/clients/CLIENT-MAC-ADDRESS thows error
- /api/v2/sites does not work to get site-id