Async version of apcaccess library implemented in python.
Project description
aioapcaccess
An async implementation of apcaccess. This library provides programmatic access to the status information provided by apcupsd over its Network Information Server (NIS) which usually listens on TCP port 3551.
This project is a re-implementation of the synchronous version flyte/apcaccess using asyncio, where a lot of the logic is borrowed and improved.
Install
Install with pip:
$ pip install aioapcaccess
Usage
The primary API for getting the status from APCUPS is aioapcaccess.request_status.
It returns a collections.OrderedDict mapping from field names (e.g., "SERIALNO") to
their values in string format. What fields are available will depend on the model of
your APC UPS, see APCUPSD manual for details.
The following example shows a typical usage of aioapcaccess
import asyncio
import aioapcaccess
async def main():
result = await aioapcaccess.request_status(host='localhost', port=3551)
print(result)
if __name__ == '__main__':
asyncio.run(main())
The example above will print the following (prettified and simplified):
OrderedDict([
('APC', '001,036,0879'),
...,
('BATTV', '13.7 Volts'),
('CUMONBATT', '0 Seconds')
))])
In addition to request_status, we offer the following functions for advanced uses:
aioapcaccess.request_raw_statusfor getting raw (unparsed) status inbytes.aioapcaccess.parse_raw_statusfor parsing thebytesto the dict shown above.aioapcaccess.split_unitfor splitting the supported unit suffix from the value strings, returning a tuple(value, unit). You can checkaioapcaccess.UNITSfor the set of supported units. Note that units are also in the forms of strings (e.g., "Seconds", "Volts"). If no valid units are found in the value strings,unitwill beNone.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aioapcaccess-1.0.0-py3-none-any.whl.
File metadata
- Download URL: aioapcaccess-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c8e6bfd6e7d1969a020fd762dd9c964a646aab31b14e7a36cfdf3051cdb10f9
|
|
| MD5 |
163252b21c1dd4178cba03505fc58fc8
|
|
| BLAKE2b-256 |
0d064e4b04d7efdc81ae4f162184f75325c3278a0a03bbe5a10d9d2737b56fbb
|
Provenance
The following attestation bundles were made for aioapcaccess-1.0.0-py3-none-any.whl:
Publisher:
release.yaml on yuxincs/aioapcaccess
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aioapcaccess-1.0.0-py3-none-any.whl -
Subject digest:
6c8e6bfd6e7d1969a020fd762dd9c964a646aab31b14e7a36cfdf3051cdb10f9 - Sigstore transparency entry: 461254845
- Sigstore integration time:
-
Permalink:
yuxincs/aioapcaccess@a3f053ea68d05206a792dbc0f367c273dc9ddc38 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/yuxincs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@a3f053ea68d05206a792dbc0f367c273dc9ddc38 -
Trigger Event:
release
-
Statement type: