Product style icon link Locations

Since alarm handling may be different for each location, add each location to the REST API interface. This allows them to report independently.

API elements with their description

ElementDescription
custom_idUnique location ID defined by the client
enabledError when system is switched off, e.g. when maintenance is required
idUnique location database ID, generated by the Octalarm alarm dialler
nameName of the location. Used:
1. when generating alarms;
2. in the alarm report (voice or text);
3. in the log and on the display.

You can modify all elements except the id element retrospectively using the custom_id and the PUT method.

API methods

In the situation diagram there are two locations: Tomatoes en Peppers.

“Post: /Locations"

{
  "custom_id": "loc_01",
  "enabled": true,
  "name": "Tomatoes"
}

cURL code:

curl -X 'POST' \
  'http://192.168.10.72/rest_api/1/Locations' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2MTI1MzQ0ODgsIm5iZiI6MTYxMjUzNDQ4OCwianRpIjoiNjY0NzI2NzAtYTRkMi00N2ZmLWFiMjUtNzAyMGYwOTkwNWJhIiwiZXhwIjoxNjEyNTM3OTg4LCJpZGVudGl0eSI6IlJFU1QtQVBJXzAwMDUiLCJmcmVzaCI6ZmFsc2UsInR5cGUiOiJhY2Nlc3MiLCJ1c2VyX2NsYWltcyI6eyJ1c2VyX2lkIjo1LCJyb2xlX2lkIjo1LCJsYW5ndWFnZSI6Im5sLU5MIn19.6xlCrMjNsKd9Eyq5ieS-MScZe6P1idstMCKPs5dfOd8' \
  -H 'Content-Type: application/json' \
  -d '{
  "custom_id": "loc_01",
  "enabled": true,
  "name": "Tomatoes"
}'

Response:

{
"id": 3,
"name": "Tomatoes",
"custom_id": "loc_01",
"enabled": true
}

When all locations have been added, you can query these locations using the API "GET: /Locations".

"GET: /Locations"

cURL code:

curl -X 'GET' \
  'http://192.168.10.72/rest_api/1/Locations' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2MTI1MzQ0ODgsIm5iZiI6MTYxMjUzNDQ4OCwianRpIjoiNjY0NzI2NzAtYTRkMi00N2ZmLWFiMjUtNzAyMGYwOTkwNWJhIiwiZXhwIjoxNjEyNTM3OTg4LCJpZGVudGl0eSI6IlJFU1QtQVBJXzAwMDUiLCJmcmVzaCI6ZmFsc2UsInR5cGUiOiJhY2Nlc3MiLCJ1c2VyX2NsYWltcyI6eyJ1c2VyX2lkIjo1LCJyb2xlX2lkIjo1LCJsYW5ndWFnZSI6Im5sLU5MIn19.6xlCrMjNsKd9Eyq5ieS-MScZe6P1idstMCKPs5dfOd8'

Response:

{
  "locations": [
    {
      "id": 3,
      "name": "Tomatoes",
      "custom_id": "loc_01",
      "enabled": true
    },
    {
      "id": 4,
      "name": "Peppers",
      "custom_id": "loc_02",
      "enabled": true
    }
  ]
}

"PUT: /Locations/CusomId/loc_01"

{
  "name": "Cucumber"
}

cURL code:

curl -X 'PUT' \
  'http://192.168.10.72/rest_api/1/Locations/CustomId/loc_01' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2MTI1MzQ0ODgsIm5iZiI6MTYxMjUzNDQ4OCwianRpIjoiNjY0NzI2NzAtYTRkMi00N2ZmLWFiMjUtNzAyMGYwOTkwNWJhIiwiZXhwIjoxNjEyNTM3OTg4LCJpZGVudGl0eSI6IlJFU1QtQVBJXzAwMDUiLCJmcmVzaCI6ZmFsc2UsInR5cGUiOiJhY2Nlc3MiLCJ1c2VyX2NsYWltcyI6eyJ1c2VyX2lkIjo1LCJyb2xlX2lkIjo1LCJsYW5ndWFnZSI6Im5sLU5MIn19.6xlCrMjNsKd9Eyq5ieS-MScZe6P1idstMCKPs5dfOd8' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Cucumber"
}'

Response:

{
  "id": 3,
  "name": "Cucumber",
  "custom_id": "loc_01",
  "enabled": true
}