Skip to main content
The Devices resource allows you to register, update, and monitor devices in your fleet. Each device can have metadata, tags, firmware version tracking, and status information.

Methods

list

List devices in your fleet with optional filtering.
client.fleet.devices.list(
    status="active",
    type="autonomous_vehicle",
    limit=50,
    cursor=None
)

Parameters

status
string
Filter devices by status (e.g., “active”, “inactive”, “maintenance”)
type
string
Filter devices by type
limit
integer
Maximum number of devices to return per page (default: 50)
cursor
string
Pagination cursor for fetching the next page

Returns

data
list[Device]
List of device objects
uid
string
Unique device identifier
name
string
Device name
type
string
Device type
status
string
Current device status
firmware_version
string
Installed firmware version
tags
list[string]
Tags associated with the device
metadata
dict
Custom metadata dictionary
last_seen_at
datetime
Timestamp of last device communication
device_token
string
Authentication token for the device
created_at
datetime
Device registration timestamp
updated_at
datetime
Last update timestamp
has_more
boolean
Whether more results are available
next_cursor
string
Cursor for fetching the next page

register

Register a new device in your fleet.
device = client.fleet.devices.register(
    name="Vehicle 001",
    type="autonomous_vehicle",
    firmware_version="2.1.0",
    tags=["production", "region-west"],
    metadata={"license_plate": "ABC123", "vin": "1HGBH41JXMN109186"}
)

Parameters

name
string
required
Name for the device
type
string
required
Device type identifier
firmware_version
string
Firmware version installed on the device
tags
list[string]
Tags to categorize the device
metadata
dict
Custom metadata as key-value pairs

Returns

Returns a Device object with all fields populated, including the generated uid and device_token.

get

Retrieve details for a specific device.
device = client.fleet.devices.get("dev_abc123")

Parameters

device_id
string
required
The unique identifier of the device

Returns

Returns a Device object.

update

Update an existing device’s properties.
device = client.fleet.devices.update(
    "dev_abc123",
    name="Vehicle 001 - Updated",
    status="maintenance",
    firmware_version="2.2.0",
    tags=["production", "region-west", "maintenance"],
    metadata={"last_service": "2024-03-01"}
)

Parameters

device_id
string
required
The unique identifier of the device to update
name
string
New name for the device
status
string
New status for the device
firmware_version
string
Updated firmware version
tags
list[string]
Updated tags (replaces existing tags)
metadata
dict
Updated metadata (merges with existing metadata)

Returns

Returns the updated Device object.

delete

Permanently delete a device from your fleet.
client.fleet.devices.delete("dev_abc123")

Parameters

device_id
string
required
The unique identifier of the device to delete

Returns

Returns None on success.

Example Usage

from avala import Avala

client = Avala(api_key="your-api-key")

# Register a new device
device = client.fleet.devices.register(
    name="Delivery Bot 42",
    type="delivery_robot",
    firmware_version="3.0.1",
    tags=["warehouse-a", "active"],
    metadata={
        "serial_number": "DB-2024-042",
        "assigned_zone": "north"
    }
)

print(f"Registered device: {device.uid}")
print(f"Device token: {device.device_token}")

# List all active delivery robots
devices = client.fleet.devices.list(type="delivery_robot", status="active")

for d in devices.data:
    print(f"Device {d.name}: Last seen at {d.last_seen_at}")

# Update device status
updated = client.fleet.devices.update(
    device.uid,
    status="charging",
    metadata={"battery_level": "35%"}
)

# Get device details
details = client.fleet.devices.get(device.uid)
print(f"Current status: {details.status}")

Async Usage

from avala import AsyncAvala
import asyncio

async def manage_devices():
    client = AsyncAvala(api_key="your-api-key")
    
    # Register device
    device = await client.fleet.devices.register(
        name="Async Device",
        type="sensor"
    )
    
    # List devices
    devices = await client.fleet.devices.list()
    
    # Update device
    updated = await client.fleet.devices.update(
        device.uid,
        status="active"
    )
    
asyncio.run(manage_devices())

Build docs developers (and LLMs) love