| name | ez-unifi |
| description | Use when asked to manage UniFi network - list/restart/upgrade devices, block/unblock clients, manage WiFi networks, control PoE ports, manage traffic rules, create guest vouchers, or any UniFi controller task. Works with UDM Pro/SE, Dream Machine, Cloud Key Gen2+, or self-hosted controllers. |
| metadata | {"openclaw":{"emoji":"📶"}} |
ez-unifi
Agent-friendly UniFi Network tools powered by the aiounifi library. Supports UDM Pro/SE, Dream Machine, Cloud Key Gen2+, and self-hosted controllers.
Run all commands with: uv run scripts/unifi.py <command> [args]
Setup
Step 1: Ask user to create a dedicated local admin account
To manage your UniFi network, I need API access. Please create a dedicated local admin account:
- Open your UniFi controller (e.g., https://192.168.1.1)
- Go to Settings → System → Admins & Users
- Click Add Admin
- Enter a username (e.g.,
agent-api)
- Enter an email and password
- Important: Disable "Remote Access" - local-only avoids MFA issues
- Set Role to Super Admin or Site Admin
- Click Add
Then provide:
- Controller IP (e.g.,
192.168.1.1)
- Username
- Password
- Is it a UDM Pro/SE/Dream Machine? (yes/no)
Step 2: Save credentials to .env
UNIFI_HOST=https://192.168.1.1
UNIFI_USERNAME=agent-api
UNIFI_PASSWORD=the_password
UNIFI_SITE=default
UNIFI_IS_UDM=true
Set UNIFI_IS_UDM=false for Cloud Key Gen1 or self-hosted controllers.
System & Sites
unifi.py sites
unifi.py sysinfo
unifi.py health
Devices (APs, Switches, Gateways)
unifi.py devices
unifi.py device MAC
unifi.py restart MAC
unifi.py restart MAC --hard
unifi.py upgrade MAC
unifi.py locate MAC
unifi.py unlocate MAC
unifi.py led MAC on|off|default
unifi.py led MAC on --color=#FF0000 --brightness=50
Switch Ports
unifi.py ports
unifi.py port MAC PORT_IDX
unifi.py port-enable MAC PORT_IDX
unifi.py port-disable MAC PORT_IDX
unifi.py poe MAC PORT_IDX MODE
unifi.py power-cycle MAC PORT_IDX
Smart Power (PDU/Outlets)
unifi.py outlets
unifi.py outlet MAC IDX on|off
unifi.py outlet-cycle MAC IDX on|off
Clients
unifi.py clients
unifi.py clients-all
unifi.py client MAC
unifi.py block MAC
unifi.py unblock MAC
unifi.py reconnect MAC
unifi.py forget MAC [MAC2...]
WiFi Networks
unifi.py wlans
unifi.py wlan ID
unifi.py wlan-enable ID
unifi.py wlan-disable ID
unifi.py wlan-password ID NEWPASS
unifi.py wlan-qr ID
unifi.py wlan-qr ID -o myqr.png
Port Forwarding
unifi.py port-forwards
unifi.py port-forward ID
Traffic Rules
unifi.py traffic-rules
unifi.py traffic-rule ID
unifi.py traffic-rule-enable ID
unifi.py traffic-rule-disable ID
unifi.py traffic-rule-toggle ID on|off
Traffic Routes
unifi.py traffic-routes
unifi.py traffic-route ID
unifi.py traffic-route-enable ID
unifi.py traffic-route-disable ID
Firewall
unifi.py firewall-policies
unifi.py firewall-policy ID
unifi.py firewall-zones
unifi.py firewall-zone ID
DPI (Deep Packet Inspection)
unifi.py dpi-apps
unifi.py dpi-app ID
unifi.py dpi-app-enable ID
unifi.py dpi-app-disable ID
unifi.py dpi-groups
unifi.py dpi-group ID
Hotspot Vouchers
unifi.py vouchers
unifi.py voucher-create --duration=60 --quota=1 --note="Guest"
unifi.py voucher-create --duration=1440 --quota=5 --rate-up=5000 --rate-down=10000
unifi.py voucher-delete ID
Voucher options:
--duration - Duration in minutes (default: 60)
--quota - Number of uses (default: 1)
--usage-quota - Usage quota in MB
--rate-up - Upload rate limit in Kbps
--rate-down - Download rate limit in Kbps
--note - Note/description
Events
unifi.py events
Raw API Access
unifi.py raw GET /stat/health
unifi.py raw POST /cmd/devmgr '{"cmd":"restart","mac":"aa:bb:cc:dd:ee:ff"}'
unifi.py raw PUT /rest/wlanconf/ID '{"enabled":false}'
Output Options
Add --json flag to any list command for JSON output:
unifi.py devices --json
unifi.py clients --json
Examples
uv run scripts/unifi.py health
uv run scripts/unifi.py clients
uv run scripts/unifi.py block "aa:bb:cc:dd:ee:ff"
uv run scripts/unifi.py restart "11:22:33:44:55:66"
uv run scripts/unifi.py wlan-disable "5f8b3d2e1a4c7b9e0d6f8a2c"
uv run scripts/unifi.py upgrade "11:22:33:44:55:66"
uv run scripts/unifi.py power-cycle "switch_mac" 5
uv run scripts/unifi.py voucher-create --duration=1440 --quota=1 --note="Guest access"
uv run scripts/unifi.py wlan-qr "wlan_id" -o guest_wifi.png
uv run scripts/unifi.py traffic-rule-disable "rule_id"
Finding IDs
- WLAN IDs: Run
wlans and look for the ID column
- Device MACs: Run
devices and look for the MAC column
- Client MACs: Run
clients or clients-all and look for the MAC column
- Traffic Rule IDs: Run
traffic-rules and look for the ID column
- Voucher IDs: Run
vouchers and look for the ID column
Notes
- MAC addresses can be any format (with colons, dashes, or none)
- All output is JSON for easy parsing
- Using a dedicated local account avoids MFA issues with cloud-linked accounts
- If you get rate limited (429 error), wait a few minutes before retrying