TH | EN

SUBSCRIPTIONS

It will be a function that works like WebSockets, which is an On Event waiting to receive data (Push) from the Platform, similar to Subscription in MQTT, which will allow receiving data in Real Time when there is a change in data according to each event that the user is interested in and has called the Subscription Function waiting, consisting of:

DeviceStatusChanged

To wait for information on changes in the Platform connection status (Online/Offline) of the Device with the Device ID details as follows:

deviceStatusChanged ( deviceid ):

Arguments

  • deviceid: String is the Device ID (required)

Query Variables

Authorization: User Token

Response Type : DeviceStatus

When the Platform connection status of a Device changes from Online to Offline or Offline to Online, the response is Object Type DeviceStatus consisting of:

  • deviceid: String is the Device ID.

  • groupid: String is the ID of the Group that the Device is under.

  • projectid: String is the Project ID that the Device is under.

  • status: Int is Device’s connection status to the platform (1 Online, 0 Offilne)

  • enabled: Boolean is the Device activation status (true enabled, false disabled).

An example is shown in the following figure:

_images/gql2_sub_devicestatuschanged.png

DeviceStatusChangedByGroup

To wait for information on changes in the Platform connection status (Online/Offline) of all Devices under Group ID, details are as follows:

deviceStatusChangedByGroup ( groupid ):

Arguments

  • groupid: String is the code of the Group of interest (required).

Query Variables

Authorization: User Token

Response Type : Device

When the Platform connection status of Devices under a Group changes from Online to Offline or Offline to Online, the response will be Object Type Device, which includes:

  • alias: String is the name of the Device.

  • createdtime: Timestamp is the date and time the Device was created.

  • credential: Credential is data for verifying identity. Object Type credential consists of:

    secret: String is the Device's secret code for Authentication.

  • description: String is a Device description.

  • deviceid: String is the Device ID.

  • devicesecret: String is the secret code of the Device.

  • groupid: String is the ID of the Group that the Device is under.

  • groupname: String is the name of the Group that the Device is under.

  • projectid: String is the Project ID that the Device is under.

  • status: Int is Device’s connection status to the platform (0 offline, 1 online)

  • tag: String is a single-valued Device tag.

  • hashtag: [String] is a multi-valued Device tag.

  • tags: Json is a Device tag in Key Value format.

  • enabled: Boolean is the Device activation status (true enabled, false disabled).

  • banned: Boolean is the Device activation status (true enabled, false disabled).

_images/gql2_sub_devicestatuschangedbygroup.png

DeviceStatusChangedByProject

To wait for information on changes in the Platform connection status (Online/Offline) of all Devices under the Project ID, details are as follows:

deviceStatusChangedByGroup ( projectid ):

Arguments

  • projectid: String is the ID of the project of interest (required)

Query Variables

Authorization: User Token

Response Type : Device

When the Platform connection status of the Devices under the Project changes from Online to Offline or Offline to Online, the response will be Object Type Device, consisting of:

  • alias: String is the name of the Device.

  • createdtime: Timestamp is the date and time the Device was created.

  • credential: Credential is data for verifying identity. Object Type credential consists of:

    secret: String is the Device's secret code for Authentication.

  • description: String is a Device description.

  • deviceid: String is the Device ID.

  • devicesecret: String is the secret code of the Device.

  • groupid: String is the ID of the Group that the Device is under.

  • groupname: String is the name of the Group that the Device is under.

  • projectid: String is the Project ID that the Device is under.

  • status: Int is Device’s connection status to the platform (0 offline, 1 online)

  • tag: String is a single-valued Device tag.

  • hashtag: [String] is a multi-valued Device tag.

  • tags: Json is a Device tag in Key Value format.

  • enabled: Boolean is the Device activation status (true enabled, false disabled).

  • banned: Boolean is the Device activation status (true enabled, false disabled).

An example is shown in the following figure:

_images/gql2_sub_devicestatuschangedbyproject.png

FeedUpdated

To wait for Shadow change information of Device with Device ID details as follows:

feedUpdated ( deviceid ):

Arguments

  • feedid: String is the Feed ID which has the same value as deviceid (required).

Query Variables

Authorization: User Token

Response Type : Shadow

When the Device Shadow changes, the response is an Object Type Shadow consisting of:

  • feedid: String is the Feed ID.

  • data: JSON is the data in each field.

  • timestamp: Timestamp is the date and time when the data was last generated.

An example is shown in the following figure:

_images/gql2_feedupdated.png

ShadowUpdated

To wait for Shadow change information of Device with Device ID details as follows:

shadowUpdated ( deviceid ):

Arguments

  • deviceid: String is the Device ID (required)

Query Variables

Authorization: User Token

Response Type : Shadow

When the Device Shadow changes, the response is an Object Type Shadow consisting of:

  • deviceid: String is the Device ID.

  • data: JSON is the defined Shadow, which will be in JSON format.

  • rev: Int is the Revision number.

  • modified: Timestamp is the date and time the data was last modified.

An example is shown in the following figure:

_images/gql2_sub_shadowUpdated.png