Skip to content

Device-Side Access

The qbee-agent provides CLI commands for reading and setting device attributes directly on the device. This is useful for scripts, automation, and device self-registration workflows.

Reading attributes

qbee-agent attributes get [KEY...]

Returns all attributes as JSON. Pass one or more key names to filter the output.

Predefined keys: device_name, longitude, latitude. Custom keys use the custom. prefix (for example, custom.env). Unknown keys are silently ignored.

Shell variable output

Use --shell to output attributes as shell variable assignments:

qbee-agent attributes get --shell

Output format:

QBEE_ATTRIBUTE_DEVICE_NAME="my-device"
QBEE_ATTRIBUTE_LONGITUDE="12.34"
QBEE_ATTRIBUTE_LATITUDE="56.78"
QBEE_ATTRIBUTE_CUSTOM_ENV="production"

Predefined attributes use the QBEE_ATTRIBUTE_ prefix. Custom attributes use QBEE_ATTRIBUTE_CUSTOM_. All variable names are uppercased, and dots and dashes in keys are replaced with underscores.

Filter specific attributes:

qbee-agent attributes get --shell custom.env custom.region

Using attributes in a script

Source the output to make attributes available as shell variables:

#!/bin/bash
eval "$(qbee-agent attributes get --shell)"

echo "Device: ${QBEE_ATTRIBUTE_DEVICE_NAME}"
echo "Environment: ${QBEE_ATTRIBUTE_CUSTOM_ENV}"

if [ "${QBEE_ATTRIBUTE_CUSTOM_ENV}" = "production" ]; then
    echo "Running in production mode"
fi

Setting attributes

qbee-agent attributes set --attributes "key=value,..."

Or pass a JSON object as a positional argument:

qbee-agent attributes set '{"device_name":"gateway-01","custom":{"env":"production"}}'

Settable legacy attributes

Of the legacy attributes, only device_name, longitude, and latitude can be written from the device. The remaining legacy fields (description, country, city, zip, address) are managed through the UI or API. All custom attributes are writable from the device.

A common use case is a device with a GPS receiver updating its own coordinates and name as it moves -- for example, a vehicle gateway or mobile asset that reports its position into the fleet on boot. The device writes those values directly, with no UI or API call:

qbee-agent attributes set --attributes "device_name=truck-42,longitude=10.74,latitude=59.91"

Equivalent JSON form:

qbee-agent attributes set '{"device_name":"truck-42","longitude":"10.74","latitude":"59.91"}'

Deleting attributes

Set an attribute to an empty value to delete it:

qbee-agent attributes set --attributes "custom.env="

Or use JSON with a null value:

qbee-agent attributes set '{"custom":{"env":null}}'

Empty or null values signal that the attribute should be deleted.

What Next?

I want to... Go to
Create, update, and delete attributes via the UI and API Managing Attributes
Filter my fleet by attribute values Searching by Attributes