Difference between revisions of "How to report data with timestamp"
From ESS-WIKI
Line 43: | Line 43: | ||
</syntaxhighlight>Report Data Sample: | </syntaxhighlight>Report Data Sample: | ||
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="JAVA">{ |
"HWM": { | "HWM": { | ||
"e": [ | "e": [ | ||
Line 74: | Line 74: | ||
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="JAVA">{ |
"HWM": { | "HWM": { | ||
"e": [ | "e": [ | ||
Line 110: | Line 110: | ||
</syntaxhighlight>Report Data Sample with Timestamp | </syntaxhighlight>Report Data Sample with Timestamp | ||
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="JAVA">{ |
"HWM": { | "HWM": { | ||
"e": [ | "e": [ |
Revision as of 08:04, 26 October 2017
Situation
In Handler, user can attach their timestamp into report data and capability with tag 'opTS'.
In original capability and report data, user only describe and report the sensor data without carry any timestamp or carried as a sensor data as below.
Capability Sample:
{
"HWM": {
"e": [
{
"n": "cpu1_volt",
"type": "volt",
"u": "V",
"max": 20,
"min": 10
},
{
"n": "cpu2_volt",
"type": "volt",
"u": "V",
"max": 20,
"min": 10
},
{
"n": "cpu1_temp",
"type": "temp",
"u": "Cel",
"max": 100,
"min": 10
},
{
"n": "timestamp",
"type": "tick",
"u": "millisec"
}
],
"bn": "HWM"
}
}
{
"HWM": {
"e": [
{
"n": "cpu1_volt",
"v": 10
},
{
"n": "cpu2_volt",
"v": 10
},
{
"n": "cpu1_temp",
"v": 10
},
{
"n": "timestamp",
"v": 1508998354
}
],
"bn": "HWM"
}
}
Solution
For RMM 3.3, user can carried the timestamp as a special tag 'opTS' in the capability or report, the server will store the timestamp related with each sensor data. The 'opTS' format is "opTS":{"$date":1508998354000}. The '$date' must be the milli seconds since Jan 01 1970 (UTC).
Capability Sample with Timestamp
{
"HWM": {
"e": [
{
"n": "cpu1_volt",
"type": "volt",
"u": "V",
"max": 20,
"min": 10
},
{
"n": "cpu2_volt",
"type": "volt",
"u": "V",
"max": 20,
"min": 10
},
{
"n": "cpu1_temp",
"type": "temp",
"u": "Cel",
"max": 100,
"min": 10
},
{
"n": "timestamp",
"type": "tick",
"u": "millisec"
}
],
"bn": "HWM"
},
"opTS":{"$date":1508998354000}
}
{
"HWM": {
"e": [
{
"n": "cpu1_volt",
"v": 10
},
{
"n": "cpu2_volt",
"v": 10
},
{
"n": "cpu1_temp",
"v": 10
},
{
"n": "timestamp",
"v": 1508998354
}
],
"bn": "HWM"
},
"opTS":{"$date":1508998354000}
}