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
Filter devices by status (e.g., “active”, “inactive”, “maintenance”)
Maximum number of devices to return per page (default: 50)
Pagination cursor for fetching the next page
Returns
List of device objectsInstalled firmware version
Tags associated with the device
Custom metadata dictionary
Timestamp of last device communication
Authentication token for the device
Device registration timestamp
Whether more results are available
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
Firmware version installed on the device
Tags to categorize the device
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
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
The unique identifier of the device to update
New status for the device
Updated tags (replaces existing tags)
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
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())