Metadata-Version: 2.1
Name: poectrl
Version: 0.2.0
Summary: Control PoE status on select Ubiquiti switches
Home-page: https://github.com/seapagan/ts-8-pro-control
License: MIT
Author: Grant Ramsay
Author-email: seapagan@gmail.com
Requires-Python: >=3.7.2,<4.0
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: End Users/Desktop
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Requires-Dist: paramiko (>=2.12.0,<3.0.0)
Requires-Dist: typer[all] (>=0.7.0,<0.8.0)
Project-URL: Bug Tracker, https://github.com/seapagan/openapi-readme/issues
Project-URL: Pull Requests, https://github.com/seapagan/openapi-readme/pulls
Project-URL: Repository, https://github.com/seapagan/ts-8-pro-control
Description-Content-Type: text/markdown

# Control PoE status on a Ubiquiti TS-8-Pro Switch <!-- omit in toc -->

[![PyPI version](https://badge.fury.io/py/poectrl.svg)](https://badge.fury.io/py/poectrl)

**Development work** for a system to remotely and automatically control the PoE
status of individual ports on multiple Ubiquiti TS-8-Pro Switch, using
predefined profiles.

This has currently only been tested on the TS-8-PRO ToughSwitch routers,
though others will be added soon.

**IMPORTANT: This library DOES NOT (and CAN NOT) ensure that any device attached
to a port is compatible with the voltage selected. BE VERY CAREFUL that you
choose the correct voltage for your devices or you can DAMAGE THEM. No
responsibility is taken for equipment damaged using this library.**

- [Status](#status)
- [Use Cases](#use-cases)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
- [Development Plans](#development-plans)
- [Contributing](#contributing)

## Status

This project is in no way ready to be used, and documentation is non-existent.
See the Development Plans below. Until I have a stable useful interface, check
the source code if you are interested 😃

## Use Cases

- Control a set of PoE-powered IP cameras, switches and access points to allow
disabling when not needed or quick enabling if required.

## Installation

The latest version is uploaded to [pypi.org](https://pypi.org) so you can
install this the same as any other package:

```console
pip install poectrl
```

## Configuration

**IMPORTANT : The configuration layout has CHANGED from version 1.2.0. If you
are using config files from previous versions you will need to update the
"devices" section to fit the below schema and change the profile to point to the
name instead of IP address.**

The program is configured using a `poectrl.json` file either in the current
working directory (first priority) or the user's home directory. This is a
simple file that describes all devices and profiles. There is an example in
[poectrl-example.json](poectrl-example.json) :

```json
{
  "devices": {
    "switch_1": {"ip": "192.168.0.187", "user": "ubnt", "password": "ubnt"},
    "switch_2": {"ip": "192.168.0.190", "user": "ubnt", "password": "ubnt"}
  },
  "profiles": {
    "cctv_on": {
      "switch_1": {"4": 24, "5": 24, "8": 48},
      "switch_2": {"5": 24, "6": 24, "7": 48}
    },
    "cctv_off": {
      "switch_1": {"4": 0, "5": 0, "8": 0},
      "switch_2": {"5": 0, "6": 0, "7": 0}
    }
  }
}

```

## Usage

Apply a predefined profile, setting the PoE port voltages.

```console
$ poectrl apply cctv_off
Using configuration from /home/seapagan/data/work/own/poectrl/poectrl.json
Conncting to switch_1 (192.168.0.187):
  Setting port 4 to 0V
  Setting port 5 to 0V
  Setting port 8 to 0V
Conncting to switch_2 (192.168.0.190):
  Setting port 5 to 0V
  Setting port 6 to 0V
  Setting port 7 to 0V

```

List all defined profiles:

```console
$ poectrl list
Using configuration from /home/seapagan/data/work/own/ts-8-pro-control/poectrl.json

Valid profiles are :
 - cctv_on
 - cctv_off
```

Show settings for a profile :

```console
$ poectrl show cctv_off
Using configuration from /home/seapagan/data/work/own/ts-8-pro-control/poectrl.json
{
    "switch_1": {
        "4": 0,
        "5": 0,
        "8": 0
    },
    "switch_2": {
        "5": 0,
        "6": 0,
        "7": 0
    }
}


```

## Development Plans

Current proposed project plan.

- [x] Write proof-of-concept code to control ports.
- [x] Refactor and tidy the above code into a Library Class.
- [x] Create a basic CLI using this Library
- [x] Continue the CLI to use a config file, show current values, list profiles
  etc.
- [x] Publish on PyPi as a standalone package.
- [ ] Develop this into a full API (using FastAPI).
- [ ] Modify the command line app to interface with the above API.
- [ ] Create a Web App to interface with the above API.

## Contributing

At this time, the project is barely in it's planning stage but I do have a firm
idea where it's going and how to structure it. As such, other contributions are
not looked for at this time. Hopefully, within a few days this project will be
at a much more advanced stage and that will change 😃.

