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.11b8.tar.gz
(20.2 kB
view hashes)
Built Distribution
Close
Hashes for pyacaia_async-0.0.11b8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a0b7de9f2a86b4030e1bdba4d14614060beb1c30d9dbb54c1068a2d07775826 |
|
MD5 | e6c3b70bc9acd5279534f0ab3d106b4e |
|
BLAKE2b-256 | c03a45d0cd683a928240f638f02d0b06fc08cecdd0295c5d1b1e720a83fb412d |