Skip to main content

An async implementation of PyAcaia

Project description

aioacaia

Async implementation of pyacaia, based on asyncio and bleak

Usage

import asyncio
from aioacaia import AcaiaScale
from aioacaia.helpers import find_acaia_devices

async def main()
  addresses = await find_acaia_devices()
  address = addresses[0]
  scale = await AcaiaScale.create(mac=address, is_new_style_scale=False)
  await scale.tare()
  await scale.startStopTimer()
  await scale.resetTimer()

asyncio.run(main())

Callback

Weight and settings are available, if you pass a callback function to the constructor. In that callback you will either receive objects of type Message or Settings. A sample notification handler can look like this and can also be found in decode.py

def notification_handler(sender, data) -> None:
    msg = decode(data)[0]
    if isinstance(msg, Settings):
        print(f"Battery: {msg.battery}")
        print(f"Unit: {msg.units}")
    elif isinstance(msg, Message):
        print(f"Weight: {msg.value}")

scale = await AcaiaScale.create(mac=address, callback=notification_handler)

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

aioacaia-0.1.5b1.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

aioacaia-0.1.5b1-py3-none-any.whl (22.1 kB view details)

Uploaded Python 3

File details

Details for the file aioacaia-0.1.5b1.tar.gz.

File metadata

  • Download URL: aioacaia-0.1.5b1.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for aioacaia-0.1.5b1.tar.gz
Algorithm Hash digest
SHA256 4c40315a7c917f44f8bed4652f8bedd1468560b5a195c8b3f92cc0f6723fcee4
MD5 94adce9e3c7a4edbbeb0abc8aab0c60a
BLAKE2b-256 6d165adf1a37bef9d5054caaa2088d004d0e012b83979d07fb6eed659d87f500

See more details on using hashes here.

Provenance

The following attestation bundles were made for aioacaia-0.1.5b1.tar.gz:

Publisher: pypi.yaml on zweckj/aioacaia

Attestations:

File details

Details for the file aioacaia-0.1.5b1-py3-none-any.whl.

File metadata

  • Download URL: aioacaia-0.1.5b1-py3-none-any.whl
  • Upload date:
  • Size: 22.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for aioacaia-0.1.5b1-py3-none-any.whl
Algorithm Hash digest
SHA256 fa656702b8f26eda1355ce8b78b48ee57149b7f290139692827e43eef44adb27
MD5 aeffd331faa9237cb55405f41b592e31
BLAKE2b-256 af60083f1921249dd3b6d206f6ca632fb3614442407ff99190e96d7cbc0f5e17

See more details on using hashes here.

Provenance

The following attestation bundles were made for aioacaia-0.1.5b1-py3-none-any.whl:

Publisher: pypi.yaml on zweckj/aioacaia

Attestations:

Supported by

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