Nut - v1.0.0
    Preparing search index...

    Class RawNUTClient

    Reserved for advanced uses, use NUTClient

    Hierarchy

    Index
    defaultMaxListeners: number
    • get client(): Socket | TLSSocket

      Get the underlying TCP or TLS socket.

      Returns Socket | TLSSocket

      The TLS socket if TLS is active, otherwise the TCP socket

      This exposes the internal socket for advanced use cases (e.g., checking readyState). Direct manipulation of the socket may break client invariants. Use with caution.

    • Authenticate with the NUT server using username and password.

      Parameters

      • username: string
      • password: string

      Returns Promise<void>

      Error if authentication fails

    • Destroy the client and release all resources. After calling destroy(), the client cannot be reused.

      • Destroys the TCP socket (and TLS socket if active)
      • Kills the command queue
      • Sets connected = false

      Safe to call multiple times (idempotent).

      Returns void

    • Type Parameters

      Parameters

      Returns boolean

    • Type Parameters

      Returns U[]

    • Force a shutdown on the UPS (set the FSD flag). Used by upsmon primary to signal secondaries to shut down before power loss.

      Parameters

      • ups: string

        The name of the UPS

      Returns Promise<string>

      The server response (e.g., "OK FSD-SET")

      Requires master or FSD permission in upsd.users. Use with caution.

    • Get the description of an instant command. Returns a human-readable description of the command.

      Parameters

      • ups: string
      • command: string

      Returns Promise<string>

    • Check if this client is master for the UPS

      Parameters

      • ups: string

      Returns Promise<boolean>

    • Returns number

    • Get the number of clients logged into a UPS. Returns the count of active logins.

      Parameters

      • ups: string

      Returns Promise<number>

    • Get the status of a previously tracked write command by its UUID.

      After enabling tracking via setTracking, write commands return OK TRACKING <uuid>. This method polls the server for the outcome of that specific command.

      Parameters

      • uuid: string

        The tracking UUID returned by a write command

      Returns Promise<string>

      'PENDING' if the command is still executing, 'SUCCESS' if it completed successfully, or 'ERR' if it failed

      Requires NUT 2.8.0+ (protocol v1.3) on the server.

    • Get the description of a UPS (from ups.conf desc= field).

      Parameters

      • ups: string

        The name of the UPS

      Returns Promise<string>

      The UPS description string, or "Unavailable" if not configured

    • Get the current value of a variable for a UPS. Returns the variable value as a string.

      Parameters

      • ups: string
      • variable: string

      Returns Promise<string>

    • Get the description of a variable for a UPS. Returns a human-readable description of the variable.

      Parameters

      • ups: string
      • variable: string

      Returns Promise<string>

    • Get the list of valid enum values for a variable. Returns an array of valid values for ENUM-type variables.

      Parameters

      • ups: string
      • variable: string

      Returns Promise<string[]>

    • Get the valid range for a variable. Returns an array of valid ranges for RANGE-type variables.

      Parameters

      • ups: string
      • variable: string

      Returns Promise<string[]>

    • Get the type of a variable for a UPS. Returns the variable type (e.g., "STRING", "NUMBER", "ENUM", "RW").

      Parameters

      • ups: string
      • variable: string

      Returns Promise<string>

    • Get help information from the NUT server. Returns a list of available commands.

      Returns Promise<string>

    • List clients connected to a UPS. Returns an array of client identifiers.

      Parameters

      • ups: string

      Returns Promise<string[]>

    • List instant commands for a UPS. Returns an array of command names.

      Parameters

      • ups: string

      Returns Promise<string[]>

    • Parameters

      Returns number

    • List available UPS devices on the NUT server.

      Returns Promise<string[]>

      Array of raw protocol strings in format: 'upsname "description"'

    • List all variables for a UPS. Returns an array of variable names.

      Parameters

      • ups: string

      Returns Promise<string[]>

    • List read-write variables for a UPS. Returns an array of variable names that can be set.

      Parameters

      • ups: string

      Returns Promise<string[]>

    • Parameters

      • ups: string

        {string} the name of the UPS

      Returns Promise<string>

      You probably shouldn't send this command unless you are upsmon, or a upsmon replacement.

    • Set this client as master for the UPS

      Parameters

      • ups: string

      Returns Promise<string>

      You probably shouldn't send this command unless you are upsmon, or a upsmon replacement.

    • get network protocol version

      Returns Promise<string>

    • Type Parameters

      Parameters

      Returns this

    • Parameters

      • Optionalevent: keyof RawNUTClientEvents

      Returns this

    • Run an instant command on a UPS.

      Parameters

      • ups: string

        The name of the UPS

      • command: string

        The command name

      • Optionalparam: string

        Optional command parameter (e.g., delay in seconds)

      Returns Promise<string>

      Raw server response ('OK' or 'OK TRACKING ')

    • allow to send custom command

      Parameters

      • cmdParts: string[]
      • Optionaltimeout: number

        Timeout in milliseconds. Use Infinity for no timeout.

      Returns Promise<string>

    • Parameters

      • n: number

      Returns this

    • Enable or disable command tracking for idempotent write operations.

      When tracking is enabled, write commands (SET VAR, INSTCMD) return OK TRACKING <uuid> instead of OK. The NUTClient facade parses this response into a structured CommandResult object.

      Each tracked command generates a unique UUID. Read operations (GET VAR, LIST) are not tracked.

      Parameters

      • enabled: boolean

        true to enable tracking, false to disable

      Returns Promise<string>

      The raw server response (e.g. 'OK TRACKING' or 'OK')

      Requires NUT 2.8.0+ (protocol v1.3) on the server. Use NUTClient for automatic parsing and TrackingOptions.followTracking for automatic polling.

    • Set the value of a variable for a UPS. Only works for read-write (RW) variables.

      Parameters

      • ups: string

        The name of the UPS

      • variable: string

        The variable name

      • value: unknown

        The value to set

      Returns Promise<string>

      Raw server response ('OK' or 'OK TRACKING ')

    • Parameters

      • OptionaltlsOptions: Omit<ConnectionOptions, "socket" | "host" | "port">

      Returns Promise<void>