ui-cli 1.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. ui_cli/__init__.py +31 -0
  2. ui_cli/client.py +269 -0
  3. ui_cli/commands/__init__.py +1 -0
  4. ui_cli/commands/devices.py +187 -0
  5. ui_cli/commands/groups.py +503 -0
  6. ui_cli/commands/hosts.py +114 -0
  7. ui_cli/commands/isp.py +100 -0
  8. ui_cli/commands/local/__init__.py +63 -0
  9. ui_cli/commands/local/apgroups.py +445 -0
  10. ui_cli/commands/local/clients.py +1537 -0
  11. ui_cli/commands/local/config.py +758 -0
  12. ui_cli/commands/local/devices.py +570 -0
  13. ui_cli/commands/local/dpi.py +369 -0
  14. ui_cli/commands/local/events.py +289 -0
  15. ui_cli/commands/local/firewall.py +285 -0
  16. ui_cli/commands/local/health.py +195 -0
  17. ui_cli/commands/local/networks.py +426 -0
  18. ui_cli/commands/local/portfwd.py +153 -0
  19. ui_cli/commands/local/stats.py +234 -0
  20. ui_cli/commands/local/utils.py +85 -0
  21. ui_cli/commands/local/vouchers.py +410 -0
  22. ui_cli/commands/local/wan.py +302 -0
  23. ui_cli/commands/local/wlans.py +257 -0
  24. ui_cli/commands/mcp.py +416 -0
  25. ui_cli/commands/sdwan.py +168 -0
  26. ui_cli/commands/sites.py +65 -0
  27. ui_cli/commands/speedtest.py +192 -0
  28. ui_cli/commands/status.py +410 -0
  29. ui_cli/commands/version.py +13 -0
  30. ui_cli/config.py +106 -0
  31. ui_cli/groups.py +567 -0
  32. ui_cli/local_client.py +897 -0
  33. ui_cli/main.py +61 -0
  34. ui_cli/models.py +188 -0
  35. ui_cli/output.py +251 -0
  36. ui_cli-1.2.1.dist-info/METADATA +1315 -0
  37. ui_cli-1.2.1.dist-info/RECORD +46 -0
  38. ui_cli-1.2.1.dist-info/WHEEL +4 -0
  39. ui_cli-1.2.1.dist-info/entry_points.txt +3 -0
  40. ui_cli-1.2.1.dist-info/licenses/LICENSE +21 -0
  41. ui_mcp/ARCHITECTURE.md +243 -0
  42. ui_mcp/README.md +235 -0
  43. ui_mcp/__init__.py +7 -0
  44. ui_mcp/__main__.py +10 -0
  45. ui_mcp/cli_runner.py +112 -0
  46. ui_mcp/server.py +468 -0
