ctek-py
About
This library provides a set of friendly classes and functions to interact with CTEK products and their public API:s through Python.
Currently supported devices
NANOGRID™ AIR - ✅
Installation
Simply install using pip
pip install ctek
Usage
Products can be interacted with through classes of the same name as the product
from ctek import NanogridAir
meter_data = await NanogridAir().fetch_meter_data()
print(f"Meter data: {meter_data}")
Since this library utilizes dataclasses, you can easily access the data returned by the API and see what is available for you to use through auto-completion in your IDE. For example, to get the active power in:
from ctek import NanogridAir
meter_data = await NanogridAir().fetch_meter_data()
print(f"Active power in: {meter_data.active_power_in}")
If you need access to the data types used in the library, you can import them from ctek.<device>.types. For example, to get the MeterData dataclass for the NANOGRID™ AIR device:
from ctek import NanogridAir
from ctek.nanogrid_air.types import MeterData
meter_data: Meterdata = await NanogridAir().fetch_meter_data()
print(f"Active power in: {meter_data.active_power_in}")
Build and Test
The recommended way is to use the provided Dev Container, which will set up everything for you. This includes installing all the necessary dependencies, installing pre-commit hooks, and setting up the development environment with recommended tools and extensions, as well as environment variables. All source code will be mounted into the container automatically on start and config files such as .gitconfig will be inherited. You are up and running in no time. For more info see the dev container configuration file .devcontainer/devcontainer.json and the Dev Container documentation.
Dev Container (Recommended)
Required tools include:
If on Windows, you will also need to install the Windows Subsystem for Linux 2 and a Linux distribution such as Ubuntu. It is recommended to clone the repository directly into WSL since this will increase the performance of the dev container. After cloning and cd'ing into the project folder, you can open the project in VS Code by running code . in the WSL terminal.
Open VS Code and you will be prompted with a notification in the bottom right corner of the window to reopen the project in a dev container.
Alternatively you can open the command palette (Ctrl+Shift+P) and run the Dev Containers: Reopen in Container or Dev Containers: Rebuild and Reopen in Container command.
PDM only (Alternative)
Required tools include:
If you want to develop directly on your machine without depending on either Visual Studio Code or Docker you can straight up install PDM, the development dependencies and setup pre-commit by running the following command:
# git clone
# cd into the project folder
pdm sync -G dev && pdm run pre-commit install
Run all tests
To run testing, linting and building of the project you can run the following command:
pdm run all
Run manual device tests
To run the manual tests for the devices you can run the following command:
pytest tests/manual_test_ng_air.py -s
This requires you to have an active NANOGRID™ AIR device connected to the same network as the computer running the tests.
To Do
- Add proper documentation with Github Pages
Metadata
Release files for ctek 0.3.0
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 | |
|---|---|---|---|---|
| ctek-0.3.0.tar.gz | 12.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ctek-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.6 kB
Release files / ctek-0.3.0.tar.gz
| Download URL | ctek-0.3.0.tar.gz |
|---|---|
| Size | 12.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1a75ee2c56a95d049347f4323562d2d73571e052494985780588c68cd40156ea
|
|
BLAKE2b-256 checksum How to use checksums |
2fd768893aa32a75a4f3f0bf286abce8336d251e2c39e51606e2971c4c768309
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.9.19
|
Release files / ctek-0.3.0-py3-none-any.whl
| Download URL | ctek-0.3.0-py3-none-any.whl |
|---|---|
| Size | 9.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
712688fc52adc39e7a0c207c9e13b3c3adddcabd55720458d23e275048b4bcf9
|
|
BLAKE2b-256 checksum How to use checksums |
a688b95d152c2b3c5e05a2e10d0c8e74ebbb1500dc09c6477299838cc0bc5c8f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.9.19
|
Security for ctek 0.3.0
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.