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

Uploaded Source

Built Distribution

aioacaia-0.1.2-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aioacaia-0.1.2.tar.gz
  • Upload date:
  • Size: 20.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for aioacaia-0.1.2.tar.gz
Algorithm Hash digest
SHA256 5dfe7064dd67d10c15f5d26f08417362990044bf59a1573907fa5f75842b368f
MD5 f68ea0d7e7b0a38b03b46a36c54c6e40
BLAKE2b-256 e064977e360bab93c096b6ef6086bac6e7484143842953c503c0c79e1e1b4d10

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for aioacaia-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 90deb0503a9d4b44b12dc17be56e87ccd80951a78aa824ab182d7e9006d67230
MD5 982ff5fd5ad8c45f73f5e524814e1a60
BLAKE2b-256 0bf40652cd4fdbceb75537056c97035dd6da772b21f1799c61d294b6cdc4e818

See more details on using hashes here.

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