property.publish
The property.publish command is used to publish property data (typically sensor data) for a thing. For more information about properties see Understanding properties.
When the deDuplicate flag is set to true for the property key in the thing definition for the thing, any duplicate entries (an entry is considered a duplicate if it has the same timestamp of an existing or previously encountered publish regardless of value) will be ignored. The property will not be updated, no triggers will be fired, and no aggregation will be done for the duplicate.
{
"cmd": {
"command": "property.publish",
"params": {
"thingKey": "mything",
"key": "myprop",
"value": 123.44,
"ts": "2020-01-05T02:03:04.322Z",
"corrId": "mycorrid",
"aggregate":true
}
}
}
If a Scale is defined in the thing definition property for the thing, when a property.publish is executed, the equation will be applied and the resulting value will be stored.
Request Parameters
Name | Type | Required | Description |
---|---|---|---|
thingKey | String | Yes* | The thing key. |
thingid | String | Id of the thing | |
esn | String | ESN of the connection. | |
iccid | String | ICCID of the connection. | |
imei | String | IMEI of the connection. | |
imsi | String | IMSI of the connection. | |
meid | String | MEID of the connection. | |
msisdn | String | MSISDN of the connection. | |
*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 property that you wish to publish. |
value | Float | Yes | The value to publish. |
ts | String | The timestamp in which the value was recorded. | |
aggregate | Boolean | If 'true', then aggregate data (hourly and daily) will be generated for the values published in this API call if 'false' only the history will be saved. If not set, then the Calculate aggregates parameter in the property definition in the thing definition for the thing is used. | |
corrId | String | A correlation ID that can be used when querying to find related data objects. |
If the command is sent successfully a success message is returned. Otherwise, an error and error message will be returned.
{
"cmd": {
"success": true
}
}
C API
// basic API
int tr50_property_publish(void *tr50, const char *prop_key, const double value);
// extended API
int tr50_property_publish_ex(void *tr50, const char *prop_key, const double value, void* optional_params, void** optional_reply, char** error_msg);
JAVA API
// Synchronous
int publish(String thingKey, String timestamp, String propKey, double propValue, String corrId, Object response);
// Asynchronous
int publish(String thingKey, String timestamp, String propKey, double propValue, String corrId, DwOpenReceiveActionListener recv, Object response);
Response Objects: StringReply, DwOpenResponse
PHP API
Boolean TR50httpWorker::propertyPublish($thingKey, $key, $value[, $ts[, $corrId]]);