publishCommands

Requires:
DeviceKit≥2.1.0@ray-js/ray≥0.6.23
Platforms:
iOSAndroid
import { device } from '@ray-js/ray';

const { publishCommands } = device;

// Promise usage
try {
  const res = await publishCommands({ ...params });
  console.log(res);
} catch (err) {
  console.log(err.errorMsg);
}

Method signature
publishCommands(params: )
Minimum SDK versions
iOSThingSmartDeviceKitBizBundle
≥ 5.2.0
Androidcom.thingclips.smart:thingsmart-bizbundle-devicekit
≥ 5.2.0

Description

Send standard dp

Parameters

PropertyTypeRequiredDescriptionMinimum SDK versions
deviceIdstringYesDevice ID—
dpsRecord<string, Record<string, any>>Yesdps—
modenumberYesDelivery channel type 0: LAN 1: Network 2: Auto—
pipelinesnumber[]YesPriority of delivery channels LAN = 0, // LAN MQTT = 1, // MQTT HTTP = 2, // Http BLE = 3, // Single Point Bluetooth SIGMesh = 4, // Sig Mesh BLEMesh = 5, // Thing Private Mesh BLEBeacon = 6, // Beacon—
optionsRecord<string, Record<string, any>>YesReserved flag for delivery logic configuration; can be extended later, for example to deliver sounds or define follow-up actions—
complete() => voidNoCompletion callback (executed on both success and failure)—
success(params: boolean) => voidNoCallback on successful API call—
fail(params: Object) => voidNoFailure callback—
fail callback parameters
PropertyTypeDescription
errorMsgstringError message
errorCodestring | numberError code
Error extension

Return Value

None

Examples

import { device } from '@ray-js/ray'

device.publishCommands({
  deviceId: "xx",
  dps: { "xx": {} },
  mode: 1,
  pipelines: [1],
  options: { "xx": {} },
  success: data => {
    console.log(data);
  },
  fail: error => {
    console.error(error);
  },
});