Locations
Good to know: Are you working with MinimalConfig? The system will then add locations and categories automatically. You can skip this steps.
Note: Always check that the hardware and software are suitable before creating locations and categories. For the API methods, see version checks.
You should add each location separately to the REST API connection, as the system may handle alarms differently for each location. This enables each location to report alarms independently.
Description of API elements
| Element | Description |
|---|---|
| custom_id | Unique location ID that you define as the client. |
| enabled | Indicates whether the system is switched off, for example during maintenance (false). |
| id | Unique location database ID that the Octalarm alarm dialler generates automatically. |
| name | Name of the location. The dialler uses this: 1. When generating alarms; 2. In the alarm report (voice or text); 3. In the log and on the screen. |
You can modify all elements retrospectively, except for the id element. Change them using the custom_id and the PUT method.
API methods
In the scenario of the practical example, there are two locations: Tomatoes and 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
}
After you have added all locations, you can query them via the 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
}
After you have created one or more locations, you can create different categories within each location to organise the alarms by location or group.