References
.data()
.set()

device.data.set

Just like get, you can also set the data of the device in similar way.

This method accepts the following arguments

NameTypeDescription
pathstringcan be empty or a path to a key in dot notation
valuestringyou can provide a valid value for the field that you want to update

This method returns the following codes in response

DEVICE-DATA-UPDATED

details has been updated

DEVICE-DATA-UPDATE-FAILED

happens when you set value to parent.child and parent is also not an object

DEVICE-NOT-PAIRED

device is not paired to the account

DEVICE-ID-INVALID

device is not registered with this id

DATA-INVALID

device id is required

Use of set method has been illustrated in the example below

// Submit request to the server
device.data().set("voltage").then((res) => {
  // Got the response
  switch(res.code) {
    case "DEVICE-DATA-UPDATED": 
      // Device data has been updated
      console.log(res.update, res.path);
  }
})