Skip to main content

PiPDU python SDK

Project description

PiPDU - Python SDK

PiPDU is a Python package for controlling and monitoring PiPDU power distribution units.
It allows you to:

  • get global metrics
  • get metrics for a specific socket
  • get the state of a socket
  • set the state of a socket
  • test the connection to the PiPDU unit.

Installation

You can install PiPDU using pip:

pip install pipdu

Usage

To use PiPDU, import the PiPDU class from the pipdu module, and create an instance of the class with the certificate, host, and optional API and metrics ports:

from pipdu import PiPDU

certificate = "path/to/certificate.pem"
host = "192.168.1.100"
api_port = 3000
metrics_port = 8000

pdu = PiPDU(host, api_port, metrics_port, certificate)

Getting the Global Metrics

To get the global metrics for all sockets, call the getGlobalMetrics method:

metrics = pdu.getGlobalMetrics()

This method returns a list of floats representing the current drawn on each socket.

Getting Metrics for a Specific Socket

To get the metrics for a specific socket, call the getMetricsFor method with the socket ID:

socket_id = 1
metrics = pdu.getMetricsFor(socket_id)

This method returns a float representing the current drawn by the specified socket.

Getting the State of a Socket

To get the state of a socket, call the getStateFor method with the socket ID:

socket_id = 1
state = pdu.getStateFor(socket_id)

This method returns a boolean value representing the current state of the specified socket (True for on, False for off).

Setting the State of a Socket

To set the state of a socket, call the setStateFor method with the socket ID and the desired state (True for on, False for off):

socket_id = 1
state = True
pdu.setStateFor(socket_id, state)

This method sets the state of the specified socket to the desired state.

Testing the Connection

To test the connection to the PiPDU unit, call the testConnection method:

connected = pdu.testConnection()

This method returns a boolean value representing whether the connection to the PiPDU unit was successful (True for connected, False for not connected).

Notes

  • The certificate parameter is the path to the certificate file for HTTPS connections. If you are using HTTP, you can pass an empty string.
  • The API port and metrics port default to 3000 and 8000, respectively, but can be changed if necessary.

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

pipdu-sdk-1.0.0.dev4075953558.tar.gz (3.7 kB view details)

Uploaded Source

File details

Details for the file pipdu-sdk-1.0.0.dev4075953558.tar.gz.

File metadata

  • Download URL: pipdu-sdk-1.0.0.dev4075953558.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for pipdu-sdk-1.0.0.dev4075953558.tar.gz
Algorithm Hash digest
SHA256 945a5ded3909a7931167fa554fbc4fab2ca0bb25b15962e1ad8f13de2ec5c34e
MD5 6f4a17c349029837f6ed8e69c3d69c77
BLAKE2b-256 b23022ef9ed4c97bd2534002d7665dc9fcc18a0f30faf995bc5b2174f468e7e2

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