Retrieve data and start measurements with GraphQL
Discover devices, retrieve recorded vibration arrays and understand the separate commands that start acquisition.
These examples preserve the earlier GrapheneVibrationCombo API. The public Python examples declare iQunet software newer than 1.2.2, but this is not a compatibility guarantee for every later sensor or release. Check the installed schema before using a query or mutation.
Find the endpoint and inspect the schema
The documented local endpoint is http://<gateway-ip>:8000/graphql. With the earlier hotspot configuration it is http://192.168.42.1:8000/graphql. Replace the gateway address with the one reachable from your computer.
Open Docs in that version’s GraphQL interface to inspect available queries, mutations, argument names and types. The original interface needed an internet connection to load browser libraries from a CDN. That was a requirement of the documented interface, not proof that the current gateway needs internet access for local API requests.
The public Python client first obtains a csrftoken cookie, then sends it as both a cookie and an x-csrftoken header using RequestsHTTPTransport. This describes that example’s request handling; it is not a replacement for the access requirements of your installation.
Discover device identities
Start with the device list and copy the macId of the intended sensor. The examples use the exact device identity, not its editable tag. All sensor IDs and dates shown below are illustrative source examples; replace them with values from your gateway.
{
deviceManager {
deviceList {
parent
macId
tag
}
}
}Select recorded measurements
For a GrapheneVibrationCombo device, first request vibrationTimestampHistory. Keep each returned timestamp exactly, including fractional seconds and its time-zone offset. The limit restricts the number of returned measurement timestamps, not the number of samples inside a vibration array.
The public Python example also supplies start, end and axis filters. Choose a bounded interval containing your measurements and inspect __typename before using a device-specific fragment. This example does not define a pagination cursor or guarantee that one limited response contains the whole history.
{
deviceManager {
device(macId: "78:47:8e:af") {
__typename
... on GrapheneVibrationCombo {
vibrationTimestampHistory(limit: 10)
}
}
}
}{
deviceManager {
device(macId: "78:47:8e:af") {
__typename
... on GrapheneVibrationCombo {
vibrationTimestampHistory(
start: "2021-02-10"
end: "2021-02-24"
limit: 4
axis: "XYZ"
)
}
}
}
}Retrieve the selected vibration array
Pass an exact returned timestamp to vibrationArray(isoDate: ...). The date below is retained from the original example and is not a measurement that will exist on your gateway. Request the capture metadata together with the sample array so the result can be interpreted correctly.
{
deviceManager {
device(macId: "78:47:8e:af") {
__typename
... on GrapheneVibrationCombo {
vibrationArray(
isoDate:
"2018-03-08T09:12:48.681441+00:00"
) {
axis
numSamples
sampleRate
rawSamples
formatRange
}
}
}
}
}| Field | Meaning in this documented format |
|---|---|
| numSamples | Number of samples in the vibration array. |
| rawSamples | Raw, unscaled acceleration samples. |
| sampleRate | Sampling rate in Hz. |
| formatRange | Accelerometer capture range; 4 represents ±4 g. |
| axis | Captured axis: X, Y or Z. |
Convert the documented raw format
For the legacy AccelerationPack format in this guide, divide each raw sample by 512.0 and multiply by the returned formatRange to obtain acceleration in g. Sample times are relative to the start of the array, in seconds. The last sample is at (numSamples - 1) / sampleRate.
This conversion is specific to the documented raw format. Do not apply it to already processed vibration values or to a different sensor format such as ModVibe without that format’s own definition. A capture’s recorded timestamp and the relative sample-time vector have different meanings.
# rawSamples, formatRange, numSamples and sampleRate
# come from the same returned vibrationArray.
acceleration_g = [sample / 512.0 * formatRange for sample in rawSamples]
time_s = [index / sampleRate for index in range(numSamples)]Start a vibration measurement
Queries above retrieve stored information. The mutation below changes acquisition state and starts a measurement on the selected sensor. It is the original article’s vibration example, with line breaks added for readability. Its numeric settings are illustrative, not recommended defaults for every machine.
The later public mutation script additionally supplies hpf and prefetch. Whether those arguments are present or required must be checked in the installed schema. An ok response is not the downloaded vibration array; use the history and array queries to retrieve a completed measurement.
mutation {
vibrationRunSetup(
sampleRate: 3200
formatRange: 16
threshold: 0.01
axis: "XYZ"
numSamples: 2048
macId: "e7:f9:6e:36"
) {
ok
}
}| Argument | Purpose |
|---|---|
| macId | Identity of the sensor whose acquisition will be changed. |
| sampleRate | Requested capture sampling rate. |
| formatRange | Requested accelerometer range. |
| threshold | The article describes this as the RMS threshold. |
| axis | Requested capture axes, shown as XYZ. |
| numSamples | Requested number of samples per capture. |
Configure periodic acquisition
setQueueInterval sets the automatic measurement interval in seconds. setQueueEnabled enables or disables automatic measurements for the specified sensor. These are separate mutations, so submit only the operation you intend after checking the sensor and its existing configuration.
The source example uses 120 seconds and enabled: true. Use enabled: false to disable automatic measurements. These commands do not describe every device’s internal continuous-sampling or peak-selection behavior.
mutation {
setQueueInterval(interval: 120, macId: "e7:f9:6e:36") {
ok
}
}mutation {
setQueueEnabled(enabled: true, macId: "e7:f9:6e:36") {
ok
}
}Other sensor families and example limits
The original acquisition article also names hallRunSetup for proximity, tiltRunSetup for inclination and reedRunSetup for the proximity switch. These are different operations for different sensor families, not aliases for vibrationRunSetup.
In the original reed-switch example, numSamples is the number of transmissions before the sensor returns to sleep. The example below requests 31 transmissions. Check the installed schema and choose a count appropriate for the sensor before triggering it.
Some argument lists in that article disagree with its code: the proximity list mentions numSamples although its example omits it, and the inclination list uses tilt-prefixed names while its mutation uses threshold, numSamples and guardRoll. Check the actual installed schema instead of treating those lists as a validated current contract.
The linked Python programs include transport, plotting and mutation examples. Check their dependencies against your client environment and choose settings appropriate for your sensor.
mutation {
reedRunSetup(numSamples: 31, macId: "f2:8e:cc:78") {
ok
}
}