A Thing in the Igloo platform represents a single physical device, each Thing can contain multiple variables that represent the state of the device and the various parameters it has measured.
For example if you want to control a few smart valves through Igloo you will create a Thing for each valve and inside each thing you will create a variable to control the open/closed state, a variable for the pressure in the pipe, …
Creating a Thing
You can create a thing launching the following mutation, where type
should be the name of the product line
mutation{ createThing(type: "Agroo Weather Station") { id token pairCode qrCode } }
The createThing
mutation also accepts some optional parameters:
firmware
: a String field that you can use to track which firmware version is on the devicestoredNotifications
: an Int field that you can use to limit the notifications stored by the Thing, if there are too many notifications the older ones will be removed
Reading data from Things
{ thing(id: "thing-id") { id createdAt updatedAt token type usedStorage usedDiskSpace storedNotifications firmware pairCode qrCode } }
The fields contain the following information:
id
is a unique identifier of your thing, it’s necessary to read and update the thing’s datacreatedAt
andupdatedAt
are the timestamps for the creation time and the last update (including changes to variables contained in the thing)token
is an authentication token with access only to that thing, it should be used in the device’s firmware to avoid the risk of your account-level token being stolentype
is a mandatory field that you should set to the name of the product line to which the device belongs (e.g. Agroo Weather Station)usedStorage
andusedDiskSpace
specify how much billed resources the thing is usingstoredNotifications
specifies the maximum amount of notifications kept in store, excess notification will be deleted starting from the oldestfirmware
is an optional field you can use to track which version of the firmware is running on the devicepairCode
andqrCode
are the text version and the QR code version of the pair code that the end user needs to associate this thing with their account
You can also fetch the list of all the things you have created you can use the query
{ user { developerThings(limit:10, offset:10){ id } developerThingCount } }
The developerThingCount
returns the total number of things you created, while developerThings
returns at most a limit
number of things starting from the one indicated by offset
.
Reading variables from Things
Similarly to the developerThings
query, there is a variables
field in the thing
query that allows you to list all the variables inside a thing:
{ thing(id: "thing-id") { variables(limit: 10, offset:0){ id } variableCount } }
The variables
field returns at most a limit
number of variables starting from the one indicated by offset
, while variableCount
indicates the total number of variables.
If you want to get only a specific kind of variable you can use the fields floatVariables
, floatVariableCount
, stringVariables
, stringVariableCount
, …
Updating a Thing
To change the data associated with a Thing you can use the following mutation:
mutation { updateThing(id:"thing-id", firmware: "v1.0"){ id } }
The fields that can be modified are firmware
, type
and storedNotifications
, the meaning of those fields is explained in the section Reading data from Things.
Deleting a Thing
If a Thing is no longer needed you should delete it so that it doesn’t count towards your account usage limits
mutation { deleteThing(id: "thing-id") }
When the thing is deleted all the data contained in its variables is permanently deleted, be sure to backup anything you might need later on.