Skip to main content

device

Websocket connection to receive state changes the given Device ID

info

Events are emitted only for subscribed fields. For example if you subscribe to the tags field, you will only receive push events when tags are modified on a device:

 subscription {
device(id: $id) {
id
tags
}
}

Adding position would fire events when either the tags change OR a position is sent from the device:

 subscription {
device(id: $id) {
id
tags
lastPosition {
position {
llaDec { lat lon alt }
}
timestamp
}
}
}
device(
id: ID!
): Device!

Arguments

device.id ● ID! non-null scalar common

Type

Device object devices

Contains information about a Device in the system

Code Samples

const subscription = `
subscription DeviceSubscription($id: ID!) {
device(id: $id) {
id
label
tags {
key
value
}
lastPosition {
position {
llaDec {
lat
lon
alt
}
}
timestamp
}
}
}
`;

const variables = {
"id": "your-device-id"
};

// WebSocket subscription
const ws = new WebSocket('wss://graphql.pointonenav.com/subscriptions');

ws.onopen = () => {
ws.send(JSON.stringify({
type: 'connection_init',
payload: {
Authorization: 'Bearer YOUR_TOKEN'
}
}));

ws.send(JSON.stringify({
id: '1',
type: 'start',
payload: {
query: subscription,
variables: variables
}
}));
};

ws.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log(data);
};