Skip to main content

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

Metadata

Release files for lua-device-client 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lua-device-client 1.3.0
File Size Uploaded Provenance Actions
lua_device_client-1.3.0.tar.gz 16.3 kB Without provenance Details for lua_device_client-1.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lua-device-client 1.3.0
File Interpreter ABI Platform Actions
lua_device_client-1.3.0-py3-none-any.whl Python 3 none any Details for lua_device_client-1.3.0-py3-none-any.whl

Total release size: 31.8 kB

Release files / lua_device_client-1.3.0.tar.gz

Download URL lua_device_client-1.3.0.tar.gz
Size 16.3 kB
Tags Source
SHA-256 checksum
How to use checksums
4ffce173856d9ba2c69ab20d5a3a94462122fde42e3f65b3862d0f3167b4ef9e
BLAKE2b-256 checksum
How to use checksums
73e403bc4b763b3bc5801d065748a1f3369b25b9748893a304ad721dabe5219d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / lua_device_client-1.3.0-py3-none-any.whl

Download URL lua_device_client-1.3.0-py3-none-any.whl
Size 15.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0159d86b61ba03be723787d6e5505bc7edb4ee277793236078c6e1b125949153
BLAKE2b-256 checksum
How to use checksums
82ab7fe3483e46da1b3de4ffb251dfea7d51841a2756c1e6e894094073227c49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Security for lua-device-client 1.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page