Skip to main content

Unifi

@mgreten/unifiv2026.11.06.1· MIT· 15d agoBEHAVIORS
01README

Manage a Ubiquiti UniFi Dream Machine (UDM / UDM Pro / UDM SE) via the legacy Network API: firewall groups, firewall rules, clients, client diagnostics, PoE device restarts, and networks. Complements @stack72/ubiquity (which focuses on traffic collection) by enabling configuration-as-data workflows: sync existing groups/rules into the swamp data model, reconcile group membership, create or delete firewall rules, toggle rule state, safely power-cycle a wired client's resolved switch port, and capture read-only client roaming snapshots.

02Behaviors4
@mgreten/unifi/clientv2026.11.06.1client.ts
fn sync(activeOnly?: boolean)
List all known clients (active + configured) and store one data per client.
ArgumentTypeDescription
activeOnly?booleanIf true, only fetch currently-connected clients (/stat/sta).
fn power-cycle-poe(device: string, expectedSwitch?: string, expectedPort?: coerce.number)
Restart an active wired device by exact name, hostname, or MAC by power-cycling its resolved UniFi switch PoE port.
ArgumentTypeDescription
devicestringExact UniFi client name, hostname, or MAC address, e.g. front-door-camera
expectedSwitch?stringOptional safety assertion: expected switch name or MAC
expectedPort?coerce.numberOptional safety assertion: expected physical switch port
fn inspect(mac?: string, ip?: string)
Capture a read-only point-in-time roaming, AP, and health snapshot for one active client.
ArgumentTypeDescription
mac?stringClient MAC address, preferred.
ip?stringClient IP address, used as fallback.

Resources

client(infinite)— A client (device) known to the UniFi controller.
power_cycle(infinite)— An accepted UniFi PoE power-cycle action and its resolved client/switch topology.
inspection(infinite)— A point-in-time read-only client roaming and health inspection snapshot.
@mgreten/unifi/firewall-groupv2026.07.27.1firewall_group.ts
fn sync()
List all firewall groups on the controller and store one data per group (factory).
fn set-members(id?: string, name?: string, members: array)
Replace the members of a firewall group with the provided list. Identify the group by id or by name.
ArgumentTypeDescription
id?stringGroup _id (preferred)
name?stringGroup name (resolved if id is omitted)
membersarrayFull replacement member list (MACs, IPs, CIDRs, or ports)

Resources

group(infinite)— A UniFi firewall group (address/port group).
@mgreten/unifi/firewall-rulev2026.07.27.1firewall_rule.ts
fn sync(ruleset?: string)
List all firewall rules on the controller and store one data per rule (factory).
ArgumentTypeDescription
ruleset?stringFilter by ruleset, e.g. LAN_IN, LAN_OUT, WAN_OUT, WAN_LOCAL
fn create(name: string, ruleset: enum, action: enum, protocol?: string, enabled?: boolean, logging?: boolean, rule_index?: number, src_firewallgroup_ids?: array, dst_firewallgroup_ids?: array, src_address?: string, dst_address?: string, src_networkconf_id?: string, dst_networkconf_id?: string, src_port?: string, dst_port?: string, state_new?: boolean, state_established?: boolean, state_invalid?: boolean, state_related?: boolean)
Create a new firewall rule. rule_index is auto-assigned (next free index in the ruleset) when omitted.
ArgumentTypeDescription
namestring
rulesetenum
actionenum
protocol?string
enabled?boolean
logging?boolean
rule_index?number
src_firewallgroup_ids?array
dst_firewallgroup_ids?array
src_address?string
dst_address?string
src_networkconf_id?string
dst_networkconf_id?string
src_port?string
dst_port?string
state_new?boolean
state_established?boolean
state_invalid?boolean
state_related?boolean
fn delete(id: string)
Delete a firewall rule by id on the UDM. Local data for the rule is not removed
ArgumentTypeDescription
idstring
fn toggle-enabled(id: string, enabled: boolean)
Enable or disable a rule by id.
ArgumentTypeDescription
idstring
enabledboolean

Resources

rule(infinite)— A UniFi legacy firewall rule.
@mgreten/unifi/networkv2026.07.27.1network.ts
fn sync()
List all configured networks and store one data per network (factory).

Resources

network(infinite)— A configured UniFi network (VLAN/subnet).
03Previous Versions8
2026.10.14.1MIT(was none)

Modified 3 behaviors

2026.08.03.1

Add exact UniFi IDS/IPS event investigation across Network 10.x traffic flows and system logs plus the legacy IDS endpoint. Preserve matched raw records, paginate supported APIs, tolerate unsupported endpoints, and distinguish incomplete searches from definitive absence.

Modified 1 behaviors

2026.07.27.1

Modified 1 behaviors

2026.07.22.1

Add TOTP authentication support for MFA-enabled UniFi accounts.

2026.07.16.1

Rebuild against swamp CLI 20260716

2026.06.27.2
2026.06.27.1
2026.05.18.1
04Stats
A
100 / 100
Downloads
52
Archive size
24.7 KB
  • Has README or module doc2/2earned
  • README has a code example1/1earned
  • README is substantive1/1earned
  • Most symbols documented1/1earned
  • No slow types (deprecated)1/1earned
  • Dependencies pass trust audit2/2earned
  • Docs keep secrets in a vault1/1earned
  • Has description1/1earned
  • Platform support declared (or universal)2/2earned
  • License2/2earned
  • Verified public repository2/2earned
05Platforms