Documentation
Commands API

Commands API

Send commands to your devices and read sensor data on demand.


Not a developer? You don't need this page! Use the Palpable app or talk to PAL to control your devices.

Send Command

Execute a command on a device module.

POST /api/devices/command

const res = await fetch('https://palpable.technology/api/devices/command', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer pk_your_api_key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    deviceId: '550e8400-...',
    moduleId: 'modulino-pixels',
    tool: 'setAll',
    params: { r: 255, g: 0, b: 128 }
  })
})
const data = await res.json()
FieldTypeRequiredDescription
deviceIduuidNoTarget a specific device (omit to broadcast to all)
moduleIdstringNoTarget a specific module type
toolstringYesThe command to execute
paramsobjectNoCommand-specific parameters

Response

{
  "success": true,
  "message": "Tool \"setAll\" executed on 1 device(s)",
  "results": [
    {
      "deviceId": "550e8400-...",
      "deviceName": "Living Room Hub",
      "moduleId": "modulino-pixels",
      "success": true,
      "method": "websocket"
    }
  ]
}

Command Delivery

MethodDescription
websocketDelivered in real-time (device online)
queuedDevice offline -- command will execute when it reconnects

Read Sensor

Read a current sensor value.

POST /api/devices/read

const res = await fetch('https://palpable.technology/api/devices/read', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer pk_your_api_key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    deviceId: '550e8400-...',
    moduleId: 'modulino-thermo',
    tool: 'read_temperature'
  })
})
const reading = await res.json()
console.log(reading.value, reading.unit) // 23.5 celsius

Response

{
  "deviceId": "550e8400-...",
  "moduleId": "modulino-thermo",
  "tool": "read_temperature",
  "value": 23.5,
  "unit": "celsius",
  "timestamp": "2024-01-15T10:30:00Z"
}

Common Read Commands

ToolModule TypesReturns
read_temperaturemodulino-thermo, bme280{ value, unit: "celsius" }
read_humiditymodulino-thermo, bme280{ value, unit: "percent" }
read_pressurebme280{ value, unit: "hPa" }
read_luxveml7700{ value, unit: "lux" }
read_vocsgp40{ value, unit: "index" }
read_distancemodulino-distance{ value, unit: "mm" }
read_allAnyAll available sensor values

Common Actuator Commands

ToolModule TypesParameters
beepmodulino-buzzer{ frequency: Hz, duration: ms }
setAllmodulino-pixels{ r: 0-255, g: 0-255, b: 0-255 }
setPixelmodulino-pixels{ index, r, g, b }
clearmodulino-pixelsNone

Broadcast Commands

Omit deviceId to send a command to every device with the matching module:

{
  "moduleId": "modulino-pixels",
  "tool": "setAll",
  "params": { "r": 0, "g": 255, "b": 0 }
}

Error Handling

Device Offline

Commands are queued and execute when the device reconnects.

Module Not Found

{
  "success": false,
  "error": "Module not found",
  "message": "Could not find module modulino-pixels on your devices."
}