Dear Team,
I am creating devices using analisys, now i want to add small feature, during creating device also add right away device-token to parameter. Is it possible using analisys?
Dear Team,
I am creating devices using analisys, now i want to add small feature, during creating device also add right away device-token to parameter. Is it possible using analisys?
Hi,
You can achieve this by using the TagoIO SDK to create a device and add the device token as a tag. Here’s a sample code snippet to guide you:
const { Analysis, Resources } = require(“@tago-io/sdk”);
async function myAnalysis(context, scope) {
const deviceData = {
name: “My Device”,
type: “mutable”,
network: “”,
connector: “”,
};
const newDevice = await Resources.devices.create(deviceData);
// Set the tags for the device.
await Resources.devices.edit(newDevice.device_id, {
tags: [
{ key: “device_token”, value: newDevice.token },
{ key: “device_id”, value: newDevice.device_id },
{ key: “device_type”, value: “organization” },
],
});
}
Analysis.use(myAnalysis);