Skip to content

set_port_state

Override settings on a single switch port.

Side effects:

  • Modifies one port’s enable, poe_mode, and/or portconf_id on 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.
set_port_state(device_mac="aa:bb:cc:00:00:01", port_idx=5, enable=True, poe_mode="auto")
ParameterTypeRequiredDefaultDescription
device_macstringyesSwitch MAC address (from list_devices).
port_idxintegeryes1-based port index.
enable`booleannull`nonull
poe_modestringno"""auto", "passive24v", "passthrough", "off", or empty to leave unchanged.
portconf_idstringno""_id of a port profile to apply, or empty to leave unchanged.
controllerstringno”default”Name of the UniFi controller to target. Defaults to "default".
dry_runbooleannofalsePreview the change without applying it. Returns the predicted change set.