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.15.tar.gz (22.8 kB view details)

Uploaded Source

Built Distribution

aioacaia-0.1.15-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file aioacaia-0.1.15.tar.gz.

File metadata

  • Download URL: aioacaia-0.1.15.tar.gz
  • Upload date:
  • Size: 22.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for aioacaia-0.1.15.tar.gz
Algorithm Hash digest
SHA256 c265ede6bd9c210e338499d3b8efc0c6faf60bce5c14284d0b1f3217d24adbfa
MD5 ce2f0e8ec5848bb6fb32b871247ac2ef
BLAKE2b-256 585f14bde4a939eb855b7e7a305dfabaa5e275746018c5b91c1c0baab8abf4be

See more details on using hashes here.

Provenance

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

Publisher: pypi.yaml on zweckj/aioacaia

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aioacaia-0.1.15-py3-none-any.whl.

File metadata

  • Download URL: aioacaia-0.1.15-py3-none-any.whl
  • Upload date:
  • Size: 23.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for aioacaia-0.1.15-py3-none-any.whl
Algorithm Hash digest
SHA256 20154e7a452df6221df9c22f6e12d31431df4421de9ee05140ba47c3f9eb9aed
MD5 c02ca4e5daeb3798497a0cd8824ca526
BLAKE2b-256 229e2dbf11ae2bc0b52e03d1d366b9b6e5f9ec06c0b851af4ad05f5ae64e0de4

See more details on using hashes here.

Provenance

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

Publisher: pypi.yaml on zweckj/aioacaia

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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