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.1.1.tar.gz
(20.5 kB
view details)
Built Distribution
File details
Details for the file pyacaia_async-0.1.1.tar.gz
.
File metadata
- Download URL: pyacaia_async-0.1.1.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02c09da230d5917f2d195526389c8a1df94723d505d1c0b2b04e8123b6002fe1 |
|
MD5 | bbf0c43090b836fe54b73352ba6e0b17 |
|
BLAKE2b-256 | 2e3199dff50035c8e995d0d44d0aae3a56c85e65bf5cec4e26574b6d0c505cf1 |
File details
Details for the file pyacaia_async-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: pyacaia_async-0.1.1-py3-none-any.whl
- Upload date:
- Size: 21.7 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 | e4154817c51d881ad9003b82c1115d66c7d102ea35150af157d774b684e8ee85 |
|
MD5 | bb37e0a7ef5b8e3996e464ab654413b6 |
|
BLAKE2b-256 | a1cded44993158f239bd1ddaec17efe7827f03f6442b94e93f4650449ecde312 |