@@ -0,0 +1,1315 @@
1
+ Metadata-Version: 2.4
2
+ Name: ui-cli
3
+ Version: 1.2.1
4
+ Summary: CLI utility for UniFi Site Manager and local controller APIs
5
+ Project-URL: Homepage, https://github.com/vedanta/ui-cli
6
+ Project-URL: Documentation, https://vedanta.github.io/ui-cli
7
+ Project-URL: Repository, https://github.com/vedanta/ui-cli
8
+ Project-URL: Changelog, https://github.com/vedanta/ui-cli/blob/main/CHANGELOG.md
9
+ Author: Vedanta
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: api,cli,network,ubiquiti,unifi
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Environment :: Console
15
+ Classifier: Intended Audience :: System Administrators
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Topic :: System :: Networking
23
+ Requires-Python: >=3.10
24
+ Requires-Dist: httpx>=0.27.0
25
+ Requires-Dist: pydantic-settings>=2.0.0
26
+ Requires-Dist: pydantic>=2.0.0
27
+ Requires-Dist: python-dotenv>=1.0.0
28
+ Requires-Dist: rich>=13.0.0
29
+ Requires-Dist: typer>=0.12.0
30
+ Provides-Extra: dev
31
+ Requires-Dist: mypy>=1.10.0; extra == 'dev'
32
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
33
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
34
+ Requires-Dist: ruff>=0.5.0; extra == 'dev'
35
+ Provides-Extra: mcp
36
+ Requires-Dist: mcp>=1.0.0; extra == 'mcp'
37
+ Description-Content-Type: text/markdown
38
+
39
+ # UniFi CLI
40
+
41
+ <p align="center">
42
+ <img src="art/uicli_new.png" alt="UI-CLI" width="400">
43
+ </p>
44
+
45
+ <p align="center">
46
+ <strong>Manage your UniFi infrastructure from the command line</strong>
47
+ </p>
48
+
49
+ <p align="center">
50
+ <a href="https://vedanta.github.io/ui-cli">Documentation</a> •
51
+ <a href="#installation">Installation</a> •
52
+ <a href="#quick-start">Quick Start</a> •
53
+ <a href="CHANGELOG.md">Changelog</a>
54
+ </p>
55
+
56
+ ---
57
+
58
+ ## Table of Contents
59
+
60
+ - [Overview](#overview)
61
+ - [Installation](#installation)
62
+ - [Configuration](#configuration)
63
+ - [Quick Start](#quick-start)
64
+ - [Cloud API Commands](#cloud-api-commands)
65
+ - [Local Controller Commands](#local-controller-commands)
66
+ - [Client Groups](#client-groups)
67
+ - [Claude Desktop Integration](#claude-desktop-integration)
68
+ - [Output Formats](#output-formats)
69
+ - [Command Reference](#command-reference)
70
+ - [Data Storage](#data-storage)
71
+ - [Troubleshooting](#troubleshooting)
72
+ - [Documentation](#documentation)
73
+
74
+ ---
75
+
76
+ ## Overview
77
+
78
+ UI-CLI is a comprehensive command-line tool for managing UniFi network infrastructure. It provides two connection modes to cover all management scenarios:
79
+
80
+ | Mode | Connection | Use Cases |
81
+ |------|------------|-----------|
82
+ | **Cloud API** | Via `api.ui.com` | Multi-site management, ISP metrics, SD-WAN, remote access |
83
+ | **Local API** | Direct to controller | Real-time client control, device management, bulk actions |
84
+
85
+ ### Features
86
+
87
+ **Cloud API (Site Manager)**
88
+ - View and manage multiple sites and controllers from anywhere
89
+ - List all devices across your infrastructure with filtering
90
+ - Monitor ISP performance metrics (latency, speeds, uptime, packet loss)
91
+ - Manage SD-WAN configurations and deployment status
92
+ - Count and group devices by model, status, or controller
93
+
94
+ **Local Controller API**
95
+ - **Client Management** - List connected clients, filter by wired/wireless/network, view detailed status including signal strength and WiFi experience, block/unblock/reconnect clients
96
+ - **Client Groups** - Create named groups of devices for bulk actions (e.g., "Kids Devices", "Smart Bulbs"), supports static groups with manual membership and auto groups with pattern-based rules (vendor, hostname, network, IP range)
97
+ - **Device Control** - List all network devices, restart or upgrade firmware, toggle locate LED for physical identification, adopt new devices
98
+ - **Network Visibility** - View all networks and VLANs with DHCP configuration, monitor site health (WAN/LAN/WLAN/VPN status), browse recent events and alerts
99
+ - **Security & Firewall** - Inspect firewall rules by ruleset, view address and port groups, list port forwarding rules
100
+ - **Traffic Analytics** - Deep packet inspection (DPI) statistics by application, per-client traffic breakdown, daily and hourly bandwidth reports
101
+ - **Guest Management** - Create hotspot vouchers with custom duration, data limits, and speed caps, list and delete existing vouchers
102
+ - **Configuration Export** - Export running config to YAML/JSON for backup, filter by section (networks, wireless, firewall, devices)
103
+
104
+ **Claude Desktop Integration (MCP)**
105
+ - Natural language control of your network via Claude Desktop
106
+ - 21 tools covering status, health, client management, device control, groups, and vouchers
107
+ - Ask questions like "How many devices are connected?" or "Block the kids iPad"
108
+ - Group actions like "Block all kids devices" or "Show status of smart bulbs"
109
+
110
+ **General**
111
+ - Multiple output formats: table (human-readable), JSON (scripting), CSV (spreadsheets), YAML (config)
112
+ - Works with UDM, UDM Pro, UDM SE, Cloud Key, and self-hosted controllers
113
+ - Automatic controller type detection (UDM vs Cloud Key API paths)
114
+ - Session management with automatic re-authentication
115
+ - SSL verification bypass for self-signed certificates
116
+ - CI/CD friendly with automatic spinner disable
117
+
118
+ ---
119
+
120
+ ## Installation
121
+
122
+ ### Prerequisites
123
+
124
+ - Python 3.10+
125
+ - Conda (recommended) or pip
126
+ - Network access to your UniFi controller
127
+
128
+ ### Using pip (PyPI)
129
+
130
+ Once the package is published publicly, install it directly from PyPI:
131
+
132
+ ```bash
133
+ # Create virtual environment
134
+ python -m venv venv
135
+ source venv/bin/activate # On Windows: venv\Scripts\activate
136
+
137
+ # Install from PyPI
138
+ pip install ui-cli
139
+ ```
140
+
141
+ ### Using Conda (Recommended for Source Checkouts)
142
+
143
+ ```bash
144
+ # Clone the repository
145
+ git clone https://github.com/vedanta/ui-cli.git
146
+ cd ui-cli
147
+
148
+ # Create and activate conda environment
149
+ conda env create -f environment.yml
150
+ conda activate ui-cli
151
+
152
+ # Install the package
153
+ pip install -e .
154
+ ```
155
+
156
+ ### Using pip from Source
157
+
158
+ ```bash
159
+ # Clone the repository
160
+ git clone https://github.com/vedanta/ui-cli.git
161
+ cd ui-cli
162
+
163
+ # Create virtual environment
164
+ python -m venv venv
165
+ source venv/bin/activate # On Windows: venv\Scripts\activate
166
+
167
+ # Install the package
168
+ pip install -e .
169
+ ```
170
+
171
+ ### Using Docker
172
+
173
+ ```bash
174
+ # Build the image
175
+ docker build -t ui-cli .
176
+
177
+ # Run with environment variables
178
+ docker run --rm -e UNIFI_API_KEY=your-key ui-cli status
179
+
180
+ # Run with .env file
181
+ docker run --rm --env-file .env ui-cli hosts list
182
+
183
+ # Run local controller commands
184
+ docker run --rm --env-file .env ui-cli lo clients list
185
+
186
+ # Interactive mode
187
+ docker run -it --rm --env-file .env ui-cli --help
188
+ ```
189
+
190
+ **Docker Compose:**
191
+
192
+ ```bash
193
+ # Run commands via docker-compose
194
+ docker-compose run --rm ui-cli status
195
+ docker-compose run --rm ui-cli lo clients list
196
+ ```
197
+
198
+ ### Verify Installation
199
+
200
+ ```bash
201
+ ./ui --help # Using wrapper script
202
+ ui --help # After pip install (if in PATH)
203
+ ```
204
+
205
+ ---
206
+
207
+ ## Configuration
208
+
209
+ Create a `.env` file in the project root:
210
+
211
+ ```bash
212
+ cp .env.example .env
213
+ ```
214
+
215
+ ### Cloud API Configuration
216
+
217
+ For commands that use the UniFi Site Manager API (`api.ui.com`):
218
+
219
+ ```bash
220
+ # Required: Your API key
221
+ UNIFI_API_KEY=your-api-key-here
222
+
223
+ # Optional: API base URL (default: https://api.ui.com/v1)
224
+ UNIFI_API_URL=https://api.ui.com/v1
225
+
226
+ # Optional: Request timeout in seconds (default: 30)
227
+ UNIFI_TIMEOUT=30
228
+ ```
229
+
230
+ **Getting Your API Key:**
231
+ 1. Go to [unifi.ui.com](https://unifi.ui.com)
232
+ 2. Navigate to **Settings** → **API**
233
+ 3. Click **Create API Key**
234
+ 4. Copy the key immediately (it's only shown once!)
235
+
236
+ ### Local Controller Configuration
237
+
238
+ For commands that connect directly to your UniFi Controller:
239
+
240
+ ```bash
241
+ # Required: Controller URL (include https://)
242
+ UNIFI_CONTROLLER_URL=https://192.168.1.1
243
+
244
+ # Required: Credentials
245
+ UNIFI_CONTROLLER_USERNAME=admin
246
+ UNIFI_CONTROLLER_PASSWORD=yourpassword
247
+
248
+ # Optional: Site name (default: "default")
249
+ UNIFI_CONTROLLER_SITE=default
250
+
251
+ # Optional: SSL verification (default: false for self-signed certs)
252
+ UNIFI_CONTROLLER_VERIFY_SSL=false
253
+ ```
254
+
255
+ ### Full Configuration Example
256
+
257
+ ```bash
258
+ # ===========================================
259
+ # Cloud API (api.ui.com)
260
+ # ===========================================
261
+ UNIFI_API_KEY=your-api-key-here
262
+ UNIFI_API_URL=https://api.ui.com/v1
263
+ UNIFI_TIMEOUT=30
264
+
265
+ # ===========================================
266
+ # Local Controller
267
+ # ===========================================
268
+ UNIFI_CONTROLLER_URL=https://192.168.1.1
269
+ UNIFI_CONTROLLER_USERNAME=admin
270
+ UNIFI_CONTROLLER_PASSWORD=yourpassword
271
+ UNIFI_CONTROLLER_SITE=default
272
+ UNIFI_CONTROLLER_VERIFY_SSL=false
273
+ ```
274
+
275
+ ### Controller Types
276
+
277
+ UI-CLI automatically detects your controller type and uses the correct API paths:
278
+
279
+ | Controller | API Path |
280
+ |------------|----------|
281
+ | UDM / UDM Pro / UDM SE | `/proxy/network/api/s/{site}/` |
282
+ | Cloud Key / Self-hosted | `/api/s/{site}/` |
283
+
284
+ ### Multiple Sites
285
+
286
+ To work with different sites on the same controller:
287
+
288
+ ```bash
289
+ # Option 1: Edit .env
290
+ UNIFI_CONTROLLER_SITE=office
291
+
292
+ # Option 2: Use different .env files
293
+ cp .env .env.home
294
+ cp .env .env.office
295
+ # Edit each file with different site names
296
+ ```
297
+
298
+ ---
299
+
300
+ ## Quick Start
301
+
302
+ ### 1. Configure Credentials
303
+
304
+ ```bash
305
+ cp .env.example .env
306
+ # Edit .env with your credentials
307
+ ```
308
+
309
+ ### 2. Verify Connections
310
+
311
+ ```bash
312
+ # Check Cloud API connection
313
+ ./ui status
314
+
315
+ # Check Local Controller connection
316
+ ./ui lo health
317
+ ```
318
+
319
+ ### 3. Explore Commands
320
+
321
+ ```bash
322
+ # List all commands
323
+ ./ui --help
324
+
325
+ # List connected clients
326
+ ./ui lo clients list
327
+
328
+ # List network devices
329
+ ./ui lo devices list
330
+
331
+ # Get client count by type
332
+ ./ui lo clients count
333
+ ```
334
+
335
+ ---
336
+
337
+ ## Cloud API Commands
338
+
339
+ Commands that use the UniFi Site Manager API (`api.ui.com`). Requires `UNIFI_API_KEY`.
340
+
341
+ ### Status & Version
342
+
343
+ ```bash
344
+ ./ui status # Check API connection status
345
+ ./ui version # Show CLI version
346
+ ```
347
+
348
+ ### Hosts (Controllers)
349
+
350
+ ```bash
351
+ ./ui hosts list # List all controllers
352
+ ./ui hosts list -o json # JSON output
353
+ ./ui hosts get HOST_ID # Get controller details
354
+ ```
355
+
356
+ ### Sites
357
+
358
+ ```bash
359
+ ./ui sites list # List all sites across controllers
360
+ ./ui sites list -o json # JSON output
361
+ ./ui sites list -v # Verbose with device counts
362
+ ```
363
+
364
+ ### Devices (Cloud)
365
+
366
+ ```bash
367
+ # List devices
368
+ ./ui devices list # List all devices across sites
369
+ ./ui devices list --host ID # Filter by controller
370
+ ./ui devices list -v # Verbose with details
371
+ ./ui devices list -o json # JSON output
372
+
373
+ # Count devices
374
+ ./ui devices count # Total count
375
+ ./ui devices count --by model # Group by device model
376
+ ./ui devices count --by status # Find online/offline counts
377
+ ./ui devices count --by host # Group by controller
378
+ ```
379
+
380
+ ### ISP Metrics
381
+
382
+ Monitor ISP performance over time:
383
+
384
+ ```bash
385
+ # Default: Last 7 days with hourly data
386
+ ./ui isp metrics
387
+
388
+ # Custom time range
389
+ ./ui isp metrics --hours 24 # Last 24 hours
390
+ ./ui isp metrics --hours 48 # Last 48 hours
391
+
392
+ # Higher resolution (5-minute intervals, max 24h)
393
+ ./ui isp metrics -i 5m
394
+ ./ui isp metrics -i 5m --hours 12
395
+
396
+ # Output formats
397
+ ./ui isp metrics -o json # JSON for scripting
398
+ ./ui isp metrics -o csv # CSV for spreadsheets
399
+ ```
400
+
401
+ Metrics include:
402
+ - Download/upload speeds
403
+ - Latency (min, max, average)
404
+ - Packet loss
405
+ - Uptime percentage
406
+
407
+ ### SD-WAN
408
+
409
+ ```bash
410
+ ./ui sdwan list # List SD-WAN configurations
411
+ ./ui sdwan get CONFIG_ID # Get configuration details
412
+ ./ui sdwan status CONFIG_ID # Check deployment status
413
+ ```
414
+
415
+ ### Speed Test
416
+
417
+ ```bash
418
+ ./ui speedtest # Get last speed test result
419
+ ./ui speedtest -r # Run new speed test (takes 30-60s)
420
+ ./ui speedtest -o json # JSON output
421
+ ```
422
+
423
+ ---
424
+
425
+ ## Local Controller Commands
426
+
427
+ Commands that connect directly to your UniFi Controller. Use `./ui local` or the shorthand `./ui lo`.
428
+
429
+ Requires `UNIFI_CONTROLLER_URL`, `UNIFI_CONTROLLER_USERNAME`, and `UNIFI_CONTROLLER_PASSWORD`.
430
+
431
+ ### Timeout Options
432
+
433
+ ```bash
434
+ ./ui lo health # Default timeout (15s)
435
+ ./ui lo -q health # Quick mode (5s timeout)
436
+ ./ui lo --timeout 60 health # Custom timeout (60s)
437
+ ```
438
+
439
+ ### Health & Monitoring
440
+
441
+ ```bash
442
+ # Site health summary
443
+ ./ui lo health # Shows WAN, LAN, WLAN, VPN status
444
+ ./ui lo health -v # Verbose with details
445
+ ./ui lo health -o json # JSON output
446
+
447
+ # Events
448
+ ./ui lo events list # Recent events (default: 25)
449
+ ./ui lo events list -l 50 # Last 50 events
450
+ ./ui lo events list -l 100 # Last 100 events
451
+ ./ui lo events list -v # Verbose with full details
452
+ ./ui lo events list -o json # JSON output
453
+ ```
454
+
455
+ ### Clients
456
+
457
+ ```bash
458
+ # List clients
459
+ ./ui lo clients list # Connected clients only
460
+ ./ui lo clients list -w # Wired clients only
461
+ ./ui lo clients list -W # Wireless clients only
462
+ ./ui lo clients list -n Guest # Filter by network/SSID
463
+ ./ui lo clients list -g kids # Filter by group
464
+ ./ui lo clients list -v # Verbose (signal, experience)
465
+ ./ui lo clients list -o json # JSON output
466
+
467
+ # All clients (including offline/historical)
468
+ ./ui lo clients all
469
+ ./ui lo clients all -o json
470
+
471
+ # Get specific client
472
+ ./ui lo clients get my-iPhone # By display name
473
+ ./ui lo clients get AA:BB:CC:DD:EE:FF # By MAC address
474
+ ./ui lo clients get 192.168.1.100 # By IP address
475
+ ./ui lo clients get iPhone # Partial name match
476
+
477
+ # Detailed client status
478
+ ./ui lo clients status my-iPhone # Full status with signal, experience
479
+ ./ui lo clients status -o json
480
+
481
+ # Client actions
482
+ ./ui lo clients block my-iPhone # Block (with confirmation)
483
+ ./ui lo clients block my-iPhone -y # Block (skip confirmation)
484
+ ./ui lo clients unblock my-iPhone # Unblock client
485
+ ./ui lo clients kick my-iPhone # Disconnect (can reconnect)
486
+
487
+ # Bulk actions with groups
488
+ ./ui lo clients block -g kids-devices -y # Block all in group
489
+ ./ui lo clients unblock -g kids-devices -y # Unblock all in group
490
+ ./ui lo clients kick -g kids-devices -y # Kick all in group
491
+
492
+ # Statistics
493
+ ./ui lo clients count # Count by connection type
494
+ ./ui lo clients count --by network # Count by network/SSID
495
+ ./ui lo clients count --by vendor # Count by manufacturer
496
+ ./ui lo clients count --by ap # Count by access point
497
+ ./ui lo clients count --by experience # Count by WiFi quality
498
+ ./ui lo clients count -a # Include offline clients
499
+ ./ui lo clients count -o json # JSON output
500
+
501
+ # Find duplicates
502
+ ./ui lo clients duplicates # Find duplicate hostnames/names
503
+ ```
504
+
505
+ ### Devices
506
+
507
+ ```bash
508
+ # List devices
509
+ ./ui lo devices list # All network devices (APs, switches, gateway)
510
+ ./ui lo devices list -v # Verbose (channels, load, temperatures)
511
+ ./ui lo devices list -o json # JSON output
512
+
513
+ # Get specific device
514
+ ./ui lo devices get UDM-Pro # By name
515
+ ./ui lo devices get 70:a7:41:xx:xx:xx # By MAC address
516
+ ./ui lo devices get 192.168.1.1 # By IP address
517
+
518
+ # Device actions
519
+ ./ui lo devices restart UDM-Pro # Restart (with confirmation)
520
+ ./ui lo devices restart UDM-Pro -y # Restart (skip confirmation)
521
+ ./ui lo devices upgrade Office-AP # Upgrade firmware
522
+ ./ui lo devices upgrade Office-AP -y # Upgrade (skip confirmation)
523
+
524
+ # Locate LED
525
+ ./ui lo devices locate Office-AP # Turn on locate LED
526
+ ./ui lo devices locate Office-AP --off # Turn off locate LED
527
+
528
+ # Adopt new device
529
+ ./ui lo devices adopt 70:a7:41:xx:xx:xx
530
+ ```
531
+
532
+ ### Networks
533
+
534
+ ```bash
535
+ ./ui lo networks list # List all networks/VLANs
536
+ ./ui lo networks list -v # Verbose (DHCP ranges, settings)
537
+ ./ui lo networks list -o json # JSON output
538
+ ./ui lo networks get NETWORK_ID # Get specific network details
539
+ ```
540
+
541
+ ### Firewall
542
+
543
+ ```bash
544
+ # Firewall rules
545
+ ./ui lo firewall list # All firewall rules
546
+ ./ui lo firewall list --ruleset WAN_IN # Filter by ruleset
547
+ ./ui lo firewall list --ruleset LAN_IN
548
+ ./ui lo firewall list --ruleset WAN_OUT
549
+ ./ui lo firewall list -v # Verbose with full details
550
+ ./ui lo firewall list -o json # JSON output
551
+
552
+ # Address and port groups
553
+ ./ui lo firewall groups # List all groups
554
+ ./ui lo firewall groups -v # Show group members
555
+ ./ui lo firewall groups -o json # JSON output
556
+ ```
557
+
558
+ ### Port Forwarding
559
+
560
+ ```bash
561
+ ./ui lo portfwd list # List port forwarding rules
562
+ ./ui lo portfwd list -v # Verbose with full details
563
+ ./ui lo portfwd list -o json # JSON output
564
+ ```
565
+
566
+ ### Guest Vouchers
567
+
568
+ ```bash
569
+ # List vouchers
570
+ ./ui lo vouchers list # All vouchers
571
+ ./ui lo vouchers list -v # Verbose with usage details
572
+ ./ui lo vouchers list -o json # JSON output
573
+
574
+ # Create vouchers
575
+ ./ui lo vouchers create # Single voucher, 24h duration
576
+ ./ui lo vouchers create -c 10 # Create 10 vouchers
577
+ ./ui lo vouchers create -d 60 # 60 minute duration
578
+ ./ui lo vouchers create -d 1440 # 24 hour duration (in minutes)
579
+ ./ui lo vouchers create -q 1024 # 1GB data quota (in MB)
580
+ ./ui lo vouchers create --up 5000 # 5 Mbps upload limit (in kbps)
581
+ ./ui lo vouchers create --down 10000 # 10 Mbps download limit (in kbps)
582
+ ./ui lo vouchers create -n "Event" # Add note
583
+
584
+ # Full example: 10 vouchers, 2 hours, 500MB quota, speed limits
585
+ ./ui lo vouchers create -c 10 -d 120 -q 500 --up 5000 --down 10000 -n "Conference"
586
+
587
+ # Delete voucher
588
+ ./ui lo vouchers delete 12345-67890
589
+ ./ui lo vouchers delete 12345-67890 -y # Skip confirmation
590
+ ```
591
+
592
+ ### DPI (Deep Packet Inspection)
593
+
594
+ Requires DPI to be enabled in controller settings.
595
+
596
+ ```bash
597
+ # Site-wide DPI statistics
598
+ ./ui lo dpi stats # Top applications by traffic
599
+ ./ui lo dpi stats -l 20 # Top 20 applications
600
+ ./ui lo dpi stats -v # Verbose with categories
601
+ ./ui lo dpi stats -o json # JSON output
602
+
603
+ # Per-client DPI
604
+ ./ui lo dpi client my-MacBook # By name
605
+ ./ui lo dpi client AA:BB:CC:DD:EE:FF # By MAC
606
+ ./ui lo dpi client -o json
607
+ ```
608
+
609
+ ### Traffic Statistics
610
+
611
+ ```bash
612
+ # Daily statistics
613
+ ./ui lo stats daily # Last 30 days
614
+ ./ui lo stats daily --days 7 # Last 7 days
615
+ ./ui lo stats daily --days 90 # Last 90 days
616
+ ./ui lo stats daily -o json # JSON output
617
+ ./ui lo stats daily -o csv # CSV for spreadsheets
618
+
619
+ # Hourly statistics
620
+ ./ui lo stats hourly # Last 24 hours
621
+ ./ui lo stats hourly --hours 48 # Last 48 hours
622
+ ./ui lo stats hourly -o json # JSON output
623
+ ```
624
+
625
+ ### Configuration Export
626
+
627
+ Export your running configuration for backup or documentation:
628
+
629
+ ```bash
630
+ # Full configuration
631
+ ./ui lo config show # All sections (table format)
632
+ ./ui lo config show -o yaml # YAML export
633
+ ./ui lo config show -o json # JSON export
634
+ ./ui lo config show -v # Include internal IDs
635
+ ./ui lo config show --show-secrets # Include passwords (careful!)
636
+
637
+ # Specific sections
638
+ ./ui lo config show -s networks # Networks and VLANs
639
+ ./ui lo config show -s wireless # SSIDs and WiFi settings
640
+ ./ui lo config show -s firewall # Firewall rules
641
+ ./ui lo config show -s devices # Device inventory
642
+ ./ui lo config show -s portfwd # Port forwarding rules
643
+ ./ui lo config show -s dhcp # DHCP reservations
644
+ ./ui lo config show -s routing # Static routes
645
+
646
+ # Save to file
647
+ ./ui lo config show -o yaml > backup-$(date +%Y%m%d).yaml
648
+ ./ui lo config show -o json > backup-$(date +%Y%m%d).json
649
+ ```
650
+
651
+ ---
652
+
653
+ ## Client Groups
654
+
655
+ Create named groups of client devices for bulk actions. Groups are stored locally and work without network access.
656
+
657
+ ### Use Cases
658
+
659
+ - **Parental Controls** - Block kids' devices at bedtime
660
+ - **IoT Management** - Group smart home devices by type
661
+ - **Guest Monitoring** - Track devices on guest network
662
+ - **Network Segmentation** - Manage servers, workstations, etc.
663
+
664
+ ### Static Groups
665
+
666
+ Static groups have manually managed membership using MAC addresses.
667
+
668
+ ```bash
669
+ # Create a group
670
+ ./ui groups create "Kids Devices"
671
+ ./ui groups create "Kids Devices" -d "Tablets and phones for the kids"
672
+
673
+ # Add members (with optional alias)
674
+ ./ui groups add kids-devices AA:BB:CC:DD:EE:FF
675
+ ./ui groups add kids-devices AA:BB:CC:DD:EE:FF -a "Timmy iPad"
676
+ ./ui groups add kids-devices 11:22:33:44:55:66 -a "Sarah Phone"
677
+ ./ui groups add kids-devices 22:33:44:55:66:77 -a "Gaming Console"
678
+
679
+ # Add multiple at once
680
+ ./ui groups add kids-devices MAC1 MAC2 MAC3
681
+
682
+ # View group
683
+ ./ui groups show kids-devices
684
+ ./ui groups show kids-devices -o json
685
+
686
+ # List members
687
+ ./ui groups members kids-devices
688
+ ./ui groups members kids-devices -o json
689
+
690
+ # Update member alias
691
+ ./ui groups alias kids-devices AA:BB:CC:DD:EE:FF "New Alias"
692
+ ./ui groups alias kids-devices AA:BB:CC:DD:EE:FF --clear
693
+
694
+ # Remove members
695
+ ./ui groups remove kids-devices AA:BB:CC:DD:EE:FF
696
+ ./ui groups remove kids-devices "Timmy iPad" # By alias
697
+
698
+ # Clear all members
699
+ ./ui groups clear kids-devices
700
+ ./ui groups clear kids-devices -y # Skip confirmation
701
+ ```
702
+
703
+ ### Auto Groups
704
+
705
+ Auto groups dynamically match clients based on rules. Members are evaluated at query time.
706
+
707
+ ```bash
708
+ # Basic syntax
709
+ ./ui groups auto "Group Name" --rule-type "pattern"
710
+
711
+ # Match by vendor/manufacturer (OUI)
712
+ ./ui groups auto "Apple Devices" --vendor "Apple"
713
+ ./ui groups auto "IoT Devices" --vendor "Philips,LIFX,Ring,Nest"
714
+ ./ui groups auto "Smart TVs" --vendor "Samsung,LG,Sony"
715
+
716
+ # Match by client name pattern
717
+ ./ui groups auto "Cameras" --name "*camera*"
718
+ ./ui groups auto "Phones" --name "*phone*,*Phone*"
719
+ ./ui groups auto "Laptops" --name "*MacBook*,*laptop*"
720
+
721
+ # Match by hostname
722
+ ./ui groups auto "iPhones" --hostname "iPhone*"
723
+ ./ui groups auto "Android" --hostname "*android*"
724
+
725
+ # Match by network/SSID
726
+ ./ui groups auto "Guest Devices" --network "Guest"
727
+ ./ui groups auto "IoT Network" --network "IoT,Smart Home"
728
+
729
+ # Match by IP address or range
730
+ ./ui groups auto "Servers" --ip "192.168.1.100-200"
731
+ ./ui groups auto "VLAN10" --ip "10.0.10.0/24"
732
+ ./ui groups auto "Printers" --ip "192.168.1.50,192.168.1.51"
733
+
734
+ # Match by MAC prefix
735
+ ./ui groups auto "Ubiquiti" --mac "70:A7:41:*"
736
+
737
+ # Match by connection type
738
+ ./ui groups auto "Wireless" --type "wireless"
739
+ ./ui groups auto "Wired" --type "wired"
740
+
741
+ # Combine rules (AND logic between different types)
742
+ ./ui groups auto "Kids iPhones" --vendor "Apple" --name "*kid*"
743
+ ./ui groups auto "Wireless IoT" --vendor "Philips,LIFX" --type "wireless"
744
+
745
+ # Preview without creating
746
+ ./ui groups auto "Test" --vendor "Apple" --dry-run
747
+
748
+ # With description
749
+ ./ui groups auto "Apple Devices" --vendor "Apple" -d "All Apple products"
750
+ ```
751
+
752
+ #### Pattern Syntax
753
+
754
+ | Format | Example | Matches |
755
+ |--------|---------|---------|
756
+ | Exact | `Apple` | "Apple" only |
757
+ | Wildcard | `*phone*` | "iPhone", "Android Phone" |
758
+ | Prefix | `iPhone*` | "iPhone", "iPhone-12" |
759
+ | Suffix | `*-TV` | "Living-TV", "Bedroom-TV" |
760
+ | Regex | `~^iPhone-[0-9]+$` | "iPhone-1", "iPhone-12" |
761
+ | Multiple (OR) | `Apple,Samsung` | "Apple" or "Samsung" |
762
+
763
+ ### Managing Groups
764
+
765
+ ```bash
766
+ # List all groups
767
+ ./ui groups list
768
+ ./ui groups ls # Alias
769
+ ./ui groups list -o json
770
+
771
+ # Edit group
772
+ ./ui groups edit kids-devices -n "Children Devices" # Rename
773
+ ./ui groups edit kids-devices -d "New description" # Update description
774
+
775
+ # Delete group
776
+ ./ui groups delete kids-devices
777
+ ./ui groups delete kids-devices -y # Skip confirmation
778
+ ./ui groups rm kids-devices # Alias
779
+ ```
780
+
781
+ ### Bulk Actions with Groups
782
+
783
+ ```bash
784
+ # List clients in a group
785
+ ./ui lo clients list -g kids-devices
786
+ ./ui lo clients list -g apple-devices -o json
787
+
788
+ # Block all clients in a group
789
+ ./ui lo clients block -g kids-devices # With confirmation
790
+ ./ui lo clients block -g kids-devices -y # Skip confirmation
791
+ # Output: Blocked 3 clients (already blocked: 1, failed: 0)
792
+
793
+ # Unblock all clients in a group
794
+ ./ui lo clients unblock -g kids-devices
795
+ ./ui lo clients unblock -g kids-devices -y
796
+ # Output: Unblocked 3 clients (not blocked: 1, failed: 0)
797
+
798
+ # Kick all clients in a group
799
+ ./ui lo clients kick -g kids-devices
800
+ ./ui lo clients kick -g kids-devices -y
801
+ # Output: Kicked 3 clients (offline: 1, failed: 0)
802
+ ```
803
+
804
+ ### Import/Export
805
+
806
+ ```bash
807
+ # Export all groups to JSON
808
+ ./ui groups export
809
+ ./ui groups export -o groups-backup.json
810
+
811
+ # Import groups from file
812
+ ./ui groups import groups-backup.json
813
+ ./ui groups import groups-backup.json --replace # Replace all existing
814
+ ./ui groups import groups-backup.json -y # Skip confirmation
815
+ ```
816
+
817
+ ### Example: Parental Controls
818
+
819
+ ```bash
820
+ # Initial setup (one time)
821
+ ./ui groups create "Kids Devices" -d "Tablets and phones for the kids"
822
+ ./ui groups add kids-devices AA:BB:CC:DD:EE:FF -a "Timmy iPad"
823
+ ./ui groups add kids-devices 11:22:33:44:55:66 -a "Sarah Phone"
824
+ ./ui groups add kids-devices 22:33:44:55:66:77 -a "Gaming Console"
825
+
826
+ # Bedtime - block all kids devices
827
+ ./ui lo clients block -g kids-devices -y
828
+
829
+ # Morning - unblock all
830
+ ./ui lo clients unblock -g kids-devices -y
831
+
832
+ # Check status
833
+ ./ui lo clients list -g kids-devices
834
+ ```
835
+
836
+ ---
837
+
838
+ ## Claude Desktop Integration
839
+
840
+ Control your UniFi network using natural language through [Claude Desktop](https://claude.ai/download).
841
+
842
+ ### Setup
843
+
844
+ ```bash
845
+ # Install MCP server to Claude Desktop
846
+ ./ui mcp install
847
+
848
+ # Verify installation
849
+ ./ui mcp check
850
+
851
+ # View current configuration
852
+ ./ui mcp show
853
+
854
+ # Restart Claude Desktop to activate
855
+ ```
856
+
857
+ ### MCP Commands
858
+
859
+ ```bash
860
+ ./ui mcp install # Add to Claude Desktop config
861
+ ./ui mcp check # Verify setup and connectivity
862
+ ./ui mcp show # View current configuration
863
+ ./ui mcp remove # Remove from Claude Desktop
864
+ ```
865
+
866
+ ### Example Prompts
867
+
868
+ | You say... | Claude does... |
869
+ |------------|----------------|
870
+ | "How many devices are on my network?" | Counts clients by type |
871
+ | "What's my network health?" | Shows WAN/LAN/WLAN/VPN status |
872
+ | "What's my internet speed?" | Shows last speed test result |
873
+ | "Run a speed test" | Initiates new speed test |
874
+ | "Find my iPhone" | Searches for client by name |
875
+ | "Is the TV online?" | Checks client status |
876
+ | "Block the kids iPad" | Blocks specific client |
877
+ | "Unblock the kids iPad" | Unblocks client |
878
+ | "Block all kids devices" | Blocks entire group |
879
+ | "Restart the garage AP" | Restarts device |
880
+ | "Create a guest WiFi voucher" | Creates voucher |
881
+ | "What groups do I have?" | Lists all groups |
882
+ | "Show the kids devices group" | Shows group details |
883
+
884
+ ### Available Tools (21)
885
+
886
+ | Category | Tools | Description |
887
+ |----------|-------|-------------|
888
+ | **Status & Health** | `network_status` | Check API connectivity |
889
+ | | `network_health` | Site health summary |
890
+ | | `internet_speed` | Last speed test result |
891
+ | | `run_speedtest` | Run new speed test |
892
+ | | `isp_performance` | ISP metrics over time |
893
+ | **Counts & Lists** | `client_count` | Count clients by category |
894
+ | | `device_list` | List UniFi devices |
895
+ | | `network_list` | List networks/VLANs |
896
+ | **Lookups** | `find_client` | Find client by name/MAC |
897
+ | | `find_device` | Find device by name/MAC/IP |
898
+ | | `client_status` | Check if client is online/blocked |
899
+ | **Actions** | `block_client` | Block from network |
900
+ | | `unblock_client` | Restore access |
901
+ | | `kick_client` | Force disconnect |
902
+ | | `restart_device` | Reboot device |
903
+ | | `create_voucher` | Create guest WiFi code |
904
+ | **Groups** | `list_groups` | List all client groups |
905
+ | | `get_group` | Get group details |
906
+ | | `block_group` | Block all in group |
907
+ | | `unblock_group` | Unblock all in group |
908
+ | | `group_status` | Live status of group members |
909
+
910
+ ### Architecture
911
+
912
+ ```
913
+ ┌─────────────────┐
914
+ │ Claude Desktop │
915
+ └────────┬────────┘
916
+ │ MCP Protocol (stdio)
917
+
918
+ ┌─────────────────┐
919
+ │ MCP Server │ ← 21 AI-optimized tools
920
+ │ (ui_mcp) │
921
+ └────────┬────────┘
922
+ │ subprocess
923
+
924
+ ┌─────────────────┐
925
+ │ UI CLI │ ← All business logic
926
+ │ (ui_cli) │
927
+ └─────────────────┘
928
+ ```
929
+
930
+ See [MCP Documentation](src/ui_mcp/README.md) for full technical details.
931
+
932
+ ---
933
+
934
+ ## Output Formats
935
+
936
+ All commands support multiple output formats:
937
+
938
+ ```bash
939
+ ./ui devices list # Table (default, human-readable)
940
+ ./ui devices list -o json # JSON (for scripting)
941
+ ./ui devices list -o csv # CSV (for spreadsheets)
942
+ ./ui lo config show -o yaml # YAML (for config files)
943
+ ```
944
+
945
+ ### JSON for Scripting
946
+
947
+ ```bash
948
+ # Count devices
949
+ ./ui devices list -o json | jq 'length'
950
+
951
+ # Find offline devices
952
+ ./ui devices list -o json | jq '[.[] | select(.status == "offline")]'
953
+
954
+ # Get all client IPs
955
+ ./ui lo clients list -o json | jq -r '.[].ip'
956
+
957
+ # Get client MACs on Guest network
958
+ ./ui lo clients list -n Guest -o json | jq -r '.[].mac'
959
+
960
+ # Find high-traffic clients
961
+ ./ui lo clients list -o json | jq '[.[] | select(.tx_bytes > 1000000000)]'
962
+ ```
963
+
964
+ ### CSV for Spreadsheets
965
+
966
+ ```bash
967
+ # Export to CSV file
968
+ ./ui devices list -o csv > devices.csv
969
+ ./ui lo clients list -o csv > clients.csv
970
+ ./ui isp metrics -o csv > isp-metrics.csv
971
+ ```
972
+
973
+ ### CI/CD Usage
974
+
975
+ Spinners are automatically disabled when running in CI environments:
976
+
977
+ ```bash
978
+ # Automatically disabled when CI=true (GitHub Actions, etc.)
979
+ ./ui lo clients count -o json
980
+
981
+ # Explicitly disable spinner
982
+ UNIFI_NO_SPINNER=1 ./ui lo health -o json
983
+
984
+ # Also disabled when NO_COLOR is set
985
+ NO_COLOR=1 ./ui lo health
986
+ ```
987
+
988
+ ---
989
+
990
+ ## Command Reference
991
+
992
+ ### Top-Level Commands
993
+
994
+ ```
995
+ ./ui
996
+ ├── status # Check Cloud API connection
997
+ ├── version # Show CLI version
998
+ ├── speedtest # Run/view speed test
999
+ ├── hosts # Manage controllers (cloud)
1000
+ ├── sites # Manage sites (cloud)
1001
+ ├── devices # Manage devices (cloud)
1002
+ ├── isp # ISP metrics (cloud)
1003
+ ├── sdwan # SD-WAN configuration (cloud)
1004
+ ├── groups # Client groups (local storage)
1005
+ ├── local / lo # Local controller commands
1006
+ └── mcp # Claude Desktop integration
1007
+ ```
1008
+
1009
+ ### Cloud API Commands
1010
+
1011
+ <details>
1012
+ <summary><strong>Click to expand</strong></summary>
1013
+
1014
+ ```
1015
+ ./ui hosts
1016
+ ├── list # List all controllers
1017
+ └── get <ID> # Get controller details
1018
+
1019
+ ./ui sites
1020
+ └── list # List all sites
1021
+
1022
+ ./ui devices
1023
+ ├── list # List all devices
1024
+ │ ├── --host <ID> # Filter by controller
1025
+ │ └── --verbose # Show details
1026
+ └── count # Count devices
1027
+ └── --by <field> # Group by model/status/host
1028
+
1029
+ ./ui isp
1030
+ └── metrics # ISP performance metrics
1031
+ ├── --interval # 5m or 1h (default: 1h)
1032
+ └── --hours # Time range (default: 168)
1033
+
1034
+ ./ui sdwan
1035
+ ├── list # List SD-WAN configs
1036
+ ├── get <ID> # Get config details
1037
+ └── status <ID> # Deployment status
1038
+
1039
+ ./ui speedtest
1040
+ ├── (no args) # Get last result
1041
+ └── -r, --run # Run new test
1042
+ ```
1043
+
1044
+ </details>
1045
+
1046
+ ### Local Controller Commands
1047
+
1048
+ <details>
1049
+ <summary><strong>Click to expand</strong></summary>
1050
+
1051
+ ```
1052
+ ./ui lo [--timeout N] [-q/--quick]
1053
+
1054
+ ./ui lo health # Site health summary
1055
+
1056
+ ./ui lo clients
1057
+ ├── list # Connected clients
1058
+ │ ├── -w # Wired only
1059
+ │ ├── -W # Wireless only
1060
+ │ ├── -n <network> # Filter by network
1061
+ │ ├── -g <group> # Filter by group
1062
+ │ └── -v # Verbose
1063
+ ├── all # All clients (inc. offline)
1064
+ ├── get <name|MAC> # Client details
1065
+ ├── status <name|MAC> # Full client status
1066
+ ├── block <name|MAC> # Block client
1067
+ │ ├── -g <group> # Block all in group
1068
+ │ └── -y # Skip confirmation
1069
+ ├── unblock <name|MAC> # Unblock client
1070
+ │ ├── -g <group> # Unblock all in group
1071
+ │ └── -y # Skip confirmation
1072
+ ├── kick <name|MAC> # Disconnect client
1073
+ │ ├── -g <group> # Kick all in group
1074
+ │ └── -y # Skip confirmation
1075
+ ├── count # Count by category
1076
+ │ ├── --by <field> # type/network/vendor/ap/experience
1077
+ │ └── -a # Include offline
1078
+ └── duplicates # Find duplicate names
1079
+
1080
+ ./ui lo devices
1081
+ ├── list # List network devices
1082
+ │ └── -v # Verbose
1083
+ ├── get <ID|MAC|name> # Device details
1084
+ ├── restart <device> # Restart device
1085
+ │ └── -y # Skip confirmation
1086
+ ├── upgrade <device> # Upgrade firmware
1087
+ │ └── -y # Skip confirmation
1088
+ ├── locate <device> # Toggle locate LED
1089
+ │ └── --off # Turn off LED
1090
+ └── adopt <MAC> # Adopt new device
1091
+
1092
+ ./ui lo networks
1093
+ ├── list # List networks/VLANs
1094
+ │ └── -v # Verbose
1095
+ └── get <ID> # Network details
1096
+
1097
+ ./ui lo firewall
1098
+ ├── list # List firewall rules
1099
+ │ ├── --ruleset # Filter by ruleset
1100
+ │ └── -v # Verbose
1101
+ └── groups # List address/port groups
1102
+ └── -v # Show members
1103
+
1104
+ ./ui lo portfwd
1105
+ └── list # List port forwards
1106
+ └── -v # Verbose
1107
+
1108
+ ./ui lo vouchers
1109
+ ├── list # List guest vouchers
1110
+ │ └── -v # Verbose
1111
+ ├── create # Create voucher(s)
1112
+ │ ├── -c <count> # Number to create
1113
+ │ ├── -d <minutes> # Duration
1114
+ │ ├── -q <MB> # Data quota
1115
+ │ ├── --up <kbps> # Upload limit
1116
+ │ ├── --down <kbps> # Download limit
1117
+ │ └── -n <note> # Add note
1118
+ └── delete <code> # Delete voucher
1119
+ └── -y # Skip confirmation
1120
+
1121
+ ./ui lo dpi
1122
+ ├── stats # Site DPI statistics
1123
+ │ ├── -l <limit> # Number of apps
1124
+ │ └── -v # Verbose
1125
+ └── client <name|MAC> # Per-client DPI
1126
+
1127
+ ./ui lo stats
1128
+ ├── daily # Daily traffic stats
1129
+ │ └── --days <n> # Number of days
1130
+ └── hourly # Hourly traffic stats
1131
+ └── --hours <n> # Number of hours
1132
+
1133
+ ./ui lo events
1134
+ └── list # Recent events
1135
+ ├── -l <limit> # Number of events
1136
+ └── -v # Verbose
1137
+
1138
+ ./ui lo config
1139
+ └── show # Export running config
1140
+ ├── -o <format> # table/json/yaml
1141
+ ├── -s <section> # networks/wireless/firewall/devices/portfwd/dhcp/routing
1142
+ ├── -v # Include IDs
1143
+ └── --show-secrets # Include passwords
1144
+ ```
1145
+
1146
+ </details>
1147
+
1148
+ ### Client Groups Commands
1149
+
1150
+ <details>
1151
+ <summary><strong>Click to expand</strong></summary>
1152
+
1153
+ ```
1154
+ ./ui groups
1155
+ ├── list # List all groups
1156
+ ├── ls # Alias for list
1157
+ ├── create <name> # Create static group
1158
+ │ └── -d <desc> # Description
1159
+ ├── show <name> # Show group details
1160
+ ├── delete <name> # Delete group
1161
+ │ └── -y # Skip confirmation
1162
+ ├── rm <name> # Alias for delete
1163
+ ├── edit <name> # Edit group
1164
+ │ ├── -n <name> # New name
1165
+ │ └── -d <desc> # New description
1166
+ ├── add <group> <MAC> # Add member(s)
1167
+ │ └── -a <alias> # Set alias (single MAC only)
1168
+ ├── remove <group> <id> # Remove member (by MAC or alias)
1169
+ ├── alias <grp> <id> # Set/clear member alias
1170
+ │ └── --clear # Clear alias
1171
+ ├── members <group> # List members
1172
+ ├── clear <group> # Remove all members
1173
+ │ └── -y # Skip confirmation
1174
+ ├── auto <name> # Create auto group
1175
+ │ ├── --vendor # Match by vendor/OUI
1176
+ │ ├── --name # Match by client name
1177
+ │ ├── --hostname # Match by hostname
1178
+ │ ├── --network # Match by network/SSID
1179
+ │ ├── --ip # Match by IP/range/CIDR
1180
+ │ ├── --mac # Match by MAC prefix
1181
+ │ ├── --type # Match by wired/wireless
1182
+ │ ├── -d <desc> # Description
1183
+ │ └── --dry-run # Preview without creating
1184
+ ├── export # Export to JSON
1185
+ │ └── -o <file> # Output file
1186
+ └── import <file> # Import from JSON
1187
+ ├── --replace # Replace all existing
1188
+ └── -y # Skip confirmation
1189
+ ```
1190
+
1191
+ </details>
1192
+
1193
+ ### MCP Commands
1194
+
1195
+ ```
1196
+ ./ui mcp
1197
+ ├── install # Add to Claude Desktop config
1198
+ ├── check # Verify setup
1199
+ ├── show # View current config
1200
+ └── remove # Remove from Claude Desktop
1201
+ ```
1202
+
1203
+ ---
1204
+
1205
+ ## Data Storage
1206
+
1207
+ UI-CLI stores local data in `~/.config/ui-cli/`:
1208
+
1209
+ | File | Purpose |
1210
+ |------|---------|
1211
+ | `session.json` | Cached controller login session |
1212
+ | `groups.json` | Client groups definitions |
1213
+
1214
+ ### Session Management
1215
+
1216
+ Sessions are cached to avoid repeated logins:
1217
+
1218
+ ```bash
1219
+ # Force new session (if having auth issues)
1220
+ rm ~/.config/ui-cli/session.json
1221
+ ./ui lo health
1222
+ ```
1223
+
1224
+ ### Groups Storage
1225
+
1226
+ Groups are stored locally and don't require network access to manage:
1227
+
1228
+ ```bash
1229
+ # View storage location
1230
+ cat ~/.config/ui-cli/groups.json
1231
+
1232
+ # Backup groups
1233
+ ./ui groups export -o ~/groups-backup.json
1234
+
1235
+ # Restore groups
1236
+ ./ui groups import ~/groups-backup.json
1237
+ ```
1238
+
1239
+ ---
1240
+
1241
+ ## Troubleshooting
1242
+
1243
+ ### Common Errors
1244
+
1245
+ | Error | Solution |
1246
+ |-------|----------|
1247
+ | "API key not configured" | Add `UNIFI_API_KEY` to `.env` |
1248
+ | "Invalid API key" | Regenerate key at [unifi.ui.com](https://unifi.ui.com) → Settings → API |
1249
+ | "Connection timeout" (cloud) | Check internet access to `api.ui.com` |
1250
+ | "Controller URL not configured" | Add `UNIFI_CONTROLLER_URL` to `.env` |
1251
+ | "Invalid username or password" | Verify credentials work in UniFi web UI |
1252
+ | "SSL certificate verify failed" | Set `UNIFI_CONTROLLER_VERIFY_SSL=false` |
1253
+ | "Connection timeout" (local) | Use `./ui lo --timeout 60 health` |
1254
+ | "Session expired" | Delete `~/.config/ui-cli/session.json` |
1255
+ | "Client not found" | Try partial name match or use MAC address |
1256
+ | "DPI unavailable" | Enable DPI in controller settings |
1257
+
1258
+ ### Debug Tips
1259
+
1260
+ ```bash
1261
+ # Verbose output for more details
1262
+ ./ui lo clients list -v
1263
+ ./ui lo devices list -v
1264
+
1265
+ # JSON output for debugging
1266
+ ./ui lo health -o json
1267
+
1268
+ # Check configuration
1269
+ cat .env
1270
+
1271
+ # Check session state
1272
+ cat ~/.config/ui-cli/session.json
1273
+
1274
+ # Force fresh session
1275
+ rm ~/.config/ui-cli/session.json
1276
+ ```
1277
+
1278
+ ### Getting Help
1279
+
1280
+ ```bash
1281
+ # General help
1282
+ ./ui --help
1283
+
1284
+ # Command-specific help
1285
+ ./ui lo --help
1286
+ ./ui lo clients --help
1287
+ ./ui groups --help
1288
+ ./ui mcp --help
1289
+ ```
1290
+
1291
+ ---
1292
+
1293
+ ## Documentation
1294
+
1295
+ | Resource | Description |
1296
+ |----------|-------------|
1297
+ | [Online Documentation](https://vedanta.github.io/ui-cli) | Full documentation site |
1298
+ | [User Guide](USERGUIDE.md) | Detailed usage examples |
1299
+ | [Client Groups](docs/groups.md) | Groups feature guide |
1300
+ | [MCP Server](src/ui_mcp/README.md) | Claude Desktop integration |
1301
+ | [MCP Architecture](src/ui_mcp/ARCHITECTURE.md) | Technical design |
1302
+ | [Roadmap](ROADMAP.md) | Planned features |
1303
+ | [Changelog](CHANGELOG.md) | Version history |
1304
+
1305
+ ---
1306
+
1307
+ ## Contributing
1308
+
1309
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
1310
+
1311
+ ---
1312
+
1313
+ ## License
1314
+
1315
+ MIT License - see [LICENSE](LICENSE) for details.