Python API

Use the Python APIs to integrate into your code

Along with the Power Software, Sixfab also offers Python API which allows a user to integrate into their own project.

Install

In order to use the Python API, you will definitely need to install the python library we are offering.

pip3 install sixfab-power-python-api

Methods

All the methods can be accessed from the API doc.

Examples

Here's a list of example actions that you can do using the Python API:

Uninstall

Use the following command to uninstall the library:

pip3 uninstall sixfab-power-python-api

Upgrade

Use the following command to upgrade the library to the latest:

pip3 install sixfab-power-python-api --upgrade

Usage

One of the simple ways to use the Python API is to use the Python Interpreter.

[email protected]:~ $ python3 Python 3.7.3 (default, Jul 25 2020, 13:03:44) [GCC 8.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from power_api import SixfabPower, Definition, Event >>> api = SixfabPower() >>> api.get_battery_level() 90 >>> api.get_system_temp() 45.2
Note: For a better experience, we recommend stopping the power_agent and power_request if connected to the power software. Run the following commands to stop the services.
sudo systemctl stop power_agent.service
sudo systemctl stop power_request.service
Note: Using Python API, the settings of the Power HAT can be changed. Functions dependent on the agent cannot be used. These are:

Updated 3 months ago

Python API


Use the Python APIs to integrate into your code

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.