Skip to content

Core Components

⚙️ Core Components

Core client classes and API interface for WyreStorm NetworkHD devices.

🎛️ NHD API Interface

Typed wrapper for all NHD command groups.

Provides organized access to all NetworkHD API commands, grouped by functionality. Each command group contains related commands for a specific domain.

This class supports any NetworkHD client implementation, including SSH and RS232 clients.

Parameters:

Name Type Description Default
client _BaseNetworkHDClient

A NetworkHD client instance (NetworkHDClientSSH, NetworkHDClientRS232, etc.)

required

Raises:

Type Description
TypeError

If client is not a NetworkHD client.

Example
from wyrestorm_networkhd import NetworkHDClientSSH, NHDAPI

# Create a client
client = NetworkHDClientSSH(
    host="192.168.1.100",
    port=10022,
    username="admin",
    password="password",
    ssh_host_key_policy="warn",
)

# Create API wrapper
api = NHDAPI(client)

# Use command groups
await api.api_query.config_get_device_info()

🔌 RS232 Client

RS232 client for NetworkHD devices with simplified architecture.

NetworkHDClientRS232

NetworkHDClientRS232(port: str, baudrate: int, timeout: float = 10.0, *, circuit_breaker_timeout: float | None = None, heartbeat_interval: float | None = None, message_dispatcher_interval: float = 0.05, **serial_kwargs: Any)

Bases: _BaseNetworkHDClient

RS232 client for NetworkHD devices.

Provides a simplified interface for connecting to NetworkHD devices via RS232, with automatic message dispatching and notification handling.

A serial link has no keepalive: a failed write marks the connection as lost (is_connected() returns False and the next command raises ConnectionLostError), but a cable that is pulled silently shows up only as commands timing out.

Parameters:

Name Type Description Default
port str

The serial port (e.g., '/dev/ttyUSB0' on Linux, 'COM1' on Windows).

required
baudrate int

The baud rate for serial communication.

required
timeout float

Write timeout in seconds (default: 10.0).

10.0
circuit_breaker_timeout float | None

Deprecated and ignored (emits DeprecationWarning); removed in 4.0.

None
heartbeat_interval float | None

Deprecated and ignored (emits DeprecationWarning); removed in 4.0.

None
message_dispatcher_interval float

Sleep interval in seconds for the message dispatcher loop when nothing is readable (default: 0.05).

0.05
**serial_kwargs Any

Additional async_pyserial.SerialPortOptions attributes (bytesize, stopbits, parity, read_timeout, write_timeout, read_bufsize).

{}

Raises:

Type Description
ValueError

If any parameters are invalid.

🔌 SSH Client

SSH client for NetworkHD devices with simplified architecture.

normalize_fingerprints

normalize_fingerprints(value: str | Sequence[str]) -> tuple[str, ...]

Parse SSH host key SHA256 fingerprints into canonical form.

Accepts "SHA256:" or bare "", with or without "=" padding. A string may hold several, separated by commas, whitespace or newlines, and may be the output of ssh-keygen -lf (e.g. 256 SHA256:... [host]:10022 (ECDSA)): other words on such lines are ignored.

Parameters:

Name Type Description Default
value str | Sequence[str]

A string, or a sequence of strings, holding one or more fingerprints.

required

Returns:

Type Description
tuple[str, ...]

The fingerprints as "SHA256:", duplicates removed, in input order.

Raises:

Type Description
ValueError

If no fingerprint is found, a "SHA256:" token is not a valid SHA-256 digest, or an item is not a string.

NetworkHDClientSSH

NetworkHDClientSSH(host: str, port: int, username: str, password: str, ssh_host_key_policy: HostKeyPolicy, timeout: float = 10.0, *, circuit_breaker_timeout: float | None = None, heartbeat_interval: float | None = None, message_dispatcher_interval: float = 0.1, host_key_fingerprints: str | Sequence[str] | None = None)

Bases: _BaseNetworkHDClient

SSH client for NetworkHD devices.

Provides a simplified interface for connecting to NetworkHD devices via SSH, with automatic message dispatching and notification handling.

Parameters:

Name Type Description Default
host str

The hostname or IP address of the device.

required
port int

The SSH port number.

required
username str

The SSH username.

required
password str

The SSH password.

required
ssh_host_key_policy HostKeyPolicy

SSH host key verification policy. Must be one of: 'auto_add', 'reject', or 'warn'.

required
timeout float

Connection timeout in seconds (default: 10.0).

10.0
circuit_breaker_timeout float | None

Deprecated and ignored (emits DeprecationWarning); removed in 4.0.

None
heartbeat_interval float | None

Deprecated and ignored (emits DeprecationWarning); removed in 4.0. SSH keepalive packets are sent every 30 s instead.

None
message_dispatcher_interval float

Sleep interval in seconds for the message dispatcher loop when nothing is readable (default: 0.1).

0.1
host_key_fingerprints str | Sequence[str] | None

SHA256 fingerprint(s) of the controller's SSH host key, in any form normalize_fingerprints accepts. When given, only a matching host key is accepted, checked before the password is sent, and ssh_host_key_policy is ignored; a mismatch raises HostKeyMismatchError. None (default) leaves host key checking to ssh_host_key_policy. Also a settable attribute, read at every connect: assign a tuple from normalize_fingerprints (or None) on an existing client, e.g. after trusting host_key_fingerprint on first use, and the next connect or reconnect is checked against it.

None

Raises:

Type Description
ValueError

If required parameters are missing or invalid.

host_key_fingerprint property

host_key_fingerprint: str | None

SHA256 fingerprint ("SHA256:") of the host key presented on the last successful connect.

Set whether or not fingerprints are pinned; None before the first successful connect. Pass it as host_key_fingerprints on later connections to trust the controller on first use.