alarm.history.multi
The alarm.history.multi command is used to obtain historical alarm states for multiple alarms for a thing.
Alarm history can be requested by specifying the following:
-
A definite time period using a start and end date
-
A time period defined by the last period of time style query (for example, last:24h)
-
A last number of records
If more than one type of request is passed as a parameter, records have priority over last, and last will have priority over start and end.
TR50 Request
// Definite time period request
{
"cmd": {
"command": "alarm.history",
"params": {
"thingKey": "mything",
"keys": ["myalarm1", "myalarm2"],
"start": "2014-01-01T00:00:00Z",
"end": "2014-01-31T23:59:59Z"
}
}
}
// Last period of time request
{
"cmd": {
"command": "alarm.history",
"params": {
"thingKey": "mything",
"keys": ["myalarm1", "myalarm2"],
"last": "24h"
}
}
}
// Last number of records request
{
"cmd": {
"command": "alarm.history",
"params": {
"thingKey": "mything",
"keys": ["myalarm1", "myalarm2"],
"records": 100
}
}
}
Request Parameters
Name |
Type |
Required |
Description |
---|---|---|---|
|
Thing Identifier Parameters |
|
Identifies the Thing associated with the alarm states. If omitted, the thingKey associated with your session will be used. See Thing Identifier Parameters table below for supported parameters. |
keys |
String Array |
Yes |
The keys for the alarms to be queried. |
split |
Bool |
|
Set to true if you want the timestamp and value fields to be split into two arrays |
start |
String |
|
When doing a definite time period request this is the timestamp for the start of the specified time window. |
end |
String |
|
When doing a definite time period request this is the timestamp for the end of the specified time window. |
last |
String |
|
When doing a last period of time request this specifies the last X amount of time in nanoseconds (ns), microseconds (us), milliseconds (ms), seconds (s), minutes (m) or hours (h). |
records |
Integer |
|
When doing a last number of records request this specifies the number of records to return. |
If the start time is after the end time in a definition time period request, the system swaps the values.
Thing Identifier Parameters
This command is used to obtain historical alarm states for multiple alarms for a thing.
Name |
Type |
Description |
---|---|---|
thingKey |
String |
Key of the thing |
thingId |
String |
Id 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 |
msisdn |
String |
Msisdn of the thing |
TR50 Response
If the command is sent successfully a success message and the alarm state values found are returned. Otherwise, an error and error message will be returned.
The number of records returned is limited by Device Cloud. In cases where your selection has more results than the limit of Device Cloud, you should shorten your time window or lower the number of records you are requesting.
{
"cmd": {
"success": true,
"params": {
"values": [
{
"key": "myalarm1",
"state": 1,
"duration": 500,
"msg": "Message.",
"ts": "2006-01-02T15:04:05Z07:00"
}
]
}
}
}
// "split" response example
{
"cmd": {
"success": true,
"params": {
"keys": [
"myalarm1"
],
"timestamps": [
"2006-01-02T15:04:05Z07:00"
],
"states": [
1
],
"messages": [
"Message."
]
}
}
}
Response Parameters
The response parameters from alarm.history depend on the request parameter split. If split is false, the response parameters are as follows:
Name |
Type |
Description |
---|---|---|
key |
String |
The key associated with the alarm record. |
ts |
String |
Timestamp for the given value. |
msg |
String |
The message associated with the alarm state value. |
corrID |
String |
The correlation identifier associated with the alarm. |
state |
Integer |
The state associated with the alarm state value. |
duration |
Integer |
The duration associated with the alarm state value. |
lat |
Float |
Latitude coordinate associated with the alarm state value. |
lng |
Float |
Longitude coordinate associated with the alarm state value. |
Duration is calculated as the difference between an alarm state's timestamp and the next state's timestamp. This means that the most recent state will have a duration of zero; it will have a value when the next alarm state gets published.
If split is true, the response parameters are as follows:
Name |
Type |
Description |
---|---|---|
keys |
Array |
Array of alarm keys |
timestamps |
Array |
Array of timestamps |
corrID |
String |
The correlation identifier associated with the alarm. |
states |
Array |
Array of integer states |
messages |
Array |
Array of messages. |
The alarm.history.multi response can also contain the following key:
Name |
Type |
Description |
---|---|---|
truncated |
Boolean |
If this value is in the response, it will be true. It is defined if the number of possible records is equal to or greater than the maximum configured. |