5. Sensor Fields

Each sensor has the following default fields:

Field Name Information
value The numerical data for the sensor. Required.
lat The latitude of the sensor. Required.
lng The longitude of the sensor. Required.
message The string message for the sensor. Not Required.

Each pieces of sensor field data has the following sub-fields:

Sub-Field Name Information
name The unique identifier for the field. It is required when creating/updating a field and cannot be changed.
longName The display name for the field.
type Can be “NUMBER” or “STRING”. It is required when creating/updating a field.
required Is a boolean field. If true, data sent to a sensor must include this field or an error will result. Optional.
units Is a string. Optional.
index The numerical identifier of the field. Automatically populated.
value The last value sent to the field. Automatically populated.
lastUpdate The time stamp of the last value sent to the field. Automatically populated.

5.1. Querying Sensor Fields

To query all sensor fields for a specific sensor:

URL http://wotkit.sensetecnic.com/api/sensors/{sensorname}/fields
Privacy Public or Private
Format json
Method GET
Returns Appropriate HTTP status code; OK 200 - if successful

To query a single sensor field for a specific sensor:

URL http://wotkit.sensetecnic.com/api/sensors/{sensorname}/fields/{fieldName}
Privacy Public or Private
Format json
Method GET
Returns Appropriate HTTP status code; OK 200 - if successful

5.2. Updating a Sensor Field

You can update an existing sensor field or add a new sensor field by performing a PUT and including the field name in the URL. The field information is supplied in a JSON format.

If the sensor already has a field with the given “fieldname”, it will be updated with new information. Otherwise, a new field will be created.

  • When inputting field data, the sub-fields “name” and “type” are required-both for adding a new field or updating an existing one.
  • The “name” sub-field of an existing field cannot be updated.
  • For user defined fields, the “longName”, “type”, “required”, and “units” sub-fields may be updated.
  • For the default fields (lat, lng, value, message), only the “longName” and “unit” sub-fields may be updated.

To update/add a sensor field:

URL http://wotkit.sensetecnic.com/api/sensors/{sensorname}/fields/{fieldname}
Privacy Private
Format json
Method PUT
Returns HTTP status code; No Content 204 if successful

For instance, to create a new field called “test-field”:

example

curl --user {id}:{password} --request POST
--header "Content-Type: application/json" --data-binary @field-data.txt
'http://wotkit.sensetecnic.com/api/sensors/test-sensor/fields/test-field'

The file field-data.txt could contain the following. (This is the minimal information needed to create a new field.)

{
        "name"=>"test-field",
        "type"=>"STRING"
}

To then update “test-field” sub-fields, the same curl command would be used, and ‘’field-data.txt’’ could now contain the following.

{
        "name"=>"test-field",
        "type"=>"NUMBER"
        "longName"=>"Test Field",
        "required"=>true,
        "units"=>"mm"
}

5.3. Deleting a Sensor Field

You can delete an existing sensor field by performing a DELETE and including the field name in the URL.

None of the existing default fields (lat, lng, value, message) can be deleted.

To delete a sensor field:

URL http://wotkit.sensetecnic.com/api/sensors/{sensorname}/fields/{fieldname}
Privacy Private
Format n/a
Method DELETE
Returns HTTP status code; No Content 204 if successful

Project Versions

Table Of Contents

Previous topic

4. Sensor Subscriptions

Next topic

6. Sensor Data

This Page