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
Release history Release notifications | RSS feed
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.12b5.tar.gz
(20.3 kB
view details)
Built Distribution
File details
Details for the file pyacaia_async-0.0.12b5.tar.gz
.
File metadata
- Download URL: pyacaia_async-0.0.12b5.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2e057f41095e53ac8990d2589cf466253a67305a3bf3d3aab57c3e7dae6f304 |
|
MD5 | a604a3bf1bd9b8e15e5db5f5708e9e41 |
|
BLAKE2b-256 | e1d68a4c49ff0f438880cbc1b8bdfbd4b69b6c2f80aa7e493cadf4ab3271c463 |
File details
Details for the file pyacaia_async-0.0.12b5-py3-none-any.whl
.
File metadata
- Download URL: pyacaia_async-0.0.12b5-py3-none-any.whl
- Upload date:
- Size: 21.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 770f143a8685fbc749a98c34f602335060f5809f8bcfaa99eef0f5ccab37db28 |
|
MD5 | c85493b246deb72aafcd6a7537c92f5b |
|
BLAKE2b-256 | 3dea7eadac018798c186e55b611d340bf6e61755421c269683b7b22e05c52d05 |