Metadata-Version: 2.4
Name: zspdu
Version: 0.0.1
Summary: Control ZSPDU smart power distribution unit via serial port
Home-page: https://github.com/ganesanluna/zspdu
Author: Ganesan Selvaraj
Author-email: ganesanluna@yahoo.in
License: MIT
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pyserial
Requires-Dist: pydantic
Requires-Dist: robotframework
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# zspdu

**zspdu** is a Python package and Robot Framework library for controlling Smart PDUs (Power Distribution Units) via USB serial interfaces.
It provides both a command‑line interface (CLI) and Robot Framework keywords for automation.

---

## Features

- List available serial ports
- Open and switch between ports
- Turn individual sockets ON/OFF
- Turn all sockets ON/OFF
- Read current measurements
- Close connections
- Usable as:
  - **CLI tool** (`zspdu`)
  - **Robot Framework library** (`Library    zspdu`)

---

## Installation

Clone the repository and install in editable mode:

git clone https://github.com/ganesanluna/zspdu.git
cd zspdu
pip install -e .

This will install the package and register the `zspdu` CLI command.

---

## Command Line Usage

zspdu -l                # List all available serial ports
zspdu -o /dev/ttyUSB0   # Open specific port
zspdu -s /dev/ttyUSB1   # Switch to another port
zspdu --on 3            # Turn ON socket 3
zspdu --off 2           # Turn OFF socket 2
zspdu --on-all          # Turn ON all sockets
zspdu --off-all         # Turn OFF all sockets
zspdu -c                # Close current port
zspdu -v                # Show version

Running `zspdu` without arguments will display the help message.

---

## Robot Framework Usage

Import the library in your `.robot` test file:
```robot
*** Settings ***
Library    zspdu

*** Test Cases ***
Control PDU
    Turn Socket On    1
    ${current}=    Read Current
    Log    Current reading: ${current}
    Turn Socket Off    1
    Close PDU Connection
```
You can also pass arguments when importing:
``` robot
*** Settings ***
Library    zspdu    port=/dev/ttyUSB1    baudrate=9600    sockets=4
```
---

## Device Information (from ZS12x0 USB PDU)

### Variants
- **ZS1220**: 8‑port USB PDU (Part Number: ZS-PDU8-USB-P1B)

### Specifications
- Output Power Sockets: 8
- Power Supply: 240VAC, 15A
- Fuse Rating: 15A
- Max Current per Socket: 13A
- Total Load Capacity: 3kVA
- Relay Switching Life Expectancy: 50,000 cycles
- Current Sensing Range: up to 15A
- Control Port: USB2.0 Type‑B

### Serial Port Settings
- Baud Rate: 115200
- Data Bits: 8
- Stop Bit: 1
- Parity: None
- Flow Control: None

---

## Usage: Command line options
``` text
$ zspdu --help
usage: zspdu [-h] [-v] [-l | -o PORT | -s PORT | --on SOCKET | --off SOCKET | --on-all | --off-all | -c]

Smart PDU control via serial interface

options:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  -l, --list            List all available serial ports
  -o PORT, --open PORT  Open specific serial port
  -s PORT, --switch PORT
                        Switch to another serial port
  --on SOCKET           Turn ON specific power socket
  --off SOCKET          Turn OFF specific power socket
  --on-all              Turn ON all power sockets
  --off-all             Turn OFF all power sockets
  -c, --close           Close current port
```

> Current version 1.0.0, this software version supported only for linux and supported single pdu support with default port /dev/ttyUSB0.

---

## Development

Folder structure:
``` text
.
├── src/
│   └── zspdu/
│       ├── __init__.py 
│       ├── core.py       
│       ├── utils.py     
│       └── cli.py        
├── LICENSE
├── README.md
├── pyproject.toml
├── requirements.txt
└── setup.py
```
---

## License

MIT License  
Copyright (c) 2026 Ganesan Selvaraj

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sub-license, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
