System

async OPNsenseClient.toggle_interface(if_name, toggle_on_off=None)

Toggle an interface’s enabled state and apply the resulting configuration.

Requires firmware >= 26.7.6 and sends only the enable flag. Refuses pending or unreadable interface work; coordinate concurrent changes. Failure or cancellation can leave pending work: resolve it in the OPNsense UI before retrying. Applying changes can reset queued interfaces’ advanced/file-based DHCP settings or disconnect this client.

Parameters:
  • if_name (str) – Logical interface identifier such as wan, lan, or opt8.

  • toggle_on_off (str | None, optional) – Target state. Use on to enable, off to disable, or None or toggle to invert the current state.

Returns:

True when already matching, or when the Router

acknowledged the save (saved) and confirmed the apply; False when refused, the save was not acknowledged (no apply is sent) or the apply was not confirmed. A suppressed exception returns None. With throw_errors enabled, invalid arguments raise OPNsenseInvalidArgument and transport failures raise OPNsenseError subclasses.

Return type:

bool | None

async OPNsenseClient.get_device_unique_id(expected_id=None)

Return the stable device identifier derived from physical MAC addresses.

Parameters:

expected_id (str | None, optional) – Previously known identifier to prefer when it is still present among physical interface MAC addresses.

Returns:

MAC-address-based identifier with colons replaced by

underscores. Returns expected_id when it still matches a physical interface, otherwise the first sorted physical MAC identifier. Returns None when no physical MAC addresses are available and throw_errors is disabled.

Return type:

str | None

async OPNsenseClient.get_system_info()

Return basic OPNsense system identity information.

Returns:

Mapping containing the OPNsense host name when

the system-information endpoint is available.

Return type:

dict[str, Any]

async OPNsenseClient.get_carp()

Fetch one CARP snapshot and return both interfaces and aggregate summary.

Returns:

Snapshot payload containing interfaces and status_summary derived from one backend fetch.

Return type:

dict[str, Any]

async OPNsenseClient.system_reboot()

Reboot OPNsense.

Returns:

True when the operation succeeds; otherwise, False.

Return type:

bool

async OPNsenseClient.system_halt()

Shutdown OPNsense.

Return type:

None

async OPNsenseClient.toggle_carp_maintenance_mode()

Toggle persistent CARP maintenance mode.

Returns:

True when the operation succeeds; otherwise, False.

Return type:

bool

async OPNsenseClient.send_wol(interface, mac)

Send a wake on lan packet to the specified MAC address.

Parameters:
  • interface (str) – OPNsense interface identifier used as the Wake-on-LAN egress interface.

  • mac (str) – MAC address to use for Wake-on-LAN.

Returns:

True when the operation succeeds; otherwise, False.

Return type:

bool

async OPNsenseClient.get_notices()

Return active OPNsense dashboard notices.

Returns:

Mapping with pending_notices_present and a

pending_notices list. Each notice includes its message, subject id, and parsed created_at timestamp when available.

Return type:

dict[str, Any]

async OPNsenseClient.close_notice(id)

Close selected notices.

Parameters:

id (str) – Identifier of the notice to close.

Returns:

True when the operation succeeds; otherwise, False.

Return type:

bool

async OPNsenseClient.reload_interface(if_name)

Reload the specified interface.

Parameters:

if_name (str) – Interface name to select rows for.

Returns:

True when the operation succeeds; otherwise, False.

Return type:

bool

async OPNsenseClient.get_certificates()

Return trust certificates known to OPNsense.

Returns:

Mapping keyed by certificate description. Each

certificate contains its UUID, issuer reference, RFC 3280 purpose, in-use flag, and validity timestamps.

Return type:

dict[str, Any]