Devices
About 1229 words
The devices subject covers the UniFi hardware of a site: gateways, switches and access points. Use it to see what's online, find a device in the rack, restart it, update its firmware, or adopt a new one.
List devices
$ unifi devices get
NAME TYPE MODEL IP STATE CLIENTS UPTIME VERSION UPLINK
● Dream Machine Pro… Gateway UDM Pro M… 192.168.1.1 Online 0 41d 5h 4.1.13 -
● Core Switch Switch USW Pro M… 192.168.99.2 Online 14 41d 4h 7.2.123 Dream Machine P…
● Garage Switch Switch USW Lite … 192.168.99.4 Online 3 41d 4h 7.2.123 Core Switch #13
● Office Switch Switch USW Flex … 192.168.99.3 Online 5 19d 7h 2.1.6 ↑ Core Switch #18
▲ USW Flex Mini Switch USW Flex … 192.168.1.47 Pending - - 2.1.2 -
✗ AP Garden AP U7 Outdoor 192.168.99.14 Offline - - 8.0.62 Garage Switch #1
● AP Hallway Mesh AP U6 Mesh 192.168.99.13 Online 9 6d 11h 6.6.77 AP Living Room ≈
● AP Living Room AP U7 Pro 192.168.99.11 Online 11 23d 2h 8.0.62 Core Switch #17
● AP Office AP U7 Pro Max 192.168.99.12 Online 4 19d 7h 8.0.62 Office Switch #2The mark in the first column is the state: a dot for online, a triangle for a device that waits for adoption, a cross for offline. An arrow next to the firmware version (2.1.6 ↑) means an update is available. --output wide adds the MAC address, CPU and memory load, total traffic and the version an update would install. On a terminal too narrow for all of that it hides the least important columns and says how many on standard error; piped, it prints them all.
The questions you usually have map to one flag each:
unifi devices get --offline # what's down
unifi devices get --upgradable # what has a firmware update waiting
unifi devices get --pending # what waits for adoption
unifi devices get --type ap # gateway, switch or ap
unifi devices get --sort cpu --limit 3 # the busiest devices--sort takes name, type, ip, model, state, clients, uptime, cpu, memory or traffic. --filter works as it does for clients, on the fields clients, cpuPercent, id, ip, legacyId, mac, memoryPercent, model, name, ports, radios, rxBytes, rxRateBps, state, txBytes, txRateBps, type, upgradable, upgradeVersion, uplink, uptimeSeconds and version. uptime is accepted as an alias that takes durations such as 7d:
unifi devices get --filter 'clients > 10'
unifi devices get --filter 'type == "switch" && cpuPercent > 50'
unifi devices get --filter 'state == "ONLINE" && uptime < 7d' # restarted in the last weekShow one device
A device answers to its name, MAC address, IP address or ID.
$ unifi devices describe "Core Switch"
Core Switch ● Online
Identity System
Model USW Pro Max 24 PoE Firmware 7.2.123
Type Switch Uptime 41d 4h
MAC 02:15:6d:00:01:02 Clients 14
IP 192.168.99.2 Throughput ↓ 170 Mbps ↑ 28.2 Mbps
Uplink Dream Machine Pro Max #11, 10 GbE Traffic ↓ 4.6 TB ↑ 2.2 TB
Load
CPU ███░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 10%
Memory █████████████░░░░░░░░░░░░░░░░░░░░░░ 38%
╭─ Ports ───────────────────────────────────────────── 18/26 up · PoE 68.9 W ─╮
│ 1 3 5 7 9 11 13 15 17 19 21 23 25 │
│ ▄ ▄ ▂ ▄ ▂ϟ ▂ϟ ▄ □ ▆ϟ ▆ ▂ × █↑ │
│ ▄ ▂ ▄ □ ▂ϟ ▂ϟ □ □ ▆ϟ □ □ □ █ │
│ 2 4 6 8 10 12 14 16 18 20 22 24 26 │
│ │
│ █ 10 GbE ▆ 2.5 GbE ▄ 1 GbE ▂ 100 FE □ down × disabled ϟ PoE ↑ uplink │
╰─────────────────────────────────────────────────────────────────────────────╯
Ports 18 of 26 up, 1 disabled
PoE 68.9 W in use across 6 ports
Top draw 38.5 W on port 18 Office SwitchSwitches and gateways show their faceplate and PoE budget. Access points show their radios instead:
$ unifi devices describe "AP Living Room"
...
Radios
BAND CHANNEL WIDTH TX POWER CLIENTS UTILIZATION INTERFERENCE SATISFACTION
2.4 GHz 6 20 MHz 17 dBm 7 ███░░░░░░░ 34% 21% 93%
5 GHz 44 80 MHz 23 dBm 3 ██░░░░░░░░ 18% 6% 97%
6 GHz 37 160 MHz 24 dBm 1 █░░░░░░░░░ 4% 1% 99%To work with a switch's ports, continue in the ports guide.
Find a device
$ unifi devices locate "Office Switch"
✓ The LED of Office Switch is blinking.
→ Stop it with `unifi devices locate "Office Switch" --off`.The LED keeps blinking until you pass --off. locate takes several devices, which helps when you're tracing a cable between two of them.
Restart a device
$ unifi devices restart "AP Office" "AP Living Room" --yes
✓ Restarting AP Office.
✓ Restarting AP Living Room.
→ Watch it come back with `unifi devices get`.Everything connected through a device loses its connection until it's back, which usually takes one to three minutes. Restarting a device that is online therefore asks for confirmation; --yes skips the question, and without a terminal the command refuses to run unless --yes is there. A device that is offline can't be restarted from here, and the error says what to check instead.
With several devices, one that fails doesn't stop the others. Each device gets its own line, and the command exits with code 1 when any of them failed:
$ unifi devices restart "AP Office" "AP Garden" --yes
✓ Restarting AP Office.
→ Watch it come back with `unifi devices get`.
✗ The device "AP Garden" is offline, so it cannot be restarted.Think about what hangs off the device before you restart it. Restarting Core Switch in the demo site also cuts off two switches and three access points downstream of it; unifi topology shows the tree.
Update firmware
$ unifi devices get --upgradable
NAME TYPE MODEL IP STATE CLIENTS UPTIME VERSION UPLINK
● Office Switch Switch USW Flex 2.5G 8 PoE 192.168.99.3 Online 5 19d 7h 2.1.6 ↑ Core Switch #18
$ unifi devices upgrade --all --yes
DEVICE MODEL INSTALLED UPDATE RESULT
Office Switch USW Flex 2.5G 8 PoE 2.1.6 → 2.1.8 started
✓ Started the firmware update of 1 device.
→ Follow the progress with `unifi devices get`.A device restarts while it updates, so updating a device that is online asks for confirmation. --all lists every device with an update and asks once before it starts. Name several devices to update just those: unifi devices upgrade "Office Switch" "AP Office".
Several devices are updated from the edge of the network inwards: access points and the switches furthest from the gateway first, the gateway last, so that no device loses its uplink in the middle of its own update. A device that fails doesn't stop the others; the command reports every device and exits with an error if one failed.
A device that already runs its latest firmware is left alone, with a notice and exit code 0.
To have devices update themselves at night instead, see unifi settings updates in the settings guide.
Adopt and remove devices
A factory-new device on the network shows up as pending:
$ unifi devices get --pending
NAME TYPE MODEL IP STATE CLIENTS UPTIME VERSION UPLINK
▲ USW Flex Mini Switch USW Flex Mini 192.168.1.47 Pending - - 2.1.2 -
$ unifi devices adopt "USW Flex Mini"
✓ Adopting USW Flex Mini.
→ Adoption takes a minute or two; follow it with `unifi devices get`.unifi devices forget <device> is the reverse and it's drastic: the controller removes the device from the site and resets it to factory defaults, so it has to be adopted and configured again. It always asks for confirmation.
Use the data in scripts
# Names of offline devices, one per line
unifi devices get --offline --output json | jq -r '.[].name'
# Exit non-zero from a monitoring check when anything is offline
test "$(unifi devices get --offline --output json | jq length)" -eq 0