thing.attr.set
The thing.attr.set command is used to set an attribute for a thing.
TR50 Request
{
"cmd": {
"command": "thing.attr.set",
"params": {
"thingKey": "mything",
"key": "boardid",
"value": "102",
"republish": true
}
}
}
Request Parameters
Name | Type | Required | Description |
---|---|---|---|
thingId | String | Identifies the thing by id to which the attribute is to be associated. | |
thingKey | String | Identifies the thing by key to which the attribute is to be associated. | |
esn | String | ESN of the thing. | |
iccid | String | ICCID of the thing. | |
imei | String | IMEI of the thing. | |
imsi | String | IMSI of the thing. | |
meid | String | MEID of the thing. | |
*One of the above parameters is required to identify the thing. If omitted, the thingKey associated with your session will be used. | |||
key | String | Yes | The key for the attribute that you wish to set. |
value | String | Yes | The value of the attribute. |
republish | Boolean | By default, if the published value is the same as the current value, a new record will not be added. Set to true to force the record of the value to be added. If not set, the default value is false. | |
corrId | String | A correlation ID that can be used when querying to find related data objects. If the correlation ID is different from the one that is published then a new record is added. |
If the command is sent successfully a success message is returned. Otherwise, an error and error message will be returned.
TR50 Response
{
"cmd": {
"success": true
}
}
C API
// basic API
int tr50_thing_attr_set(void *tr50, const char *key, const char* value);
// extended API
int tr50_thing_attr_set_ex(void *tr50, const char *key, const char *value, void* optional_params, void** optional_reply, char** error_msg);
JAVA API
// Synchronous
int attributeSet(String thingKey, String attrKey, String attrValue, Object response);
// Asynchronous
int attributeSet(String thingKey, String attrKey, String attrValue, DwOpenReceiveActionListener recv, Object response);
Response Objects: StringReply, DwOpenResponse