SynLink Python Library
About
SynLink Python Library is a Python interface for the SynLink Smart PDU API.
Installation
$ pip install synlinkpy
Examples
from synlinkpy import SynLinkPy
pdu1 = SynLinkPy("http://192.168.1.100", { "username": "admin", "password": "admin" })
# Change outlet state for a given PDU (Power Distribution Unit)
pdu1.outlets.set_state("1", "OFF") # accepts outlet number
pdu1.outlets.set_state("1-1200578", "ON") # accepts unique outlet ID
pdu1.outlets.set_state("2", "REBOOT") # acceptable states are "OFF", "ON", "REBOOT"
# Get information of all outlets
outlet_response = pdu1.outlets.list()
for outlet in outlet_response:
print(outlet['id'], outlet['outletName'], outlet['state'])
# Get information on inlet(s)
inlet_response = pdu1.inlets.list()
for inlet in inlet_response:
print(inlet['id'], inlet['inletCurrentRms'], inlet["inletVoltageRms"])
# Modify Configuration
# https://synaccess.com/support/webapi#configuration
pdu1.conf.set({"lcdOutletControlEnabled": False})
HTTP API Documentation
https://synaccess.com/support/webapi
Authentication
Authentication can occur with Personal Access Token (PATs) or Username & Password. It is recommended to use Personal Access Tokens.
Authenticating with Username and Password
pdu1 = SynLinkPy("http://192.168.1.100", { "username": "admin", "password": "admin" })
print(pdu1.device.info())
Authenticating with Personal Access Token
pdu1 = SynLinkPy("http://192.168.1.100", { "token": "9wxBwnck6JpEH0b1DyI" })
print(pdu1.device.info())
Python Library Commands
Outlet Commands
Outlet API Information https://synaccess.com/support/webapi#outlets
pdu1 = SynLinkPy("http://192.168.1.100", { "username": "admin", "password": "admin" })
# Change outlet state for a given PDU (Power Distribution Unit)
pdu1.outlets.set_state("1", "OFF") # accepts outlet number
pdu1.outlets.set_state("1-1200578", "ON") # accepts unique outlet ID
pdu1.outlets.set_state("2", "REBOOT") # acceptable states are "OFF", "ON", "REBOOT"
# Change outlet name for a given PDU
pdu1.outlets.change_config("1", { "outletName": "example name" })
# Get information of all outlets
outlet_response = pdu1.outlets.list()
for outlet in outlet_response:
print(outlet['id'], outlet['outletName'], outlet['state'])
# OUTPUT
# 1-1200578 Outlet 1 ON
# 2-1200578 Rectifier #1 ON
# 3-1200578 Outlet 3 ON
# 4-1200578 Outlet 4 ON
Inlet Commands
Inlet API Information https://synaccess.com/support/webapi#inlets
pdu1 = SynLinkPy("http://192.168.1.100", { "username": "admin", "password": "admin" })
inlet_response = pdu1.inlets.list()
for inlet in inlet_response:
print(inlet['id'], inlet['inletPlug'], inlet['inletCurrentRms'] )
# OUTPUT
# I1-1000036 0.0 117.4000015258789
Bank Commands
Bank API Information https://synaccess.com/support/webapi#banks
pdu1 = SynLinkPy("http://192.168.1.100", { "username": "admin", "password": "admin" })
banks_response = pdu1.banks.list()
for bank in banks_response:
print(bank['id'], bank['currentRms'])
# OUTPUT
# 1200578 0.0
Device Commands
Device API Information https://synaccess.com/support/webapi#device
pdu1 = SynLinkPy("http://192.168.1.100", { "username": "admin", "password": "admin" })
device_response = pdu1.device.info()
print (device_response['modelNumber'], device_response['enclosureSerialNumber'], device_response['formFactor'])
# OUTPUT
# 5001AIE-0E 1000036 Compact
Groups Commands
Groups API Information https://synaccess.com/support/webapi#groups
pdu1 = SynLinkPy("http://192.168.1.100", { "username": "admin", "password": "admin" })
groups_response = pdu1.groups.list()
for group in groups_response:
print(group['id'], group['groupName'], group["outlets"])
# OUTPUT
# 1 Example Group [...]
# 2 Important Equipment [...]
# 3 Non Essential Equipment [...]
# Create new group with name, to add outlets use groups.modify
pdu1.groups.create("Example Name")
# outlets value must be an array and will override pre-existing outlet's value. First argument is group ID
pdu1.groups.modify(1, { "outlets": ["1-200578", "3-200578"] })
# switch all outlets of the group, will switch according to sequencing time setting
pdu1.groups.set_state(1, "OFF")
# permanently remove based off of group ID
pdu1.groups.delete(1)
Configuration Commands
Configuration API Information https://synaccess.com/support/webapi#configuration
pdu1 = SynLinkPy("http://192.168.1.100", { "username": "admin", "password": "admin" })
conf_response = pdu1.conf.list()
print(conf_response["macAddr"], conf_response["deviceName"], conf_response["lcdOrientation"])
# OUTPUT
# 0C:73:EB:BE:00:27 Demo Compact PDU 90
# Set configuration with key value pairs
pdu1.conf.set({ "lcdOutletControlEnabled" : False })
Sensors Commands
Sensors API Information https://synaccess.com/support/webapi#sensors
pdu1 = SynLinkPy("http://192.168.1.100", { "username": "admin", "password": "admin" })
sensors_response = pdu1.sensors.list()
for sensor in sensors_response:
print(sensor['sensorPort'], sensor['sensorName'], sensor['sensorTempInC'], sensor['sensorHumidity'])
# OUTPUT
# B Temperature & Humidity Sensor 22.9057 39.50677
Event & Action Commands
Events API Information https://synaccess.com/support/webapi#events
Actions API Information https://synaccess.com/support/webapi#actions
pdu1 = SynLinkPy("http://192.168.1.100", { "username": "admin", "password": "admin" })
# List all events
event_response = pdu1.events.list()
for events in event_response:
print(events['id'], events['name'], events['code'], events['params'], events['actions'], events['triggered'])
# OUTPUT
# 1 Example High Current Event for Bank #1 31 ['2003757', '16', '10'] [] False
# List all actions
action_response = pdu1.actions.list()
for actions in action_response:
print(actions['id'], actions['name'], actions['code'], actions['params'])
# OUTPUT
#1 Example Power Cycle for Outlet #1 12 ['1-2003757', '', '']
# Create an action
example_action = pdu1.actions.create({ "name": "example reboot", "code": 12, "params": ["1-2003757","",""] })
# Create an event
example_event pdu1.events.create({"name": "example outlet current event", "code": 46, "params": ["1-2003757", "0.2", "3"], "actions": []})
# Modify an event
pdu1.events.modify(example_event['id'], "actions": [example_action['id']])
# Modify an action
pdu1.actions.modify(example_action['id'], { "name": "example reboot 2", "code": 12, "params": ["2-2003757","",""] })
# Delete an event
pdu1.events.delete(example_event['id'])
# Delete an action
pdu1.actions.delete(example_action['id'])
System Commands
pdu1 = SynLinkPy("http://192.168.1.100", { "username": "admin", "password": "admin" })
response = pdu1.system.fwUpdate("./SP000005_2.5.90_1730425460_ab2721b.swu")
# Firmware update in progress...
# Firmware update successful.
# Rebooting the device...
# Device reboot successful.
print(response)
# True
Metadata
Release files for synlinkpy 0.0.14
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| synlinkpy-0.0.14.tar.gz | 9.0 kB | Without provenance | Details for synlinkpy-0.0.14.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| synlinkpy-0.0.14-py3-none-any.whl | Python 3 | none | any | Details for synlinkpy-0.0.14-py3-none-any.whl |
Total release size: 15.8 kB
Release files / synlinkpy-0.0.14.tar.gz
| Download URL | synlinkpy-0.0.14.tar.gz |
|---|---|
| Size | 9.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dce81c706823e7cb80579a7c153586e0b49a38c9a004bebbebde102da9836849
|
|
BLAKE2b-256 checksum How to use checksums |
c1f7d4c4d4f6d73fa0a0f267e73c25e3eb3273226a56b026265f592c5caa757b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.10
|
Release files / synlinkpy-0.0.14-py3-none-any.whl
| Download URL | synlinkpy-0.0.14-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
176ab0886b8aadec43f0d46ab837377eb8bfae56534b04929a01f26d568b6960
|
|
BLAKE2b-256 checksum How to use checksums |
c42ea228c1085e5a1e8263dfb41275139bc1a6aa1281dada7c61e34ad58ccec4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.10
|
Security for synlinkpy 0.0.14
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.