Connect physical devices to Lua AI agents via MQTT.
Project description
lua-device-client
Connect physical devices to Lua AI agents via MQTT.
Install
pip install lua-device-client
Quick Start
import asyncio
from lua_device import DeviceClient, DeviceCommandDefinition
client = DeviceClient(
agent_id="baseAgent_agent_abc123",
api_key="api_your_key_here",
device_name="warehouse-scanner",
commands=[
DeviceCommandDefinition(
name="scan_barcode",
description="Scan a barcode and return its value",
),
DeviceCommandDefinition(
name="get_status",
description="Return device battery and connectivity status",
),
],
)
async def handle_scan(payload):
return {"barcode": "ABC-12345", "format": "CODE128"}
async def handle_status(payload):
return {"battery": 85, "signal": "strong"}
client.on_command("scan_barcode", handle_scan)
client.on_command("get_status", handle_status)
async def main():
await client.connect()
print("Device connected!")
# Fire a trigger to the agent
ack = await client.trigger("barcode_scanned", {"value": "ABC-12345"})
print(f"Trigger acknowledged: {ack}")
# Keep running
await asyncio.Event().wait()
asyncio.run(main())
Features
- MQTT transport -- connects to Lua AI via MQTT (paho-mqtt)
- Self-describing commands -- no server config needed
- CDN uploads -- upload screenshots and files via
CDN.upload() - Device triggers -- fire events from device to agent
- Auto-reconnection -- exponential backoff
- Async/await -- built on asyncio
MicroPython
For Raspberry Pi Pico W and other MicroPython boards, use the standalone MicroPython client included in lua_device/micropython.py. See the MicroPython docs for details.
Documentation
Full documentation: https://docs.heylua.ai/devices
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lua_device_client-1.1.0.tar.gz.
File metadata
- Download URL: lua_device_client-1.1.0.tar.gz
- Upload date:
- Size: 14.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4116ff66299726a8b731c76b43f098d19eea39e8cefb065be632be9c0bf80c09
|
|
| MD5 |
fb5ae5163570cb4a504c408ce6e955a8
|
|
| BLAKE2b-256 |
0026b4273403f8bc69c0d993e36251df1c15a301b0652fa8b0f26894affa4572
|
File details
Details for the file lua_device_client-1.1.0-py3-none-any.whl.
File metadata
- Download URL: lua_device_client-1.1.0-py3-none-any.whl
- Upload date:
- Size: 14.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01483fbe074fb64400a50939837390016a06006788f6023b76e97916d83a44f0
|
|
| MD5 |
7cdde55067a4967cffe64c0ff38bbf1e
|
|
| BLAKE2b-256 |
06533ccf2c9477e34ac5cc8fb94f4987d3dca492ae844991b23fe43a492d3f45
|