Skip to main content

SugarPie is a Python library to drive the PiSugar UPS / Battery.

Project description

Have a piece of SugarPie

SugarPie is a Python library to drive the PiSugar UPS / Battery (https://github.com/PiSugar).

The main motivations to create this library are:

  • The official driver takes the form of a web server, which is not always practical.
  • The official driver does not support all the features of the product (eg: the watchdog).

This library is based upon the official documentation for the PiSugar 3 Series: https://github.com/PiSugar/PiSugar/wiki/PiSugar-3-Series

Support for other versions of the product may be added later.

Usage

You can find some examples in the contrib directory with some systemd services and corresponding Python scripts that use the library.

Basically in your code you just have to import and instanciate the Pisugar class and then use the methods you need:
from sugarpie.pisugar import Pisugar
pisugar = Pisugar()
pisugar.turn_on_system_watchdog()
pisugar.turn_off_system_watchdog()

(Be careful if you run the example above, when you turn on the system watchdog you need to reset it regularly or the PiSugar will restart the power! You can find a complete example in the contrib/systemd folder.)

Supported Features

The goal is to support all the features advertised officially in the PiSugar documentation. Here is a list of the currently supported features.
You can find more details within the src/pisugar.py module where each feature should have its corresponding method with a well described docstring.

  • Sytem Watchdog: turn on, turn off and reset the watchdog.

How it works

Everything happens over the i2c bus by setting bits at specific addresses. It depends on the SMBus library.

Contributing

Contributions are welcome. The project is organized such as it should be simple to just add new support, withtout having to modify the current structure (trying to respect the SOLID principles).
When contributing, please format your code with Black, or the CI will break.

License

MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sugarpie-0.1.1.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sugarpie-0.1.1-py2.py3-none-any.whl (4.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file sugarpie-0.1.1.tar.gz.

File metadata

  • Download URL: sugarpie-0.1.1.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.1

File hashes

Hashes for sugarpie-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8a776b4176f0816091ebac40e55d670fb595329a517460d681dbc21dd14a4489
MD5 d052328669ef379b056829784c964c49
BLAKE2b-256 031fd67effff6352ac977a76e2205ad6d4fea4abca860a7c71e703f75a6d3e98

See more details on using hashes here.

File details

Details for the file sugarpie-0.1.1-py2.py3-none-any.whl.

File metadata

  • Download URL: sugarpie-0.1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.1

File hashes

Hashes for sugarpie-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 11e914d431430d77d51333fed2641c83d0a4deaa4f5ed12654d137719b4046d1
MD5 5231dd6a3125abd95e4f8fae9398c012
BLAKE2b-256 3d2aa055f897157b4d3147cfdadd3428025c26a65e2ba8caffce7f431737ded7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page