SensorGroups

SensorGroups are a virtual collection of sensors that are created based on the tags that are specified. Each sensor may consist a set of tags. The list of sensors that belong to a SensorGroup can be changed by modifying the tags attached to this SensorGroup. All sensors having the current tags will fall under this SensorGroup automatically for any subsequent operations. SensorGroups can be defined in the CentralService at http://www.example.com:81/api/sensorgroup.

Create SensorGroup

This request creates a new SensorGroup with the name and description in the building specified by the user.

Example request:

POST /api/sensor_group HTTP/1.1
Accept: application/json; charset=utf-8

{ "data": {
              "name":"Test Sensor Group",
              "building":"NSH",
              "description":"Description for Sensor Group"
          }
}

Example response (for success):

HTTP/1.1 200 OK
Content-Type: application/json

{
  "success": "True"
}

Example response (for failure):

HTTP/1.1 200 OK
Content-Type: application/json

{
  "success": "False",
  "error": "Building does not exist"
}

Get SensorGroup Details

This request retrieves the details of a SensorGroup

Example request:

GET /api/sensor_group/Test HTTP/1.1
Accept: application/json; charset=utf-8

Example response (for success):

HTTP/1.1 200 OK
Content-Type: application/json

{
  "success" : "true"
  "name":"Test",
  "description": "A SensorGroup for Test"
  "building":"NSH"
}

Example response (for failure):

HTTP/1.1 200 OK
Content-Type: application/json

{
  "success": "False",
  "error": "SensorGroup does not exist"
}

Delete SensorGroup

This request deletes the SensorGroup

Example request:

DELETE /api/sensor_group/Test HTTP/1.1
Accept: application/json; charset=utf-8

Example response (for success):

HTTP/1.1 200 OK
Content-Type: application/json

{
  "success": "True"
}

Example response (for failure):

HTTP/1.1 200 OK
Content-Type: application/json

{
  "success": "False",
  "error": "SensorGroup does not exist"
}

Add tags to SensorGroup

This request adds the tags specified in the request to the SensorGroup

Note: The list of tags sent in this request will overwrite the previous list.

Example request:

POST /api/sensor_group/test/tags HTTP/1.1
Accept: application/json; charset=utf-8


{
  "data":{
      "tags":[
           {
            "name": "Corridor",
            "value": "3600"
           },
           {
            "name": "Room",
            "value": "3606"
           }
          ]
  }
}

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "success": "True"
}

Get list of tags in SensorGroup

This request retrieves two lists of key-value pairs, one list contains the array of eligible tags that can be attached to this SensorGroup and the other list contains the array of tags that are currently attached to this SensorGroup.

Example request:

GET /api/sensor_group/test/tags HTTP/1.1
Accept: application/json; charset=utf-8

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "tags": {
           "Corridor": [
                        "3600",
                        "3700"
                       ],
           "Floor": [
                     "3"
                    ],
           "Room": [
                    "3606"
                   ]
          },

  "tags_owned": [
                  {
                   "name": "Corridor",
                   "value": "3600"
                  },
                  {
                   "name": "Floor",
                   "value": "3"
                  },
                  {
                   "name": "Room",
                   "value": "3606"
                  }
                ]
}