Skip to main content

An async implementation of PyAcaia

Project description

pyacaia_async

Async implementation of pyacaia, based on asyncio and bleak

Usage

import asyncio
from pyacaia_async import AcaiaScale
from pyacaia_async.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

pyacaia_async-0.0.12b1.tar.gz (20.3 kB view details)

Uploaded Source

Built Distribution

pyacaia_async-0.0.12b1-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

Details for the file pyacaia_async-0.0.12b1.tar.gz.

File metadata

  • Download URL: pyacaia_async-0.0.12b1.tar.gz
  • Upload date:
  • Size: 20.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for pyacaia_async-0.0.12b1.tar.gz
Algorithm Hash digest
SHA256 1670ac88bebc92cd8ca78b9afa0c5677d1f07eccd7a0fadeca2efcd059c7630a
MD5 c42e8b95d5f2d6d7ceabe91761c5f317
BLAKE2b-256 1ef7c4c2aad28fbe9051f77f2c44b0df4ad159926929423d736d1e05655adfa2

See more details on using hashes here.

File details

Details for the file pyacaia_async-0.0.12b1-py3-none-any.whl.

File metadata

File hashes

Hashes for pyacaia_async-0.0.12b1-py3-none-any.whl
Algorithm Hash digest
SHA256 ee75a73b59d4c5fad8b5580ba06042a1f85931266b195739ce1438448faf7a34
MD5 41ec183ab06297f6242b3573d1478b7a
BLAKE2b-256 750cf485a0c5c6a3d3efbc29c19b1509f12e9cd660937a1cb7d23a5a3d78ec1b

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