pipdu-sdk


Namepipdu-sdk JSON
Version 1.0.0.dev4076543265 PyPI version JSON
download
home_pagehttps://gitlab.com/mirceanton/piPDU/-/tree/main/utils/python_sdk
SummaryPiPDU python SDK
upload_time2023-04-06 21:29:25
maintainer
docs_urlNone
authorMircea-Pavel Anton
requires_python
licenseMIT
keywords pypi pipdu mirceanton
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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:

```bash
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:

```python
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:

```python
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:

```python
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:

```python
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):

```python
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:

```python
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.



            

Raw data

            {
    "_id": null,
    "home_page": "https://gitlab.com/mirceanton/piPDU/-/tree/main/utils/python_sdk",
    "name": "pipdu-sdk",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "pypi,pipdu,mirceanton",
    "author": "Mircea-Pavel Anton",
    "author_email": "contact@mirceanton.com",
    "download_url": "https://files.pythonhosted.org/packages/cd/f9/7dd65cd1a24fb647c7d0f5e2696d65fae0a153131218ca31cee57dc970b4/pipdu_sdk-1.0.0.dev4076543265.tar.gz",
    "platform": null,
    "description": "# PiPDU - Python SDK\n\nPiPDU is a Python package for controlling and monitoring PiPDU power distribution units.  \nIt allows you to:\n\n- get global metrics\n- get metrics for a specific socket\n- get the state of a socket\n- set the state of a socket\n- test the connection to the PiPDU unit.\n\n## Installation\n\nYou can install PiPDU using pip:\n\n```bash\npip install pipdu\n```\n\n## Usage\n\nTo 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:\n\n```python\nfrom pipdu import PiPDU\n\ncertificate = \"path/to/certificate.pem\"\nhost = \"192.168.1.100\"\napi_port = 3000\nmetrics_port = 8000\n\npdu = PiPDU(host, api_port, metrics_port, certificate)\n```\n\n### Getting the Global Metrics\n\nTo get the global metrics for all sockets, call the `getGlobalMetrics` method:\n\n```python\nmetrics = pdu.getGlobalMetrics()\n```\n\nThis method returns a list of `floats` representing the current drawn on each socket.\n\n### Getting Metrics for a Specific Socket\n\nTo get the metrics for a specific socket, call the `getMetricsFor` method with the socket ID:\n\n```python\nsocket_id = 1\nmetrics = pdu.getMetricsFor(socket_id)\n```\n\nThis method returns a `float` representing the current drawn by the specified socket.\n\n### Getting the State of a Socket\n\nTo get the state of a socket, call the `getStateFor` method with the socket ID:\n\n```python\nsocket_id = 1\nstate = pdu.getStateFor(socket_id)\n```\n\nThis method returns a `boolean` value representing the current state of the specified socket (`True` for on, `False` for off).\n\n### Setting the State of a Socket\n\nTo set the state of a socket, call the `setStateFor` method with the socket ID and the desired state (`True` for on, `False` for off):\n\n```python\nsocket_id = 1\nstate = True\npdu.setStateFor(socket_id, state)\n```\n\nThis method sets the state of the specified socket to the desired state.\n\n### Testing the Connection\n\nTo test the connection to the PiPDU unit, call the `testConnection` method:\n\n```python\nconnected = pdu.testConnection()\n```\n\nThis method returns a `boolean` value representing whether the connection to the PiPDU unit was successful (`True` for connected, `False` for not connected).\n\n## Notes\n\n- The certificate parameter is the path to the certificate file for HTTPS connections. If you are using HTTP, you can pass an empty string.\n- The API port and metrics port default to `3000` and `8000`, respectively, but can be changed if necessary.\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "PiPDU python SDK",
    "version": "1.0.0.dev4076543265",
    "split_keywords": [
        "pypi",
        "pipdu",
        "mirceanton"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cdf97dd65cd1a24fb647c7d0f5e2696d65fae0a153131218ca31cee57dc970b4",
                "md5": "8a7033b1a971da84c59d8504ad1b5632",
                "sha256": "626ca29cdb9b6dfc28ba8068ebdd78dc22d08ef2c32197a734b651628f2de3bb"
            },
            "downloads": -1,
            "filename": "pipdu_sdk-1.0.0.dev4076543265.tar.gz",
            "has_sig": false,
            "md5_digest": "8a7033b1a971da84c59d8504ad1b5632",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4495,
            "upload_time": "2023-04-06T21:29:25",
            "upload_time_iso_8601": "2023-04-06T21:29:25.758848Z",
            "url": "https://files.pythonhosted.org/packages/cd/f9/7dd65cd1a24fb647c7d0f5e2696d65fae0a153131218ca31cee57dc970b4/pipdu_sdk-1.0.0.dev4076543265.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-06 21:29:25",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "pipdu-sdk"
}
        
Elapsed time: 0.06891s