Skip to main content

Zafron CLI

The Zafron CLI (zafron) lets you manage devices, profiles, and data sources from the terminal. It supports both interactive and non-interactive workflows, making it suitable for scripting and LLM-assisted development.

Installation

Download the latest binary for your platform from the GitHub Releases page:

Authentication

Before using the CLI, log in with your Zafron account:

zafron login

You will be prompted for your email and password. The session token is saved to ~/.zafron/config.json.

Global Options

All commands support:

OptionDescription
--jsonOutput raw JSON instead of formatted tables
--helpShow help for a command
--versionShow CLI version

Devices

Manage IoT devices on the Zafron platform.

List devices

zafron devices list

Get device details

zafron devices get <id>

Create a device

zafron devices create

Interactive prompts guide you through device creation. You can also pass flags to skip prompts:

zafron devices create -n "My Sensor" -t mqtt -s "ABCDEF1234"
FlagDescription
-n, --name <name>Device name
-t, --type <type>Device type: mqtt or lora
-s, --serial <serial>Serial number (mqtt: 6-16 chars, lora: 16 hex char DevEUI)
-p, --profile <id>Profile ID (required for lora devices)

LoRa example:

zafron devices create \
-n "Dragino LHT65" \
-t lora \
-s "A84041000181C061" \
-p "675d2503bd75b9b238ce6305"

Update a device

zafron devices update <id> --name "New Name"
zafron devices update <id> --enabled false

Delete a device

zafron devices delete <id>

Use -y to skip the confirmation prompt.

View measurements

zafron devices measurements <id>
FlagDescription
--channel <ch>Filter by channel
--type <type>Filter by measurement type
--start <date>Start date
--end <date>End date
--limit <n>Number of results
--page <n>Page number

Profiles

Manage device profiles. Profiles define how incoming sensor data is decoded.

List profiles

zafron profiles list

Get profile details

zafron profiles get <id>

Create a profile

zafron profiles create

Interactive prompts guide you through profile creation. You can also pass flags:

zafron profiles create -n "My Profile" -s <source-id> -i cube
FlagDescription
-n, --name <name>Profile name
-s, --source <id>Source ID
-i, --image <image>Icon image

Available images: server, microchip, network, thermometer, water, battery, sun, wind, cloud, leaf, signal, satellite, bolt, gauge, cube, box, industry, warehouse, location, map, globe, tower

Update a profile

zafron profiles update <id> --name "New Name"
zafron profiles update <id> --image microchip

Delete a profile

zafron profiles delete <id>

Use -y to skip the confirmation prompt.


Decoder Management

Each profile has a decoder — a JavaScript function that transforms raw sensor payloads into Zafron's normalized format. The CLI provides commands to get, set, and test decoders.

Get a decoder

Output the current decoder script to stdout:

zafron profiles decoder get <profile-id>

Save to a file for editing:

zafron profiles decoder get <profile-id> > decoder.js

Set a decoder

Upload a decoder from a local file:

zafron profiles decoder set <profile-id> decoder.js

Or pipe from stdin:

cat decoder.js | zafron profiles decoder set <profile-id> --stdin

The CLI validates that the file contains a decode function before uploading.

Test a decoder

Test the decoder against a sample payload:

zafron profiles decoder test <profile-id> --payload "yzwKmwGJAX//f/8="
FlagDescription
--payload <string>Base64-encoded payload (required)
--fport <number>LoRaWAN fPort number (default: 1)
--hexTreat payload as hex string instead of base64

Example output:

┌─────────┬─────────────┬───────┬──────┬──────┐
│ Channel │ Name │ Value │ Unit │ Type │
├─────────┼─────────────┼───────┼──────┼──────┤
│ 1 │ Temperature │ 23.5 │ c │ temp │
└─────────┴─────────────┴───────┴──────┴──────┘

Decoder function format

A decoder must export a decode function with the following signature:

// fPort: LoRaWAN fPort number
// buffer: array of bytes, e.g. [225, 230, 255, 0]
// json: decoded data from the network (if available)
function decode(fPort, buffer, json) {
return [
{
channel: "1", // string - channel identifier
name: "Temperature", // string - human-readable name
value: 23.5, // number - the measurement value
unit: "c", // string - unit of measurement
type: "temp" // string - measurement type
}
];
}

Decoder workflow with Claude Code

The CLI's decoder commands are designed for LLM-assisted development. Here's a typical workflow:

# 1. Export the current decoder
zafron profiles decoder get <id> > decoder.js

# 2. Edit decoder.js (manually or with Claude Code)

# 3. Upload the updated decoder
zafron profiles decoder set <id> decoder.js

# 4. Test with a sample payload
zafron profiles decoder test <id> --payload "yzwKmwGJAX//f/8="

# 5. Iterate until the output is correct

Sources

Manage data sources (e.g., TTN, HTTP endpoints).

List sources

zafron sources list

Get source details

zafron sources get <id>