set_port_state
set_port_state
Section titled “set_port_state”Override settings on a single switch port.
Side effects:
- Modifies one port’s
enable,poe_mode, and/orportconf_idon the named switch without touching the others. - Disabling a port immediately drops the link; powered devices on that port (PoE cameras, APs) will go offline.
- Mutates controller state. Use dry_run=True to preview the change without applying.
Example
Section titled “Example”set_port_state(device_mac="aa:bb:cc:00:00:01", port_idx=5, enable=True, poe_mode="auto")Parameters
Section titled “Parameters”| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
device_mac | string | yes | — | Switch MAC address (from list_devices). |
port_idx | integer | yes | — | 1-based port index. |
enable | `boolean | null` | no | null |
poe_mode | string | no | "" | "auto", "passive24v", "passthrough", "off", or empty to leave unchanged. |
portconf_id | string | no | "" | _id of a port profile to apply, or empty to leave unchanged. |
controller | string | no | ”default” | Name of the UniFi controller to target. Defaults to "default". |
dry_run | boolean | no | false | Preview the change without applying it. Returns the predicted change set. |