Historical Context
This custom node is a simple node that allows to obtain historical context from STH-Comet.
Properties
This node allows to obtain raw context information or historical aggregate time series context information from STH-Comet.
- Raw context information
- Historical aggregate time series context information
- Average of all the samples
- Maximum value
- Sum of all the samples
- Sum of the square value of all the samples
- Occur for attributes values of type string
You can specify the start and end of the target period.
- ISO 8601
- years
- months
- days
- hours
- minutes
- seconds
For example, if you want to get historical context from 3 days ago to 2 days ago, specify as follows.
Raw context information
name
: a name for a node instanceGeneric Enabler
: an endpoint of a STH-CometServicePath
: FIWARE Service PathEntity id
: an entity id to retrieveEntity type
: an entity type to retrieveAttribute
: an attribute to retrieveDate type
: data type to retrieveLastN
: only the requested last entries will be returned. It is a mandatory parameter if no Limit and Offset are providedLimit
: in case of pagination, the number of entries per page. It is a mandatory parameter if no lastN is providedOffset
: in case of pagination, the offset to apply to the requested search of raw context information. It is a mandatory parameter if no lastN is providedDate from
: the starting date and time from which the raw context information is desired. It is an optional parameterUnit for data from
: unit for starting dateDate to
: the final date and time until which the raw context information is desired. It is an optional parameter.Unit for data to
: unit for the final dateOutput type
:raw
,value
ordashboard
Count
: the total count of elementsDecode forbidden chars
:off
oron
Input
payload JSON Object
A msg.payload
may contain attributes as shown:
{
"entityId":
"attrName":
"entityType":
"dataType": "raw"
"lastN:
"hLimit":
"hOffset":
"dateFrom:"
"fromUnit": "ISO8601", "years", "months", "days", "hours", "minutes" or "seconds"
"dateTo:
"toUnit": "ISO8601", "years", "months", "days", "hours", "minutes" or "seconds"
"outputType: "raw", "value", "dashboard"
"count": "true" or "false"
}
These attributes are optional. If properties have appropriate values, you can retrieve historical context by sending an empty JSON Object to this node. If an attribute has a value, it overwrites the value of its corresponding property.
Output
payload JSON Object
A msg.payload
contains historical context data.
statusCode Number
A msg.statusCode
contains a status code.
200
Historical Aggregated Time Series Context Information
name
: a name for a node instanceGeneric Enabler
: an endpoint of a STH-CometServicePath
: FIWARE Service PathEntity id
: an entity id to retrieveEntity type
: an entity type to retrieveAttribute
: an attribute to retrieveDate type
: data type to retrieveAggrPeriod
: Aggregation period or resolutionDate from
: the starting date and time from which the raw context information is desired. It is an optional parameterUnit for data from
: unit for starting dateDate to
: the final date and time until which the raw context information is desired. It is an optional parameter.Unit for data to
: unit for the final dateOutput type
:raw
,value
ordashboard
Decode forbidden chars
:off
oron
Input
payload JSON Object
A msg.payload
may contain attributes as shown:
{
"entityId":
"attrName":
"entityType":
"dataType": "ave", "max", "sum", "sum2" or "occur"
"hLimit":
"hOffset":
"aggrPeriod": "month", "day", "hour", "minute" or "second"
"dateFrom:"
"fromUnit": "ISO8601", "years", "months", "days", "hours", "minutes" or "seconds"
"dateTo:
"toUnit:
"outputType: "raw", "value" or "dashboard"
"count": "true" or "false"
}
These attributes are optional. If properties have appropriate values, you can retrieve historical context by sending an empty JSON Object to this node. If an attribute has a value, it overwrites the value of its corresponding property.
Output
payload JSON Object
A msg.payload
contains historical context data.
statusCode Number
A msg.statusCode
contains a status code.
200
Examples
Output (raw)
{
"type": "StructuredValue",
"value": [
{
"_id": {
"attrName": "temperature",
"origin": "2023-01-01T00:00:00.000Z",
"resolution": "month"
},
"points": [
{
"offset": 1,
"samples": 20,
"sum": 100
},
{
"offset": 1,
"samples": 0,
"sum": 0
}
]
}
]
}
Output (value)
[
{
"_id": "63d115bb5f63eb554d85a13b",
"attrName": "temperature",
"attrType": "Number",
"attrValue": 20.6,
"recvTime": "2023-01-25T11:42:51.143Z"
},
{
"_id": "63d115bd5f63eb554d85a141",
"attrName": "temperature",
"attrType": "Number",
"attrValue": 20.6,
"recvTime": "2023-01-25T11:42:53.143Z"
},
{
"_id": "63d115bf5f63eb554d85a147",
"attrName": "temperature",
"attrType": "Number",
"attrValue": 20.6,
"recvTime": "2023-01-25T11:42:55.145Z"
}
]
Output (dashboard)
This output is for the NGSI-to-dashboard custom node.
{
"type": "StructuredValue",
"value": [
{
"_id": "63d115bb5f63eb554d85a13b",
"attrName": "temperature",
"attrType": "Number",
"attrValue": 20.6,
"recvTime": "2023-01-25T11:42:51.143Z"
},
{
"_id": "63d115bd5f63eb554d85a141",
"attrName": "temperature",
"attrType": "Number",
"attrValue": 20.6,
"recvTime": "2023-01-25T11:42:53.143Z"
},
{
"_id": "63d115bf5f63eb554d85a147",
"attrName": "temperature",
"attrType": "Number",
"attrValue": 20.6,
"recvTime": "2023-01-25T11:42:55.145Z"
}
],
"entityId": "E",
"attrName": "A1",
"entityType": "T1",
"dataType": "raw"
}