thing.attr.get
The thing.attr.get command is used to get an attribute for a thing.
TR50 Request
{
"cmd": {
"command": "thing.attr.get",
"params": {
"thingKey": "mything",
"key": "boardid"
}
}
}
Request Parameters
Name | Type | Required | Description |
---|---|---|---|
thingId | String | Yes* |
ID of the Thing |
thingKey | String |
Key of the Thing |
|
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 get. |
TR50 Response
If the command is sent successfully a success message is returned. Otherwise, an error and error message will be returned.
{
"cmd": {
"success": true,
"params": {
"value": "test_attribute",
"ts": "2018-11-10T11:22:33Z"
}
}
}
Response Parameters
Name | Type | Description |
---|---|---|
value | String | The current value for the requested attribute. If the attribute value has not been set by the thing and there is a default attribute set for the thing's thing definition, the default attribute is returned. |
ts | String | The timestamp that the value was explicitly set on the thing. There is no timestamp returned when the value returned is the default attribute value. |
C API
// basic API
int tr50_thing_attr_get(void *tr50, const char *key, char **value);
// extended API
int tr50_thing_attr_get_ex(void *tr50, const char *key, char **value, void* optional_params, void** optional_reply, char** error_msg);
JAVA API
//Synchronous
int attributeGet(String thingKey, String attrKey, Object response);
//Asynchronous
int attributeGet(String thingKey, String attrKey, DwOpenReceiveActionListener recv, Object response);
Response Objects: Class StringReply, DwOpenResponse, DwOpenThingAttributeGet. For more information on these response objects, see JAVA - Worker APIs