Skip to main content

CLI tool to control Synaccess Netbooter NP-0201DU PDU

Project description

synpdu

A command-line tool to control Synaccess Netbooter NP-0201DU PDU outlets via the HTTP CGI interface.

Overview

synpdu provides simple command-line control of Synaccess Netbooter PDU outlets. It uses the device's built-in HTTP CGI interface to turn outlets on/off and query their status.

Tested Hardware:

  • Synaccess Netbooter NP-0201DU (2-outlet PDU)

The tool may work with other Synaccess Netbooter models that support the same CGI command interface.

Installation

From PyPI

pip install synpdu

From Source

git clone https://github.com/bradfa/synpdu.git
cd synpdu
pip install -e .

Requirements

  • Python 3.8 or later
  • Network access to the PDU
  • No external dependencies (uses Python standard library only)

Usage

Basic Commands

Turn outlet 1 on:

synpdu 1 on

Turn outlet 2 off:

synpdu 2 off

Check outlet 1 status:

synpdu 1 status

Check all outlets and current measurement:

synpdu status

Example output:

Outlet 1 is ON
Outlet 2 is OFF
Current: 0.05 A

Custom PDU Configuration

By default, synpdu connects to a PDU at 192.168.1.100 using credentials admin:admin. You can override these with command-line flags:

synpdu 1 on --host 192.168.2.50
synpdu 1 on --host 192.168.2.50 --username myuser --password mypass

You can also use HTTPS and custom ports:

synpdu 1 on --host https://192.168.1.100:8080

Command-Line Options

synpdu [-h] [--host HOST] [--username USERNAME] [--password PASSWORD] [--version] [{1,2}] {on,off,status}

Positional arguments:
  {1,2}                 Outlet number (1 or 2) - optional for status command
  {on,off,status}       Command to execute

Options:
  -h, --help            Show this help message and exit
  --host HOST           PDU IP address or URL (default: 192.168.1.100)
  --username USERNAME   PDU username (default: admin)
  --password PASSWORD   PDU password (default: admin)
  --version             Show program's version number and exit

Note: The outlet number is required for on and off commands, but optional for status. When no outlet is specified with status, all outlets and current measurement are displayed.

Development

Running Tests

Install development dependencies:

pip install -e ".[dev]"

Run tests:

pytest

Run tests with coverage:

pytest --cov=synpdu tests/

Building for Distribution

Install build tools:

pip install build twine

Build the package:

python -m build

This creates distribution files in the dist/ directory.

How It Works

The Synaccess Netbooter PDUs provide a simple HTTP CGI interface at /cmd.cgi:

  • Set outlet state: GET /cmd.cgi?$A3 {outlet} {state}

    • outlet: 1 or 2
    • state: 1 = ON, 0 = OFF
    • Success response contains $A0
  • Get all outlet states: GET /cmd.cgi?$A5

    • Returns: $A0,xx,cccc,tt
    • xx: outlet states (rightmost character is outlet 1)
    • cccc: current consumption
    • tt: temperature or other data

Authentication uses HTTP Basic Auth on every request.

License

This project is licensed under the GNU General Public License v2.0 - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

synpdu-0.2.1.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

synpdu-0.2.1-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file synpdu-0.2.1.tar.gz.

File metadata

  • Download URL: synpdu-0.2.1.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for synpdu-0.2.1.tar.gz
Algorithm Hash digest
SHA256 da0ac8fb02475b6628a404e78a189907af447354e24b91a8fe7c52522a5e9f0c
MD5 08f4d30204939838d9e1da3aa350bb1c
BLAKE2b-256 9292e330ca6281b6224ee4ead02a86e86395ec109d70b3456104eef59cf38b75

See more details on using hashes here.

File details

Details for the file synpdu-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: synpdu-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for synpdu-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 126ccd9459d9fb7e09e0e0a65e7a0b0af18eeec30986b40e8a9a023b667c8ef1
MD5 c7614e5855568f15d16b91497fbabca4
BLAKE2b-256 7c663eb8313b05d6e7ad1a683b0ae2abd655f293ee281dbc7243d6ec3f963171

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page