Name | aioacaia JSON |
Version |
0.1.14
JSON |
| download |
home_page | None |
Summary | An async implementation of PyAcaia |
upload_time | 2025-01-23 08:19:55 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.12 |
license | MIT |
keywords |
acaia
bluetooth
api
async
client
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# aioacaia
Async implementation of [pyacaia](https://github.com/lucapinello/pyacaia/tree/master/pyacaia), based on `asyncio` and `bleak`
# Usage
```python
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`
```python
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)
```
Raw data
{
"_id": null,
"home_page": null,
"name": "aioacaia",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.12",
"maintainer_email": "Josef Zweck <24647999+zweckj@users.noreply.github.com>",
"keywords": "Acaia, Bluetooth, api, async, client",
"author": null,
"author_email": "Josef Zweck <24647999+zweckj@users.noreply.github.com>",
"download_url": "https://files.pythonhosted.org/packages/92/22/10fc565cbb1ebdd51d1183a9293180c4e0a06fc676949956ff769efe28b7/aioacaia-0.1.14.tar.gz",
"platform": null,
"description": "# aioacaia\n\nAsync implementation of [pyacaia](https://github.com/lucapinello/pyacaia/tree/master/pyacaia), based on `asyncio` and `bleak`\n\n# Usage\n\n```python\nimport asyncio\nfrom aioacaia import AcaiaScale\nfrom aioacaia.helpers import find_acaia_devices\n\nasync def main()\n addresses = await find_acaia_devices()\n address = addresses[0]\n scale = await AcaiaScale.create(mac=address, is_new_style_scale=False)\n await scale.tare()\n await scale.startStopTimer()\n await scale.resetTimer()\n\nasyncio.run(main())\n```\n\n# Callback\n\nWeight and settings are available, if you pass a callback function to the constructor.\nIn 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`\n\n```python\ndef notification_handler(sender, data) -> None:\n msg = decode(data)[0]\n if isinstance(msg, Settings):\n print(f\"Battery: {msg.battery}\")\n print(f\"Unit: {msg.units}\")\n elif isinstance(msg, Message):\n print(f\"Weight: {msg.value}\")\n\nscale = await AcaiaScale.create(mac=address, callback=notification_handler)\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "An async implementation of PyAcaia",
"version": "0.1.14",
"project_urls": {
"Documentation": "https://github.com/zweckj/aioacaia",
"Homepage": "https://github.com/zweckj/aioacaia",
"Repository": "https://github.com/zweckj/aioacaia"
},
"split_keywords": [
"acaia",
" bluetooth",
" api",
" async",
" client"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "12092f90870a979bf99cef66d9ce89c55ead28d527695e4e254060d9ae9c0fd0",
"md5": "c15b01d00044dec2118aa946f9c205a6",
"sha256": "a5f91a4f74198f3d0cf3796d307564098fe61f7d541d12eb7609e6924e83976a"
},
"downloads": -1,
"filename": "aioacaia-0.1.14-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c15b01d00044dec2118aa946f9c205a6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 23563,
"upload_time": "2025-01-23T08:19:53",
"upload_time_iso_8601": "2025-01-23T08:19:53.792271Z",
"url": "https://files.pythonhosted.org/packages/12/09/2f90870a979bf99cef66d9ce89c55ead28d527695e4e254060d9ae9c0fd0/aioacaia-0.1.14-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "922210fc565cbb1ebdd51d1183a9293180c4e0a06fc676949956ff769efe28b7",
"md5": "9eb3be036ec44756b507d27ebd3fb3d3",
"sha256": "914bb0ae4829ecf39d6dd8aa0aa3dec6b80763c7002212b7dda48eab3d144430"
},
"downloads": -1,
"filename": "aioacaia-0.1.14.tar.gz",
"has_sig": false,
"md5_digest": "9eb3be036ec44756b507d27ebd3fb3d3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 22738,
"upload_time": "2025-01-23T08:19:55",
"upload_time_iso_8601": "2025-01-23T08:19:55.135405Z",
"url": "https://files.pythonhosted.org/packages/92/22/10fc565cbb1ebdd51d1183a9293180c4e0a06fc676949956ff769efe28b7/aioacaia-0.1.14.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-23 08:19:55",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "zweckj",
"github_project": "aioacaia",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "aioacaia"
}