Gathered data or settings are associated with sensors and configurable items. Each sensor or configurable item belongs to a host.
A host may be bound to a prototype, set up in a.fa.se. From the prototype it is possible to determine which host fulfills a certain role, even when devices are replaced.
To uniquely identify a sensor or configuration item you must specify its key and its host.
Sensors and configurable values have a history of previous values. Configurable values also have information about the latest configuration change request recieved by the API.
Sensors may have an associated alarm which produces alarm events. Alarm events may have one or more acknowledgements.
All times are represented in Unix-time, which means the number of seconds passed since 1970-01-01 00:00:00 UTC.
Prototypes
Prototypes from a.fa.se define the roles that devices/hosts fulfill.
The JSON representation of a prototype is an object like this:
{
"id": "9e222f14-5b1f-4790-bcac-afa8a675b592",
"site": "S:t Larsgatan",
"name": "Smartbox CDEF",
"host": "d0ff50abcdef",
}
idis the unique identifier of the prototypesitethe location of the device, is not guaranteed to be permanent or unique.namethe role of the device, is not guaranteed to be permanent or unique.hostis the identifier of the host bound to this prototype
To keep a permanent reference to a device, store a reference to the prototype id instead of the host. If a device is replaced the host will change, but the prototype will be bound to the new host.
The list of prototypes should be regularly checked to determine which host is currently bound to a prototype.
The list of prototypes is better suited than the list of hosts for presenting a device selection in a GUI. The separate site and name information gives more options for presenting their names, and the prototype id is available.
Hosts
Devices in a.fa.se are referred to as hosts in the API.
The JSON representation of a host is an object like this:
{
"name": "Box_cdef",
"host": "d0ff50abcdef",
"lastclock": 1416586490,
"items": [ ... ],
"ip": "10.0.0.1"
}
hostis the unique identifier of a host, used for the{host}part of request paths.nameis not guaranteed to be permanent or uniquelastclockindicates the latest value measured from this host. It may be null if there has not yet been any data collecteditemsis an array of the sensors and configurable items belonging to the host. It is left out in some cases.
Sensors
The JSON representation of a sensor data is an object like this:
{
"name": "pump 3.40004 BT1 Outdoor temp",
"unit": "degC",
"lastclock": 1416586545,
"lastvalue": 2.4,
"key": "modbus.pump.F1345.3.40004",
"configurable": false
}
keyis unique per host, but is not necessarily globally unique. It is used for the{item}part of request paths.nameis not guaranteed to be permanent or uniqueunitspecifies the meaning of the valueconfigurableis false for sensorslastvalueis the latest sensor value, may be null if there has never been any data collectedlastclockindicates time when lastvalue was measured, may be null if there has never been any data collected
Configurable items
The JSON representation of a configurable item is just like a sensor, except its configurable value is true, and it has a config property:
{
"name": "pump 3.47024 Own Curve P3",
"unit": "degC",
"lastclock": 1416586606,
"config": {
"audit": [],
"target": null,
"lastclock": null,
"status": "SUCCESS",
"expected": null
},
"lastvalue": 46,
"key": "modbus.pump.F1345.3.47024",
"configurable": true
}
- The
configobject contains information about the latest configuration change received by the API. Note that thisconfigchange has not necessarily been successfully applied. targetis the desired new value, may be null if no configuration request has been madeexpectedis the value expected before the change, may be null if no configuration request has been madeauditis an array of strings with information identifying who or what initiated the changelastclockindicates when this configuration change was received, may be null if no configuration request has been madestatusis one ofPENDING,SUCCESS,FAILED
History
The JSON representation of a sensor value history is an array:
[
[1416586366, 2.2],
[1416586426, 2.3],
[1416586485, 2.3],
[1416586545, 2.4],
...
]
- History data is represented as pairs of earlier lastclock and lastvalue values.
- The values are guaranteed to be in order, but there may be gaps in the data.
Trend
Trend data are collated series of data for an interval, representing the minimum, average, maximum for the period, as well as a count of samples.
The JSON representation is a time-series of objects:
[
[1458763440, {"num": 60, "min": 0.1, "avg": 1.2, "max": 2.0}],
[1458767040, {"num": 60, "min": 0.2, "avg": 1.2, "max": 2.0}],
[1458770640, {"num": 55, "min": 0.2, "avg": 1.2, "max": 2.0}]
]
Trend data also comes in more specific calls that look exactly like the history data. See below for API call section.
Alarm events
Alarm events represent instances when alarms trigger or when they are resolved. Its JSON representation is an object:
{
"eventid": 4711,
"host": "d0ff50abcdef",
"key": "modbus.corrigo2.regin_ch.2.24",
"value": "OK",
"clock": 1421944072,
"description": "Circulation pump not running",
"severity": [3, "C-Larm"],
"acknowledgements": [ ... ],
"problem_id": 4707
}
eventidis the unique identifier of an event, necessary for acknowledging an eventhostis the unique identifier of a host, used for the{host}part of request paths.keyis unique per host, but is not necessarily globally unique. It is used for the{item}part of request paths.valueis the type of event, which may be:problemindicating that the alarm was triggeredOKindicating that the problem is resolvedunknownin rare occasions when data is missing
clockindicates when the event occurreddescriptionis a human readable description of the problem this event relates toseverityis a pair[num, "text"]:- the number part is priority (3 == lowest, 5 == highest)
- text is a textual description ("A-Larm", "B-Larm", "C-Larm")
acknowledgementsis an array of acknowledgement messages for this event. The array may be empty.problem_idis the identifier of the problem event that corresponds to an OK event. This field is absent for problem events, or if the OK event is the first event for the trigger.
Acknowledgements
Event acknowledgements can be used to document actions taken for an alarm. They are represented as a simple JSON object:
{
"clock": 1421943944,
"message": "Service technician dispatched"
}
clockindicates when the acknowledgement was mademessagecontains free-form text
Triggers
The JSON representation of a trigger data is an object like this:
{
"triggerid": 17,
"description": "Frost alarm",
"hosts": [ ... ],
"lastchange": 1421944072,
"value": "OK",
"severity": [5, "A-Larm"]
}
triggeridis an unique id of this triggerdescriptioncontains free-form texthostsis an array of all hosts affected by this triggervalueis the current value of the triggerlastchangeis the timestamp the trigger last changed stateseverityis a pair [num, "text"]:- numerical part is priority (3 == lowest, 5 == highest)
- text is a textual description ("A-Larm", "B-Larm", "C-Larm")