Report Generator
The Report Generator is a tool that allows you to receive customized reports about your data via email.
Usage
You define a report as an action in the Rule Engine UI
Method 1: Array of Objects
You can define a report as an action in the Rule Engine UI. There are three ways to define a report:
Example:
[
{
"nodes": [
"63a2cfec12169cf61ae14381",
"63a2d11212169cf61ae14385"
],
"measurement": "temperature",
"graph": "step",
"duration": "1M",
"distance": "1d"
},
{
"nodes": [
"63a2cfec12169cf61ae14381",
"63a2d11212169cf61ae14385"
],
"measurement": "humidity",
"graph": "step",
"duration": "1w",
"distance": "1d"
}
]
Method 2: Single Object with Device Count
You can define a report using a single object that specifies a type of measurement and sets the deviceCount boolean to true. This method generates a special report listing all the IoT nodes owned by the user.
Example:
[
{
"measurement": "deviceCount",
"deviceCount": true,
"startTime": "2019-01-01T00:00:00.000Z", // optional
"endTime": "2019-01-31T00:00:00.000Z" // optional
}
]
Method 3: Single Object with Query
You can define a report using a single object that specifies a type of measurement and a query. This method is useful when you want to generate a report that includes all the IoT nodes owned by the user or specific nodes based on a device model name or ID. (This report will send a email with an attached CSV file containing the data) The format of the CSV file is determined by the value of the key "csv-column" or "csv-table". If the value of the key "csv-column" is set to "true", the CSV file will be in the format of a column. If the value of the key "csv-table" is set to "true", the CSV file will be in the format of a table. If neither of the keys "csv-column" or "csv-table" is set to "true", the CSV file will be in the format of a table by default.
In addition, you can define the name of the file by setting the value of the key "fileName" to a string. If the value of the key "fileName" is not set, the name of the file will be "report.csv" by default. You also have the option to set a fixed "endTime", which will be used as the end time for the report. If the value of the key "endTime" is not set, the current time will be used as the end time for the report by default.
Example:
[
{
"query": "all",
"csv-column": true,
"measurement": "temperature",
"duration": "3M",
"distance": "1M",
"endTime": "2019-01-31T00:00:00.000Z",
"fileName": "myReport.csv"
}
]
[
{
"query": {
"deviceModelName": "myDeviceModelName"
},
"csv-column": true,
"measurement": "temperature",
"duration": "3M",
"distance": "1M",
"fileName": "myReport.csv"
}
]
[
{
"query": {
"_id": "63a2d11212169cf61ae14385"
},
"csv-table": true,
"measurement": "temperature",
"duration": "3M",
"distance": "1M"
}
]
Report Structure:
- An array of objects, each containing information about a specific report.
-
Nodes: An array of strings representing the unique identifiers for the nodes being measured, at least one node is required.
-
Measurement: A string describing the type of measurement being taken (e.g. "temperature").
-
Graph: A string describing the type of graph to be used to display the data, the possible options are:
- "step": This will display the data as a step graph
- "line": This will display the data as a line graph
- "bar": This will display the data as a bar graph
-
Duration: A string describing the length of time over which the measurements will be taken for the entire report, in the format of "value"+"unit", where value is a number and unit is one of the following: "s" for seconds, "m" for minutes, "d" for days, "h" for hours, "w" for weeks, "M" for months, and "y" for years.
-
Distance (optional): A string describing the time distance between the measurements, in the format of "value"+"unit", where value is a number and unit is one of the following: "s" for seconds, "m" for minutes, "d" for days, "h" for hours, "w" for weeks, "M" for months, and "y" for years.
-
For Method 2 the properties are:
- Measurement: A string describing the type of measurement being taken, currently only "deviceCount" is supported for the special report that lists all the IoT nodes owned by the user. If "deviceCount" is specified, the value of the key "deviceCount" should be set to "true" to enable this special report.
- deviceCount: A boolean value that should be set to "true" if the measurement is "deviceCount".
For Method 3 the additional properties are:
- Query: A String or Object describing the type of query to be used to generate the report, the possible options are:
- "all": This will generate a report that includes all the IoT nodes owned by the user. (e.g,
query: "all"
). - "query.deviceModelName": This will generate a report that includes all the IoT nodes owned by the user that have the specified device model name. (e.g,
query: {deviceModelName: "myDeviceModelName"}
). - "query._id": This will generate a report that includes all the IoT nodes owned by the user that have the specified device model id. (e.g,
query: {_id: "63a2d11212169cf61ae14385"}
).
- "all": This will generate a report that includes all the IoT nodes owned by the user. (e.g,