Web API/en: различия между версиями

Материал из wiki.quadrobit.com
Перейти к навигации Перейти к поиску
(Новая страница: «Web API»)
 
(Новая страница: «error parameters:»)
 
(не показана 231 промежуточная версия этого же участника)
Строка 7: Строка 7:
 
URL https://quadrobit.com/
 
URL https://quadrobit.com/
  
= Учётная запись =
+
= Account =
== Авторизация (login) ==
+
== Login ==
  
 
request:
 
request:
Строка 14: Строка 14:
 
Request URL: [site]/api/login
 
Request URL: [site]/api/login
  
параметры запроса:
+
request parameters:
  
 
(string) email,
 
(string) email,
Строка 20: Строка 20:
 
(string) password
 
(string) password
  
Пример запроса:  
+
Request example:
 +
 
 
<pre>
 
<pre>
 
{
 
{
Строка 26: Строка 27:
 
"password":"12345678"
 
"password":"12345678"
 
}
 
}
</pre>
 
  
 
response:
 
response:
параметры ответа: (object)
+
response parameters: (object)
 +
 
 +
Response sample:
  
Пример ответа:
 
 
<pre>
 
<pre>
 
{
 
{
Строка 38: Строка 39:
 
"email":"aaaa@aaa.aa",
 
"email":"aaaa@aaa.aa",
 
"phone": "423546546546",
 
"phone": "423546546546",
"sex":2, // пол 0 - не указан , 1 - женский , 2 - мужской
+
"sex":2, // 0 - not specified , 1 - female , 2 - male
"country":219,  // код страны в базе
+
"country":219,  // country code in database
 
"active_configuration":"1",
 
"active_configuration":"1",
 
"refcode":"JHE-1GD-T8B-9HB",
 
"refcode":"JHE-1GD-T8B-9HB",
"status":10,      // 0 - неактивен , 10 - активен
+
"status":10,      // 0 - inactive, 10 - active
 
"token":"1Cyuvr9DKMbB6aFQ-mLPLeGZXFLyuK8d",
 
"token":"1Cyuvr9DKMbB6aFQ-mLPLeGZXFLyuK8d",
"expired":1502586831 // метка времени до которой активен token
+
"expired":1502586831 // timestamp to which token is active
 
}
 
}
  
Строка 50: Строка 51:
  
  
== Регистрация (registration) ==   
+
== Registration ==   
  
 
request:
 
request:
 
Request URL: [site]/api/registration
 
Request URL: [site]/api/registration
  
параметры запроса:
+
request parameters:
  
 
(string) email,
 
(string) email,
Строка 61: Строка 62:
 
(string) password
 
(string) password
  
Пример запроса:  
+
Request example:
 +
 
 
<pre>
 
<pre>
 
{
 
{
Строка 85: Строка 87:
  
  
== Профиль пользователя (profile) ==
+
== User Profile (profile) ==
  
 
request:
 
request:
Строка 91: Строка 93:
 
Request URL: [site]/api/profile/
 
Request URL: [site]/api/profile/
  
параметры запроса: (string) token
+
request parameters: (string) token
 +
 
 +
Request example:
  
Пример запроса:
 
 
<pre>
 
<pre>
 
{
 
{
Строка 121: Строка 124:
 
</pre>
 
</pre>
  
= Контроллеры =
+
= Controllers =
  
== Список Контроллеров Пользователя (list) ==
+
== List of User Controllers (list) ==
  
 
request:
 
request:
 
Request URL: [site]/api/ctrl/list/
 
Request URL: [site]/api/ctrl/list/
  
параметры запроса: (string) token
+
request parameters: (string) token
 +
 
 +
Request example:
  
Пример запроса:
 
 
 
<pre>
 
<pre>
 
{
 
{
Строка 140: Строка 143:
 
response:
 
response:
  
параметры ответа: (array)  
+
response parameters: (array)  
 +
 
 +
Sample answer:
  
Пример ответа:
 
 
<pre>
 
<pre>
 
{
 
{
Строка 148: Строка 152:
 
"id":"11",
 
"id":"11",
 
"name":"AS_A61301A020E4",
 
"name":"AS_A61301A020E4",
"armed":"0",  //0 - снят с охраны, 1 - под охраной
+
"armed":"0",  //0 - disarmed, 1 - under guard
"device_ids":"a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}", //ids устройств на контроллере
+
"device_ids":"a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}", //ids of devices on the Controller
"action_ids":"a:0:{}", //ids действий на контроллере
+
"action_ids":"a:0:{}", //ids of actions on the Controller
 
"timezone":"3",
 
"timezone":"3",
 
"token":"747D3844ABD35B08F27D18D15D7178B7AF99A754D805633928D4362D19B4AEC2",
 
"token":"747D3844ABD35B08F27D18D15D7178B7AF99A754D805633928D4362D19B4AEC2",
Строка 168: Строка 172:
  
  
== Информация о Контроллере (info) ==
+
== Controller Information (info) ==
  
 
request:
 
request:
 
Request URL: [site]/api/ctrl/info/
 
Request URL: [site]/api/ctrl/info/
  
параметры запроса: (int) controller_id , (string) token
+
request parameters:
 +
#(int) controller_id,
 +
#(string) token
 +
 
 +
Request example:
  
Пример запроса:
 
 
<pre>
 
<pre>
 
{
 
{
Строка 185: Строка 192:
 
response:
 
response:
  
параметры ответа: (object)
+
response parameters: (object)
  
Пример ответа:  
+
response parameters: (object)
  
 
<pre>
 
<pre>
Строка 202: Строка 209:
 
</pre>
 
</pre>
  
== Постановка/снятие Контроллера на охрану / с охраны  (armed) ==
+
== Arming / disarming the Controller (armed) ==
  
 
request:
 
request:
Строка 208: Строка 215:
 
Request URL: [site]/api/ctrl/armed/
 
Request URL: [site]/api/ctrl/armed/
  
параметры запроса: (int) controller_id , (string) token
+
request parameters:
пример:  
+
 
 +
#(int) controller_id,
 +
#(string) token
 +
 
 +
example:  
  
 
<pre>
 
<pre>
Строка 217: Строка 228:
 
}
 
}
 
</pre>
 
</pre>
так как MQTT односторонний - ответа быть не может. Ответ что запрос ушел:
+
 
response:
+
Since MQTT is one-way, there can be no answer. Answer that the request is gone as follows:
параметры ответа:  
+
 
пример:
+
Response:
 +
 
 +
Example:
 +
 
<pre>
 
<pre>
 
{
 
{
Строка 228: Строка 242:
  
  
== Добавление Контроллера (add) ==
+
== Add Controller (add) ==
  
 
request:
 
request:
Строка 234: Строка 248:
 
Request URL: [site]/api/ctrl/add
 
Request URL: [site]/api/ctrl/add
  
параметры запроса: (string) token
+
request parameters: (string) token
 +
 
 +
Example
  
Пример:
 
 
<pre>
 
<pre>
 
{
 
{
"token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae"
+
"token": "_ zcX0_QceAqgP_seIvjG32EC3HMO34ae"
 
}
 
}
</pre>
+
</ pre>
response:
+
 
параметры ответа:  
+
Response:
пример:
+
 
 +
Example:
 +
 
 
<pre>
 
<pre>
 
{
 
{
"PIN":"7gDH"
+
"PIN": "7gDH"
 
}
 
}
</pre>
+
</ pre>
После ввода пин-кода необходимо обновить список Контроллеров (/api/ctrl/list/)
+
 
 +
After entering the PIN code, you need to update the list of Controllers (/ api / ctrl / list /)
 +
 
 +
== Update the list of devices and actions on the controller (update) ==
  
== Обновление списка устройств и действий на Контроллере (update) ==
+
=== Stage 1 - update the list of IDS devices on the controller ===
  
=== Этап 1 - обновляем список IDS устройств на Контроллере ===
+
Request:
request:
 
  
 
Request URL: [site]/api/ctrl/update/
 
Request URL: [site]/api/ctrl/update/
параметры запроса: (int) controller_id , (string) token
+
 
пример:  
+
Request parameters:
 +
#(int) controller_id,
 +
#(string) token
 +
example:
 
<pre>
 
<pre>
 
{
 
{
"controller_id": 6 ,
+
"controller_id": 6,
"token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae"
+
"token": "_ zcX0_QceAqgP_seIvjG32EC3HMO34ae"
 
}
 
}
</pre>
+
</ pre>
response:
+
 
параметры ответа:
+
Response:
пример:  
+
 
 +
Example:
 
<pre>
 
<pre>
 
{
 
{
"result": "Ok" // "Ok" = запрос ушел
+
"result": "Ok" // "Ok" = request was sent
 
}
 
}
</pre>
+
</ pre>
  
=== Этап 2 - обновляем информацию о каждом устройстве ===
+
=== Stage 2 - the update information about each device ===
  
 
request:
 
request:
 
Request URL: [site]/api/ctrl/update-devices/
 
Request URL: [site]/api/ctrl/update-devices/
  
параметры запроса:
+
request parameters:
  
 
(int) controller_id,
 
(int) controller_id,
 
(string) token
 
(string) token
  
Пример запроса:  
+
Request example:  
 
<pre>
 
<pre>
 
{
 
{
Строка 295: Строка 318:
 
response:
 
response:
  
параметры ответа:  
+
response parameters:
 +
 
 +
Sample answer:
  
Пример ответа:
 
 
<pre>
 
<pre>
 
{
 
{
"result": "Ok" // ответ что запрос ушел
+
"result": "Ok" // answer that the request is gone
 
}
 
}
</pre>
+
</ pre>
Процесс происходит автоматически. Для получения результата требуется таймаут, после чего делается стандартный запрос на получение данных (контроллер, устройства)
+
 
 +
The process takes place automatically. To obtain the result, a timeout is required, after which a standard request is made to receive data (controller, devices)
  
  
== Удаление Контроллера (delete) ==
+
== Delete Controller (delete) ==
  
 
Request URL: [site]/api/ctrl/delete
 
Request URL: [site]/api/ctrl/delete
  
Параметры запроса:  
+
Request parameters:  
  
Пример запроса:
+
Request example:
+
 
 
<pre>
 
<pre>
 
{
 
{
"token":"8yE-VIQrYuZ2bTeho_lajxjOJPnIe_Yx",
+
"token": "8yE-VIQrYuZ2bTeho_lajxjOJPnIe_Yx",
"controller_id":"81"
+
"controller_id": "81"
 
}
 
}
 
</pre>
 
</pre>
  
 
response:
 
response:
параметры ответа:
+
 
пример:  
+
example:
 
<pre>
 
<pre>
 
{
 
{
"error":null,
+
"error": null,
"data":{"resuls":"Ok"}
+
"data": {"resuls": "Ok"}
 
}
 
}
 
</pre>
 
</pre>
  
== Обновление статуса контроллера (update-status) ==
+
== Update controller status (update-status) ==
  
 
request:
 
request:
Строка 337: Строка 362:
 
Request URL: [site]/api/ ctrl/update-status/
 
Request URL: [site]/api/ ctrl/update-status/
  
Параметры запроса:
+
Request parameters:
  
 
(string) token,
 
(string) token,
Строка 343: Строка 368:
 
(int) controller_id
 
(int) controller_id
  
Пример запроса:
+
Request example:
 +
 
 
<pre>
 
<pre>
 
{
 
{
Строка 353: Строка 379:
 
response:
 
response:
  
параметры ответа:
+
response parameters:
 +
 
 +
Sample answer:
  
Пример ответа:
 
 
<pre>
 
<pre>
 
{
 
{
Строка 365: Строка 392:
 
</pre>
 
</pre>
  
== Получение актуального статуса Контроллера (get-status) ==
+
== Getting the current status of the Controller (get-status) ==
 
request:
 
request:
  
 
Request URL: [site]/api/ ctrl/get-status/
 
Request URL: [site]/api/ ctrl/get-status/
  
параметры запроса:
+
request parameters
  
 
(string) token,
 
(string) token,
Строка 376: Строка 403:
 
(int) controller_id
 
(int) controller_id
  
Пример запроса:
+
Request example:
 +
 
 
<pre>
 
<pre>
 
{
 
{
Строка 386: Строка 414:
 
response:
 
response:
  
параметры ответа:
+
response parameters:
 +
 
 +
Sample answer:
  
Пример ответа:
 
 
<pre>
 
<pre>
 
{
 
{
Строка 398: Строка 427:
 
</pre>
 
</pre>
  
Поле “status” может принимать следующие значения:
+
The “status” field can have the following values:
• 0 – офлайн
+
• 0 - offline
  
• 1 – онлайн
+
• 1 - online
  
• 2 – онлайн, после включения питания
+
• 2 - online after power on
  
== Передача локального IP Контроллера (get-ip) ==
+
== Transmit Local IP Controller (get-ip) ==
  
 
Request URL: [site]/api/ctrl/get-ip
 
Request URL: [site]/api/ctrl/get-ip
Строка 424: Строка 453:
 
</pre>
 
</pre>
  
== Установка подписки на Контроллере ==
+
== Setting a Subscription on the Controller ==
 +
 
 
in/subscription/set
 
in/subscription/set
  
Строка 431: Строка 461:
 
{
 
{
 
"seq_id": 0,
 
"seq_id": 0,
"id": 1, // ID подписки (см. ниже)
+
"id": 1, // Subscription ID (see below)
"remain_time": 100 // оставшееся время в секундах, 4294967295 - неограниченно
+
"remain_time": 100 // remaining time in seconds, 4294967295 - unlimited
 
}
 
}
 
</pre>
 
</pre>
  
== Просмотр статуса подписки (get-subscribe-status) ==
+
== View Subscription Status (get-subscribe-status) ==
  
 
Request URL: [site]/api/ctrl/get-subscribe-status
 
Request URL: [site]/api/ctrl/get-subscribe-status
Строка 451: Строка 481:
  
  
== Активация/продление/покупка подписки (set-subscribe) ==
+
== Activation / extension / purchase of a subscription (set-subscribe) ==
  
  
Строка 479: Строка 509:
  
  
== Метод получения списка телефонов (get-phones) ==
+
== Getting phone list (get-phones) ==
  
 
Request URL: [site]/api/ctrl/get-phones
 
Request URL: [site]/api/ctrl/get-phones
Строка 506: Строка 536:
  
  
== Редактирование телефона (edit-phone) ==
+
== Edit phone (edit-phone) ==
  
 
Request URL: [site]/api/ctrl/edit-phone
 
Request URL: [site]/api/ctrl/edit-phone
Строка 537: Строка 567:
  
  
== Удаление телефона (delete-phone) ==
+
== Delete phone (delete-phone) ==
  
 
Request URL: [site]/api/ctrl/delete-phone
 
Request URL: [site]/api/ctrl/delete-phone
Строка 555: Строка 585:
 
</pre>
 
</pre>
  
== Добавление телефона (add-phone) ==
+
== Add Phone (add-phone) ==
  
 
Request URL: [site]/api/ctrl/add-phone
 
Request URL: [site]/api/ctrl/add-phone
Строка 586: Строка 616:
 
</pre>
 
</pre>
  
= Устройства =
+
= Devices =
  
== Получение списка устройств пользователя (list) ==
+
== Getting a list of user devices (list) ==
  
 
request:
 
request:
Строка 594: Строка 624:
 
Request URL: [site]/api/device/list
 
Request URL: [site]/api/device/list
  
параметры запроса: (int) controller_id , (string) token
+
request parameters: (int) controller_id, (string) token
  
Пример запроса:  
+
Request example:  
 
<pre>
 
<pre>
 
{
 
{
Строка 605: Строка 635:
  
 
response:
 
response:
параметры ответа:
+
 
+
Sample answer:
Пример ответа:  
 
 
<pre>
 
<pre>
 
{
 
{
 
"0":{
 
"0":{
 
"id":"122",
 
"id":"122",
"external_id":"19", //id на контроллере
+
"external_id":"19", // id at the Controller
 
"controller_id":"6",
 
"controller_id":"6",
 
"name":"Сирена",
 
"name":"Сирена",
"type_id":"2",  //тип устройства
+
"type_id":"2",  //device type
"codes":":{    //коды (кнопки)
+
"codes":":{    //codes (buttons)
 
"0":{
 
"0":{
 
"id":"218",
 
"id":"218",
Строка 638: Строка 667:
 
},
 
},
 
"state":"1",
 
"state":"1",
"on_dashboard":"1", //показывать на главной
+
"on_dashboard":"1", //show at Homepage
 
"active":"1"   
 
"active":"1"   
 
},
 
},
Строка 645: Строка 674:
 
"external_id":"22",
 
"external_id":"22",
 
"controller_id":"6",
 
"controller_id":"6",
"name":"Пульт 4кн бел",
+
"name":"XXXXXX",
 
"type_id":"3",
 
"type_id":"3",
 
"codes": ... ,
 
"codes": ... ,
Строка 656: Строка 685:
  
  
== Информация об устройстве (info) ==
+
== Device Information (info) ==
  
 
request:
 
request:
Строка 662: Строка 691:
 
Request URL: [site]/api/device/info/
 
Request URL: [site]/api/device/info/
  
параметры запроса:
+
request parameters:
  
 
(int) controller_id,
 
(int) controller_id,
Строка 670: Строка 699:
 
(string) token
 
(string) token
  
Пример запроса:  
+
Request example:
 +
 
 
<pre>
 
<pre>
 
{
 
{
Строка 681: Строка 711:
 
response:
 
response:
  
параметры ответа:
+
response parameters:
+
 
Пример ответа:  
+
Sample answer:
 
<pre>
 
<pre>
 
{
 
{
Строка 726: Строка 756:
  
  
== Обновление информации об устройстве (update) ==
+
== Update Device Information (update) ==
  
 
request:
 
request:
Строка 742: Строка 772:
 
(string) token,
 
(string) token,
  
Пример запроса:  
+
Request example:
 +
 
 
<pre>
 
<pre>
 
{
 
{
Строка 753: Строка 784:
 
response:
 
response:
  
параметры ответа:
+
response parameters:
+
 
Пример ответа:  
+
Sample answer:
 +
 
 
<pre>
 
<pre>
 
{
 
{
Строка 762: Строка 794:
 
</pre>
 
</pre>
  
== Удаление устройства (delete) ==
+
== Deleting a device (delete) ==
  
 
request:
 
request:
Строка 768: Строка 800:
 
Request URL: [site]/api/device/delete/
 
Request URL: [site]/api/device/delete/
  
параметры запроса:
+
request parameters:
  
 
(int) device_id,
 
(int) device_id,
Строка 774: Строка 806:
 
(string) token
 
(string) token
  
Пример запроса:  
+
Request example:
 +
 
<pre>
 
<pre>
 
{
 
{
Строка 784: Строка 817:
 
response:
 
response:
  
Параметры ответа:  
+
Parameters of the answer:
 +
 
 +
Sample answer:
  
Пример ответа:
 
 
<pre>
 
<pre>
 
{
 
{
Строка 795: Строка 829:
  
  
== Получение метеоданных (last) ==
+
== Getting weather data (last) ==
  
 
request:
 
request:
 
Request URL: [site]/api/device/meteo-last/
 
Request URL: [site]/api/device/meteo-last/
  
параметры запроса:
+
request parameters:
  
 
(string) token,
 
(string) token,
Строка 806: Строка 840:
 
(int) device_id
 
(int) device_id
  
Пример запроса:  
+
Request example:
 +
 
<pre>
 
<pre>
 
{
 
{
Строка 815: Строка 850:
 
response:
 
response:
  
параметры ответа: (object)
+
response parameters: (object)
  
Пример ответа:  
+
Example response:  
  
 
<pre>
 
<pre>
Строка 836: Строка 871:
 
</pre>
 
</pre>
  
== Получение метеоданных за период (period) ==
+
== Receiving meteorological data for the period ==
 +
 
 
request:
 
request:
  
 
Request URL: [site]/api/device/meteo-period/
 
Request URL: [site]/api/device/meteo-period/
  
параметры запроса:
+
request parameters:
  
 
(string) token,
 
(string) token,
Строка 849: Строка 885:
 
(int) period
 
(int) period
  
Пример запроса:  
+
Request example:
 +
 
 
<pre>
 
<pre>
 
{
 
{
 
"token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae",
 
"token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae",
 
"device_id": 130,
 
"device_id": 130,
"period": 1 // количество дней
+
"period": 1 // number of days
 
}
 
}
 
</pre>
 
</pre>
Строка 860: Строка 897:
 
response:
 
response:
  
параметры ответа: (array to objects)
+
response parameters: (array to objects)
  
Пример ответа:  
+
Example response:
 +
 
<pre>
 
<pre>
 
[
 
[
Строка 887: Строка 925:
 
</pre>
 
</pre>
  
== Получение данных электропитания (last) ==
+
== Receive power data (last) ==
 
   
 
   
 
request:
 
request:
 +
 
Request URL: [site]/api/device/electro-last/
 
Request URL: [site]/api/device/electro-last/
  
параметры запроса:
+
request parameters:
  
 
(string) token,
 
(string) token,
Строка 898: Строка 937:
 
(int) device_id
 
(int) device_id
  
Пример запроса:  
+
Request example:
 +
 
 
<pre>
 
<pre>
 
{
 
{
Строка 908: Строка 948:
 
response:
 
response:
  
параметры ответа: (object)
+
response parameters: (object)
  
Пример ответа:  
+
Example response:  
  
 
<pre>
 
<pre>
Строка 932: Строка 972:
 
</pre>  
 
</pre>  
  
== Получение данных электропитания за период (period) ==
+
== Obtain power data for a period (period) ==
+
 
 
request:
 
request:
  
 
Request URL: [site]/api/device/electro-period/
 
Request URL: [site]/api/device/electro-period/
  
параметры запроса:
+
request parameters:
  
 
(string) token,
 
(string) token,
Строка 946: Строка 986:
 
(int) period
 
(int) period
  
Пример запроса:  
+
Request example:
 +
 
 
<pre>
 
<pre>
 
{
 
{
Строка 956: Строка 997:
 
response:
 
response:
  
параметры ответа: (array to objects)
+
response parameters: (array to objects)
  
Пример ответа:
+
Sample answer:
 
   
 
   
 
<pre>
 
<pre>
Строка 987: Строка 1028:
 
</pre>
 
</pre>
  
== Получение данных о сторонних устройствах (other-last) ==
+
== Getting data about third-party devices (other-last) ==
  
Метод возвращает информацию о последнем обнаруженном стороннем устройстве.
+
The method returns information about the last detected third-party device.
+
 
 
request:
 
request:
  
 
Request URL: [site]/api/device/other-last/
 
Request URL: [site]/api/device/other-last/
  
Параметры запроса:
+
Request parameters:
  
 
(string) token,
 
(string) token,
Строка 1001: Строка 1042:
 
(int) device_id
 
(int) device_id
  
Пример запроса:  
+
Request example:
 +
 
<pre>
 
<pre>
 
{
 
{
Строка 1010: Строка 1052:
 
response:
 
response:
  
параметры ответа: (object)
+
response parameters: (object)
 +
 
 +
Example response:
  
Пример ответа:
 
 
<pre>
 
<pre>
 
{
 
{
Строка 1032: Строка 1075:
  
  
== Получение данных о сторонних устройствах за период (other-period) ==
+
== Get data on third-party devices for the period (other-period) ==
 
request:
 
request:
  
 
Request URL: [site]/api/device/other-period/
 
Request URL: [site]/api/device/other-period/
  
параметры запроса:
+
request parameters:
  
 
(string) token,
 
(string) token,
Строка 1045: Строка 1088:
 
(int) period
 
(int) period
  
Пример запроса:  
+
Request example:
 +
 
 
{
 
{
 
"token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae",
 
"token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae",
 
"device_id": 118,
 
"device_id": 118,
"period": 1 // количество дней
+
"period": 1 // number of days
 
}
 
}
 
response:
 
response:
  
параметры ответа: (array to objects)
+
response parameters: (array to objects)
 +
 
 +
Example response:
  
Пример ответа:
 
 
<pre>
 
<pre>
 
{
 
{
Строка 1079: Строка 1124:
 
</pre>
 
</pre>
  
= Wizard добавления устройств =
+
= Devices adding Wizard  =
  
  
== Датчик открытия двери (create-door-open-sensor) ==
+
== Door open sensor (create-door-open-sensor) ==
  
 
URL:  [site]/api/wizard/create-door-open-sensor
 
URL:  [site]/api/wizard/create-door-open-sensor
  
Params:
+
Parameters:
 
controller_id (required): int
 
controller_id (required): int
 
token (required): string, 64
 
token (required): string, 64
 
device_name (optional): string, 256
 
device_name (optional): string, 256
code_ready (optional): string, 64 //Название кода готовности
+
code_ready (optional): string, 64 //Readiness code name
code_alarm (optional): string, 64 //Название кода оповещания
+
code_alarm (optional): string, 64 //Alert code name
code_low_battery (optional): string, 64 //Название кода садящейся батареи
+
code_low_battery (optional): string, 64 //Name of low battery code
  
 
RESPONSE:  
 
RESPONSE:  
Строка 1104: Строка 1149:
 
</pre>
 
</pre>
  
После отправки параметров ожидается срабатывание добавляемого устройства. При срабатывании происходит процесс добавления, и лишь после этого приходит ответ.
+
After sending the parameters, the added device is expected to be activated. When triggered, the process of adding occurs, and only after that the answer comes.
  
  
== Датчик затопления (create-flood-sensor) ==
+
== Flood sensor (create-flood-sensor) ==
  
 
Request URL: [site]/api/wizard/create-flood-sensor
 
Request URL: [site]/api/wizard/create-flood-sensor
Строка 1118: Строка 1163:
  
 
device_name (optional): string, 256
 
device_name (optional): string, 256
code_alarm (optional): string, 64 //Название кода оповещения
+
code_alarm (optional): string, 64 //Alert code name
  
code_tamper (optional): string, 64 //Название кода вмешательства
+
code_tamper (optional): string, 64 //Intervention code name
  
code_low_battery (optional): string, 64 //Название кода садящейся батареи
+
code_low_battery (optional): string, 64 //Name of low battery code
  
 
RESPONSE:  
 
RESPONSE:  
Строка 1134: Строка 1179:
 
</pre>
 
</pre>
 
---------------------------------------
 
---------------------------------------
После отправки параметров ожидается срабатывание добавляемого устройства. При срабатывании происходит процесс добавления, и лишь после этого приходит ответ.
+
After sending the parameters, the added device is expected to be activated. When triggered, the process of adding occurs, and only after that the answer comes.
  
  
== Пульт,4 кнопки (create-console) ==
+
== Remote, 4 buttons (create-console) ==
  
 
Request URL: [site]/api/wizard/create-console
 
Request URL: [site]/api/wizard/create-console
Строка 1149: Строка 1194:
 
device_name (optional): string, 256
 
device_name (optional): string, 256
  
code_lock (optional): string, 64 //Название кода блокировки
+
code_lock (optional): string, 64 //Lock code name
  
code_unlock (optional): string, 64 //Название кода разблокировки
+
code_unlock (optional): string, 64 //Unlock code name
  
code_s (optional): string, 64 //Название кода s
+
code_s (optional): string, 64 //"s" code name
  
code_alarm (optional): string, 64 //Название кода оповещения
+
code_alarm (optional): string, 64 //Alert code name
  
 
RESPONSE:  
 
RESPONSE:  
Строка 1167: Строка 1212:
 
</pre>
 
</pre>
 
---------------------------------------
 
---------------------------------------
После отправки параметров ожидается срабатывание добавляемого устройства. При срабатывании происходит процесс добавления, и лишь после этого приходит ответ.
+
After sending the parameters, the added device is expected to be activated. When triggered, the process of adding occurs, and only after that the answer comes.
  
  
== Сирена (create-siren) ==
+
== Siren (create-siren) ==
  
 
Request URL: [site]/api/wizard/create-siren
 
Request URL: [site]/api/wizard/create-siren
Строка 1182: Строка 1227:
 
device_name (optional): string, 256
 
device_name (optional): string, 256
  
code_on (optional): string, 64 //Название кода включения
+
code_on (optional): string, 64 //Name of the inclusion code
  
code_off (optional): string, 64 //Название кода выключения
+
code_off (optional): string, 64 //Shutdown code name
  
code_blank (optional): string, 64 //Название кода blank
+
code_blank (optional): string, 64 // blank code name
  
 
RESPONSE:  
 
RESPONSE:  
Строка 1198: Строка 1243:
 
</pre>
 
</pre>
 
---------------------------------------
 
---------------------------------------
Перед отправкой параметров необходимо перевести сирену в режим обучения.
+
Before sending the parameters, it is necessary to transfer the siren to the training mode
  
  
== Метеостанция: получение списка обнаруженных метеостанций за последние 10 минут (get-meteos) ==
+
== Weather Station: Get a list of weather stations found in the last 10 minutes (get-meteos) ==
 +
 
 
Request URL: [site]/api/wizard/get-meteos
 
Request URL: [site]/api/wizard/get-meteos
  
Строка 1218: Строка 1264:
 
</pre>
 
</pre>
  
== Метеостанция: добавление (create-meteo) ==
+
== Adding Weather Station (create-meteo) ==
  
 
Request URL: [site][site]/api/wizard/create-meteo
 
Request URL: [site][site]/api/wizard/create-meteo
Строка 1228: Строка 1274:
 
token (required): string, 64
 
token (required): string, 64
  
meteo_num (required): int //Получается в списке выше
+
meteo_num (required): int //It turns out in the list above
  
 
device_name (optional): string, 256
 
device_name (optional): string, 256
Строка 1244: Строка 1290:
  
  
== Водопроводный кран ==
+
== Water tap ==
  
Порядок добавления крана:
+
The procedure for adding a crane:
1) Сгенерировать коды
+
1) Generate codes
  
2) Зажать на кране кнопку, пока кран не мигнёт трижды
+
2) Press the button on the tap until the tap flashes three times.
  
3) Отправить один код
+
3) Send one code
  
4) Нажать на кране кнопку однократно
+
4) Press the button on the tap once
  
5) Зажать на кране кнопку, пока не мигнёт 4 раза
+
5) Press the button on the tap until it blinks 4 times
  
6) Отправить второй код из сгенерированных
+
6) Send the second code from the generated
  
7) Нажать на кране кнопку однократно
+
7) Press the button on the tap once
  
8) Отправить запрос на создание крана.
+
8) Send a request to create a crane.
  
  
=== Генерация кодов ===
+
=== Code Generation ===
  
 
Request URL: [site]/api/wizard/create-codes
 
Request URL: [site]/api/wizard/create-codes
Строка 1284: Строка 1330:
  
  
=== Выполнение кода ===
+
=== Code Execution ===
  
 
Request URL: [site]/api/wizard/execute-code
 
Request URL: [site]/api/wizard/execute-code
Строка 1294: Строка 1340:
 
token (required): string, 64
 
token (required): string, 64
  
code (required): int // Берется из сгенерированных
+
code (required): int // Takes from generated
  
 
Response:
 
Response:
Строка 1306: Строка 1352:
 
</pre>
 
</pre>
  
=== Добавление крана ===
+
=== Adding a tap ===
  
 
Request URL: [site]/api/wizard/create-crane-by-codes
 
Request URL: [site]/api/wizard/create-crane-by-codes
Строка 1322: Строка 1368:
 
device_name (optional): string, 256
 
device_name (optional): string, 256
  
code_open (optional): string, 64 //Название кода открытия
+
code_open (optional): string, 64 //The name of the opening code
  
code_close (optional): string, 64 //Название кода закрытия
+
code_close (optional): string, 64 //Closing code name
  
 
RESPONSE:  
 
RESPONSE:  
Строка 1334: Строка 1380:
 
</pre>
 
</pre>
  
== Добавление розетки ==
+
Название кода закрытия
 +
 
 +
The procedure for adding the socket is as follows:
  
порядок добаления розетки следующий:
+
1) Generate codes
  
1) Сгенерировать коды
+
2) Press the button on the outlet until it flashes
  
2) Зажать на розетке кнопку, пока она не начнет мигать
+
3) Send one code
  
3) Отправить один код
+
4) Press the button on the outlet until it flashes
  
 
4) Зажать на розетке кнопку, пока она не начнет мигать
 
4) Зажать на розетке кнопку, пока она не начнет мигать
  
5) Отправить второй код из сгенерированых
+
6) Send a request to create an outlet
 
 
6) Отправить запрос на создание розетки
 
  
  
=== Генерация кодов (create-codes) ===
+
=== Generation of codes (create-codes) ===
  
 
Request URL: [site]/api/wizard/create-codes
 
Request URL: [site]/api/wizard/create-codes
Строка 1374: Строка 1420:
  
  
=== Выполнение кода  (execute-code) ===
+
=== Code Execution (execute-code) ===
  
 
Request URL: [site]/api/wizard/execute-code
 
Request URL: [site]/api/wizard/execute-code
Строка 1384: Строка 1430:
 
token (required): string, 64
 
token (required): string, 64
  
code (required): int // Берется из сгенерированных
+
code (required): int // Takes from generated
  
 
Response  
 
Response  
Строка 1395: Строка 1441:
  
  
=== Добавление розетки (create-socket) ===
+
=== Add a socket (create-socket) ===
  
 
Request URL: [site]/api/wizard/create-socket
 
Request URL: [site]/api/wizard/create-socket
Строка 1411: Строка 1457:
 
device_name (optional): string, 256
 
device_name (optional): string, 256
  
code_off (optional): string, 64 //Название кода открытия
+
code_off (optional): string, 64 //Shutdown Code Name
  
code_on (optional): string, 64 //Название кода закрытия
+
code_on (optional): string, 64 //Name of the inclusion code
  
 
RESPONSE:  
 
RESPONSE:  
Строка 1423: Строка 1469:
 
</pre>
 
</pre>
  
= Сценарии =
+
= Scripts =
  
== Список сценариев (list) ==
+
== List of scripts (list) ==
  
 
request:
 
request:
 
Request URL: [site]/api/scheduler/list/
 
Request URL: [site]/api/scheduler/list/
  
параметры запроса: (string) token
+
request parameters: (string) token
  
Пример запроса:
+
Request example:
 
   
 
   
 
<pre>
 
<pre>
Строка 1442: Строка 1488:
 
response:
 
response:
  
параметры ответа:  
+
response parameters:
 +
 
 +
Example response:
  
Пример ответа:
 
 
<pre>
 
<pre>
 
{
 
{
Строка 1499: Строка 1546:
  
  
== Обновление сценариев (update) ==
+
== Update Scripts (update) ==
  
Запрос осуществляется в 2 этапа: на первом этапе происходит при запросе на обновление Контроллера (см. "Обновление Контроллера");
+
The request is carried out in 2 stages: in the first stage it occurs when a request is made to update the Controller (see "Updating the Controller");
на втором этапе обновляется информация о каждом действии.
+
at the second stage, information about each action is updated.
  
 
request:
 
request:
 
Request URL: [site]/api/scheduler/update/
 
Request URL: [site]/api/scheduler/update/
  
параметры запроса:
+
request parameters:
  
 
(int) controller_id,
 
(int) controller_id,
Строка 1513: Строка 1560:
 
(string) token
 
(string) token
  
Пример запроса:  
+
Request example:
 +
 
 
<pre>
 
<pre>
 
{
 
{
Строка 1523: Строка 1571:
 
response:
 
response:
  
параметры ответа:  
+
response parameters:  
  
Пример ответа:  
+
Example response:
 +
 
<pre>
 
<pre>
 
{
 
{
Строка 1531: Строка 1580:
 
}
 
}
 
</pre>
 
</pre>
Процесс обновления происходит автоматически. Для получения результата требуется таймаут, после чего делается стандартный запрос на получение данных (Контроллер, действия)
 
  
 +
The update process happens automatically. To get the result, a timeout is required, after which a standard data request is made (controller, actions)
  
== Информация о сценарии (info) ==
+
 
 +
== Script Information (info) ==
  
 
request:
 
request:
 
Request URL: [site]/api/scheduler/info/
 
Request URL: [site]/api/scheduler/info/
  
параметры запроса:
+
request parameters:
  
 
(int) scheduler_id,
 
(int) scheduler_id,
Строка 1545: Строка 1595:
 
(string) token
 
(string) token
  
Пример ответа:  
+
Example response:
 +
 
<pre>
 
<pre>
 
{
 
{
Строка 1554: Строка 1605:
 
response:
 
response:
  
параметры ответа:  
+
response parameters:  
  
Пример ответа:  
+
Example response:
 +
 
<pre>
 
<pre>
 
{
 
{
Строка 1604: Строка 1656:
  
  
= Логи пользователя (logs) =
+
= User logs (logs) =
 +
 
 
request:
 
request:
  
 
Request URL: [site]/api/profile/logs/
 
Request URL: [site]/api/profile/logs/
  
параметры запроса: (string) token
+
request parameters: (string) token
 +
 
 +
Request example:
  
Пример запроса:
 
 
<pre>
 
<pre>
 
{
 
{
Строка 1617: Строка 1671:
 
}
 
}
 
</pre>
 
</pre>
 +
 
response:
 
response:
параметры ответа: (object)
+
 
пример:  
+
response parameters: (object)
 +
example:
 
{
 
{
 
 
Строка 1629: Строка 1685:
  
  
= Коды =
+
= Codes =
  
== Получение информации о коде (info) ==
+
== Getting code info (info) ==
  
 
request:
 
request:
Строка 1637: Строка 1693:
 
Request URL: [site]/api/property/info/
 
Request URL: [site]/api/property/info/
  
параметры запроса:
+
request parameters:
 
(int) controller_id,
 
(int) controller_id,
  
Строка 1646: Строка 1702:
 
(string) token
 
(string) token
  
Пример запроса:  
+
Request example:
 +
 
<pre>
 
<pre>
 
{
 
{
Строка 1658: Строка 1715:
  
 
response:
 
response:
параметры ответа:  
+
response parameters:  
  
Пример ответа:  
+
Example response:
 
<pre>
 
<pre>
 
{
 
{
Строка 1683: Строка 1740:
  
  
== Изменение имени кода (update-code-name) ==
+
== Change code name (update-code-name) ==
  
 
Request URL: [site]/api/device/update-code-name
 
Request URL: [site]/api/device/update-code-name
Строка 1705: Строка 1762:
 
</pre>
 
</pre>
  
== Получение кодов по типу сигнала (get-codes-by-subtype) ==
+
== Receiving codes by signal type (get-codes-by-subtype) ==
  
 
Request URL: [site]/api/device/get-codes-by-subtype
 
Request URL: [site]/api/device/get-codes-by-subtype
Строка 1715: Строка 1772:
 
device_subtype_id (optional): int, default 0.
 
device_subtype_id (optional): int, default 0.
  
== Получение списка кодов (get-codes) ==
+
== Getting a list of codes (get-codes) ==
  
 
Request URL: [site]/api/device/get-codes
 
Request URL: [site]/api/device/get-codes
Строка 1834: Строка 1891:
 
</pre>
 
</pre>
  
== Добавление кода к устройству (set-code-to-device) ==
+
== Adding code to a device (set-code-to-device) ==
  
 
Request URL: [site]/api/device/set-code-to-device
 
Request URL: [site]/api/device/set-code-to-device
Строка 1865: Строка 1922:
 
</pre>
 
</pre>
  
== Удаление кода (remove-code) ==
+
== Remove code (remove-code) ==
  
 
Request URL: [site]/api/device/remove-code
 
Request URL: [site]/api/device/remove-code
Строка 1884: Строка 1941:
 
</pre>
 
</pre>
  
= События =
+
= Events =
  
== Нажатие кнопки на устройстве (event) ==
+
== Press the button on the device (event) ==
  
 
request:
 
request:
  
 
Request URL: [site]/api/device/event/
 
Request URL: [site]/api/device/event/
параметры запроса:
+
 
 +
request parameters:
  
 
(string) controller_name,
 
(string) controller_name,
Строка 1903: Строка 1961:
 
(int) device_type
 
(int) device_type
  
Пример запроса:  
+
Request example:  
  
 
<pre>
 
<pre>
Строка 1915: Строка 1973:
 
</pre>
 
</pre>
  
так как MQTT односторонний - ответа быть не может. Может быть возвращён ответ, что запрос отправлен:
+
since MQTT is one-way, there can be no answer. An answer may be returned that the request has been sent:
 +
 
 
response:
 
response:
  
параметры ответа:  
+
response parameters:  
  
Пример ответа:  
+
Sample answer:  
  
 
<pre>
 
<pre>
Строка 1928: Строка 1987:
 
</pre>
 
</pre>
  
= Места =
+
= Places =
  
== Получение списка мест (places-list) ==
+
== Getting a list of places (places-list) ==
  
 
Request URL: [site]/api/places/places-list  
 
Request URL: [site]/api/places/places-list  
Строка 1949: Строка 2008:
  
  
== Создание места (create) ==
+
== Creating a place (create) ==
  
  
Строка 1960: Строка 2019:
 
root (optional): int, default 1
 
root (optional): int, default 1
  
lft (optional): int, from 1 to 5 //В сумме с rgt должно быть 5
+
lft (optional): int, from 1 to 5 //Summ of rgt should be 5
  
rgt (optional): int, from 1 to 5 //В сумме с lft должно быть 5
+
rgt (optional): int, from 1 to 5 //Summ of lft should be 5
  
 
lvl (optional): int, default 0
 
lvl (optional): int, default 0
Строка 1968: Строка 2027:
 
name (optional): string, 64, default 'Simple name'
 
name (optional): string, 64, default 'Simple name'
  
icon (optional): string, default '' //Допускаемые параметры -- ключи объекта выше
+
icon (optional): string, default '' //Valid parameters are keys that are presented above
  
color (optional): string, default: '#ccc' //Любой цвет в формате HEX, решетка в начале обязательна
+
color (optional): string, default: '#ccc' //Any color in HEX format, the grid at the beginning is required
  
 
active (optional): int, default 1
 
active (optional): int, default 1
Строка 2008: Строка 2067:
  
  
== Редактирование места (edit) ==
+
== Editing a place (edit) ==
  
 
Request URL: [site]/api/places/edit
 
Request URL: [site]/api/places/edit
Строка 2020: Строка 2079:
 
root (optional): int, default 1
 
root (optional): int, default 1
  
lft (optional): int, from 1 to 5 //В сумме с rgt должно быть 5
+
lft (optional): int, from 1 to 5 //Summ of rgt should be 5
  
rgt (optional): int, from 1 to 5 //В сумме с lft должно быть 5
+
rgt (optional): int, from 1 to 5 //Summ of lft should be 5
  
 
lvl (optional): int, default 0
 
lvl (optional): int, default 0
Строка 2028: Строка 2087:
 
name (optional): string, 64, default 'Simple name'
 
name (optional): string, 64, default 'Simple name'
  
icon (optional): string, default '' //Допускаемые параметры -- ключи объекта выше
+
icon (optional): string, default '' //Allowed parameters as object keys are presented above
  
color (optional): string, default: '#ccc' //Любой цвет в формате HEX, решетка в начале обязательна
+
color (optional): string, default: '#ccc' //Any color in HEX format, the grid at the beginning is required
  
 
active (optional): int, default 1
 
active (optional): int, default 1
Строка 2068: Строка 2127:
 
</pre>
 
</pre>
  
== Удаление места (delete) ==
+
== Deleting a place (delete) ==
  
 
Request URL: [site]/api/places/delete
 
Request URL: [site]/api/places/delete
Строка 2090: Строка 2149:
  
  
== Активация подписки Ebus ==
+
== Ebus subscription activation ==
  
  
Получение состояния подписки на Контроллере - “in/subscription/get”:
+
Getting the subscription status on the Controller - “in/subscription/get”:
  
 
<pre>
 
<pre>
 
{
 
{
"id": 1, // ID подписки (см. ниже)
+
"id": 1, // Subscription ID (see below)
 
"seq_id": 0
 
"seq_id": 0
 
}
 
}
 
</pre>
 
</pre>
  
Ответ:
+
Response:
  
 
<pre>
 
<pre>
 
{
 
{
 
"seq_id": 0,
 
"seq_id": 0,
"remain_time": 100, // оставшееся время в секундах, 4294967295 – неограниченно
+
"remain_time": 100, // remaining time in seconds; 4294967295 is unlimited
 
"success": 0/1
 
"success": 0/1
 
}
 
}
 
</pre>
 
</pre>
  
Установка подписки на Контроллере - “in/subscription/set”:
+
Subscription setting on the Controller - “in/subscription/set”:
  
 
<pre>
 
<pre>
 
{
 
{
 
"seq_id": 0,
 
"seq_id": 0,
"id": 1, // ID подписки (см. ниже)
+
"id": 1, // Subscription ID (see below)
"remain_time": 100 // оставшееся время в секундах, 4294967295 - неограниченно
+
"remain_time": 100 // Remaining time in seconds; 4294967295 is unlimited
 
}
 
}
 
</pre>
 
</pre>
  
Ответ:
+
Response:
 
<pre>
 
<pre>
 
{
 
{
Строка 2130: Строка 2189:
 
</pre>
 
</pre>
  
Идентификаторы подписок:
+
Subscription IDs:
 
SUBSCRIPTION_EBUS = 1
 
SUBSCRIPTION_EBUS = 1
  
Статус Контроллера
+
Controller Status
  
Контроллер отправляет информацию о своем онлайн/оффлайн статусе в топик “out/status”.
+
The Controller sends information about its online/offline status to the “out/status” topic.
  
Формат сообщения:
+
Request format:
 
<pre>
 
<pre>
 
{
 
{
"status": 1 // см. ниже
+
"status": 1 // see below
 
}
 
}
 
</pre>
 
</pre>
  
Поле “status” может принимать следующие значения:
+
The “status” field can have the following values:
  
• "0" – оффлайн
+
• "0" - offline
  
• "1" – онлайн
+
• "1" - online
  
• "2" – онлайн, после включения питания
+
• "2" - online after power on
  
При получении сообщения со статусом "2", портал должен отправить Контроллеру информацию о пользовательских подписках, как это описано в разделе «Подписки».
+
When receiving a message with the status "2", the portal should send information about user subscriptions to the Controller, as described in the "Subscriptions" section.
  
  
= Ошибки =
+
= Errors =
  
параметры ошибки:
+
error parameters:  
 
пример:  
 
  
 
<pre>
 
<pre>

Текущая версия на 15:04, 29 марта 2019

Другие языки:
  • API v01 *

API ( json )

URL https://quadrobit.com/

Содержание

Account

Login

request:

Request URL: [site]/api/login

request parameters:

(string) email,

(string) password

Request example:

{
	"email":"aaaa@aaaa.aa",
	"password":"12345678"
}

response:
response parameters: (object)

Response sample:

<pre>
{
	"user_id":1,
	"username":"Ivan Pupkin",
	"email":"aaaa@aaa.aa",
	"phone": "423546546546",
	"sex":2, 		//  0 - not specified , 1 - female  , 2 - male
	"country":219,  		// country code in database
	"active_configuration":"1",
	"refcode":"JHE-1GD-T8B-9HB",
	"status":10,       		// 0 - inactive, 10 - active
	"token":"1Cyuvr9DKMbB6aFQ-mLPLeGZXFLyuK8d",
	"expired":1502586831 // timestamp to which token is active
}


Registration

request: Request URL: [site]/api/registration

request parameters:

(string) email,

(string) password

Request example:

{
	"email":"aaaa@aaaa.aa",
	"password":"12345678"
}

response: параметры ответа: (object) пример:

{
    	"user_id": 43,
    	"username": "user_4383",
    	"email": "aaaa@aaa.aa",
    	"sex": null,
   	 "country": null,
   	 "active_configuration": null,
    	"refcode": "746-81O-0RJ-RJS",
    	"status": 10
}


User Profile (profile)

request:

Request URL: [site]/api/profile/

request parameters: (string) token

Request example:

{
	"token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae"
}

response: параметры ответа: (object) пример:

{
	"user_id":1,
	"username":"Ivan Pupkin",
	"email":"aaaa@aaa.aa",
	"phone": "423546546546",
	"sex":2, 		// пол 0 - не указан , 1 - женский  , 2 - мужской
	"send_email": 1,
              "send_sms": 0,
               "role": 1,
               "lang": 2,
	"country":219,  		// код страны в базе
	"active_configuration":"1",
	"refcode":"JHE-1GD-T8B-9HB",
	"status":10,       		// 0 - неактивен , 10 - активен
	"token":"1Cyuvr9DKMbB6aFQ-mLPLeGZXFLyuK8d",
}

Controllers

List of User Controllers (list)

request: Request URL: [site]/api/ctrl/list/

request parameters: (string) token

Request example:

{
	"token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae"
}

response:

response parameters: (array)

Sample answer:

{
"0":{
	"id":"11",
	"name":"AS_A61301A020E4",
	"armed":"0",   //0 - disarmed, 1 - under guard
	"device_ids":"a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}", //ids of devices on the Controller
	"action_ids":"a:0:{}", //ids of actions on the Controller
	"timezone":"3",
	"token":"747D3844ABD35B08F27D18D15D7178B7AF99A754D805633928D4362D19B4AEC2",
	"online":"1"
},
"1":{
	"id":"12",
	"name":"AS_A61301A020E5",
	"armed":"1",
	"device_ids":"a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}",
	"action_ids":"a:0:{}",
	"timezone":"2",
	"token":"734D3844ABD35B08F27D18D15D7178B7AF99A754D805633928D4362D19B4AEC2",
	"online":"0"
}] 


Controller Information (info)

request: Request URL: [site]/api/ctrl/info/

request parameters:

  1. (int) controller_id,
  2. (string) token

Request example:

{
	"controller_id": 1 ,
	"token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae"
}

response:

response parameters: (object)

response parameters: (object)

{
	"id":"6",
	"name":"AS_7F26335CCF4B",
	"armed":"1",
	"device_ids":"a:26:{i:0;i:25;i:1;i:26;i:2;i:28;i:3;i:19;i:4;i:40;i:5;i:41;i:6;i:42;i:7;i:43;i:8;i:36;i:9;i:34;i:10;i:29;i:11;i:45;i:12;i:38;i:13;i:33;i:14;i:30;i:15;i:31;i:16;i:49;i:17;i:24;i:18;i:46;i:19;i:47;i:20;i:44;i:21;i:27;i:22;i:22;i:23;i:9;i:24;i:23;i:25;i:7;}",
	"action_ids":"a:4:{i:0;i:45;i:1;i:46;i:2;i:49;i:3;i:42;}",
	"timezone":"3",
	"token":"660D91C2B0926A8C981AE7DA4AAA4421A3D86D136262A6F8E98ACF534A7A715B",
	"online":"1"
}

Arming / disarming the Controller (armed)

request:

Request URL: [site]/api/ctrl/armed/

request parameters:

  1. (int) controller_id,
  2. (string) token

example:

{
	"controller_id": 6 ,
	"token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae"
}

Since MQTT is one-way, there can be no answer. Answer that the request is gone as follows:

Response:

Example:

{
	"result": "Ok"
}


Add Controller (add)

request:

Request URL: [site]/api/ctrl/add

request parameters: (string) token

Example

{
	"token": "_ zcX0_QceAqgP_seIvjG32EC3HMO34ae"
}
</ pre>

Response:

Example:

<pre>
{
	"PIN": "7gDH"
}
</ pre>

After entering the PIN code, you need to update the list of Controllers (/ api / ctrl / list /)

== Update the list of devices and actions on the controller (update) ==

=== Stage 1 - update the list of IDS devices on the controller ===

Request:

Request URL: [site]/api/ctrl/update/

Request parameters:
#(int) controller_id,
#(string) token
example:
<pre>
{
	"controller_id": 6,
	"token": "_ zcX0_QceAqgP_seIvjG32EC3HMO34ae"
}
</ pre>

Response:

Example:
<pre>
{
	"result": "Ok" // "Ok" = request was sent
}
</ pre>

=== Stage 2 - the update information about each device ===

request:
Request URL: [site]/api/ctrl/update-devices/

request parameters:

(int) controller_id,
(string) token

Request example: 
<pre>
{
	"controller_id": 6 ,
	"token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae",
}

response:

response parameters:

Sample answer:

{
	"result": "Ok" // answer that the request is gone
}
</ pre>

The process takes place automatically. To obtain the result, a timeout is required, after which a standard request is made to receive data (controller, devices)


== Delete Controller (delete) ==

Request URL: [site]/api/ctrl/delete

Request parameters: 

Request example:
 
<pre>
{
	"token": "8yE-VIQrYuZ2bTeho_lajxjOJPnIe_Yx",
	"controller_id": "81"
}

response:

example:

{
	"error": null,
	"data": {"resuls": "Ok"}
}

Update controller status (update-status)

request:

Request URL: [site]/api/ ctrl/update-status/

Request parameters:

(string) token,

(int) controller_id

Request example:

{
	"token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae",
	"controller_id": 122
}

response:

response parameters:

Sample answer:

{
	"error":null,
	"data":{
		"resuls":"Ok"
		}
}

Getting the current status of the Controller (get-status)

request:

Request URL: [site]/api/ ctrl/get-status/

request parameters

(string) token,

(int) controller_id

Request example:

{
	"token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae",
	"controller_id": 122
}

response:

response parameters:

Sample answer:

{
	"error":null,
	"data":{
		"status":1
		}
}

The “status” field can have the following values: • 0 - offline

• 1 - online

• 2 - online after power on

Transmit Local IP Controller (get-ip)

Request URL: [site]/api/ctrl/get-ip

Request Params:

token (required): string(64);

controller_id (required): int;

SUCCESS RESPONSE:

{
	data:'192.168.0.15',
	error: null
}

Setting a Subscription on the Controller

in/subscription/set

Request URL: [site]/in/subscription/set”

{
	"seq_id": 0,
	"id": 1, // Subscription ID (see below)
	"remain_time": 100 // remaining time in seconds, 4294967295 - unlimited
}

View Subscription Status (get-subscribe-status)

Request URL: [site]/api/ctrl/get-subscribe-status

params:

token (required): string(64)

controller_id (required): int

response:

{data:{id: 1, controller_id: 40, user_id: 424, remain_time: 100, request_time: 1355314332, response_time: 1355315332, success: 0}, error: }


Activation / extension / purchase of a subscription (set-subscribe)

Request URL: [site]/api/ctrl/set-subscribe

params:

token (required): string(64)

controller_id (required): int

response:

{
	data:{
		id: 1,
		controller_id: 40,
		user_id: 424,
		remain_time: 100,
		request_time: 1355314332,
		response_time: 1355315332,
		success: 0
	},
	error: ''
}


Getting phone list (get-phones)

Request URL: [site]/api/ctrl/get-phones

Params:

token (required): string, 64

controller_id (required): int

type (optional): string, range ['recipient', 'authorized', 'all'], default 'all'

Response:

{
	'error': null,
	data: [
		{'id': 5, 'phone': '+380123456789'},
		{'id': 6, 'phone': '+380123334455'},
		{'id': 7, 'phone': '+380112223344'}
	]
}


Edit phone (edit-phone)

Request URL: [site]/api/ctrl/edit-phone

Params:

token (required): string, 64

phone_id (required): int

is_recipient (optional): int

is_authorized (optional): int

phone (optional): string

Response:

{
	"error":null,
	"data":{
		"id":2,
		"controller_id":81,
		"phone":"+380503334455",
		"is_recipient":"1",
		"is_authorized":0
	}
}


Delete phone (delete-phone)

Request URL: [site]/api/ctrl/delete-phone

Params:

token (required): string, 64

phone_id (required): int

Response:

{
	"error":null,
	"data":{"response":"OK"}
}

Add Phone (add-phone)

Request URL: [site]/api/ctrl/add-phone

Params:

token (required): string, 64

controller_id (required): int

phone (required): string

is_recipient (optional): int

is_authorized (optional): int

Response:

{
	"error":null,
	"data":{
		"id":2,
		"controller_id":81,
		"phone":"+380503334455",
		"is_recipient":"1",
		"is_authorized":0
	}
}

Devices

Getting a list of user devices (list)

request:

Request URL: [site]/api/device/list

request parameters: (int) controller_id, (string) token

Request example:

{
	"controller_id": 1 ,
	"token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae"
}

response:   Sample answer:

{
"0":{
	"id":"122",
	"external_id":"19", // id at the Controller
	"controller_id":"6",
	"name":"Сирена",
	"type_id":"2",  //device type
	"codes":":{     //codes (buttons)
		"0":{
		"id":"218",
		"external_cod_id":"32",
		"device_id":"122",
		"name":"ON",
		"code":"3675192",
		"protocol":"1",
		"pulse_len":null,
		"group_1":"1",
		"group_2":"0",
		"group_3":"0",
		"group_4":"0",
		"group_5":"0",
		"group_6":"0",
		"group_7":"0",
		"group_8":"0",
		"active":"1"
		}, 
		"1":{ ... }
	},
	"state":"1",
	"on_dashboard":"1", //show at Homepage
	"active":"1"  
},
"1":{
	"id":"120",
	"external_id":"22",
	"controller_id":"6",
	"name":"XXXXXX",
	"type_id":"3",
	"codes": ... ,
	"state":"1",
	"on_dashboard":"0",
	"active":"1"
}
}  


Device Information (info)

request:

Request URL: [site]/api/device/info/

request parameters:

(int) controller_id,

(int) device_id,

(string) token

Request example:

{
	"controller_id": 1 ,
	"device_id": 122,
	"token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae"
}

response:

response parameters:   Sample answer:

{
	"id":"122",
	"external_id":"19",
	"controller_id":"6",
	"name":"Сирена",
	"type_id":"2",
	"codes":{
		"0":{
		"id":"218",
		"external_cod_id":"32",
		"device_id":"122",
		"name":"ON",
		"code":"3675192",
		"protocol":"1",
		"pulse_len":null,
		"group_1":"1",
		"group_2":"0",
		"group_3":"0",
		"group_4":"0",
		"group_5":"0",
		"group_6":"0",
		"group_7":"0",
		"group_8":"0",
		"active":"1"
		},
		"1":{
		"id":"219",
		"external_cod_id":"33",
		"device_id":"122",
		"name":"OFF",
		"code":"3675186
		...
		}
	},
	"state":"1",
	"on_dashboard":"1",
	"active":"1"
}


Update Device Information (update)

request:

Request URL: [site]/api/device/update/

параметры запроса:

(int) device_id,

(string) name,

(int) active,

(string) token,

Request example:

{
	"device_id": 107,   // local device id
	"name": "New name", // new name
	"active": 1,
	"token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae"
}

response:

response parameters:   Sample answer:

{
	"resuls" : "Ok"
}

Deleting a device (delete)

request:

Request URL: [site]/api/device/delete/

request parameters:

(int) device_id,

(string) token

Request example:

{
	"device_id": 107,   // local device id
	"token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae"
}

response:

Parameters of the answer:

Sample answer:

{
	"resuls" : "Ok"

}


Getting weather data (last)

request: Request URL: [site]/api/device/meteo-last/

request parameters:

(string) token,

(int) device_id

Request example:

{
	"token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae",
	"device_id": 130
}

response:

response parameters: (object)

Example response:

{
	"id":"4046",
	"controller_name":"AS_7FD6785CCF5D",
	"internal_id":"55",
	"device_id":"130",
	"name":"7",
	"temp":"240",
	"hum":"245",
	"illum":"0",
	"pres":"1239",
	"volt":"32",
	"date_time":"2016-03-02 21:09:40",
	"new":"0"  
}

Receiving meteorological data for the period

request:

Request URL: [site]/api/device/meteo-period/

request parameters:

(string) token,

(int) device_id,

(int) period

Request example:

{
	"token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae",
	"device_id": 130,
	"period": 1 // number of days 
}

response:

response parameters: (array to objects)

Example response:

[
	{
	"id":"4065",
	"controller_name":"AS_7FD6785CCF5D",
	"internal_id":"55",
	"device_id":"130",
	"name":"7",
	"temp":"240",
	"hum":"523",
	"illum":"0",
	"pres":"1239",
	"volt":"32",
	"date_time":"2017-07-30 21:11:07",
	"new":"0"
	},
	{
	"id":"4067",
	"controller_name":"AS_7FD6785CCF5D
	...
	},
]

Receive power data (last)

request:

Request URL: [site]/api/device/electro-last/

request parameters:

(string) token,

(int) device_id

Request example:

{
	"token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae",
	"device_id": 130
}

response:

response parameters: (object)

Example response:

{
	"id":"318",
	"controller_id":"11",
	"external_id":"2",
	"device_id":"125",
	"name":"23",
	"token":"747D3844ABD35B08F27D18D15D7178B7AF99A754D805633928D4362D19B4AEC2",
	"last_seen":"2017-07-21 04:20:27",
	"available":"1",
	"voltage":"24",
	"have_voltage":"1",
	"current":"2147483647",
	"have_current":"1",
	"supp_voltage":"33",
	"date_create":"2017-07-21 01:20:33",
	"new":"0"
}

Obtain power data for a period (period)

  request:

Request URL: [site]/api/device/electro-period/

request parameters:

(string) token,

(int) device_id,

(int) period

Request example:

{
	"token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae",
	"device_id": 130,
	"period": 1 // количество дней 
}

response:

response parameters: (array to objects)

Sample answer:

[
	{
	"id":"318",
	"controller_id":"11",
	"external_id":"2",
	"device_id":"125",
	"name":"23",
	"token":"747D3844ABD35B08F27D18D15D7178B7AF99A754D805633928D4362D19B4AEC2",
	"last_seen":"2017-07-21 04:20:27",
	"available":"1",
	"voltage":"24",
	"have_voltage":"1",
	"current":"2147483647",
	"have_current":"1",
	"supp_voltage":"33",
	"date_create":"2017-07-21 01:20:33",
	"new":"0"
	},
	{
	"id":"318",
	"controller_id":"11",
	...
	},
]

Getting data about third-party devices (other-last)

The method returns information about the last detected third-party device.   request:

Request URL: [site]/api/device/other-last/

Request parameters:

(string) token,

(int) device_id

Request example:

{
	"token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae",
	"device_id": 118
}

response:

response parameters: (object)

Example response:

{
	"id":"1301",
	"controller_id":"6",
	"device_id":"118",
	"name":"Розетка",
	"code":"81",
	"pulse_len":null,
	"bit_len":null,
	"protocol":null,
	"groups":null,
	"type":null,
	"date_time":"2017-08-21 04:55:18",
	"active":null,
	"new":"1"
}


Get data on third-party devices for the period (other-period)

request:

Request URL: [site]/api/device/other-period/

request parameters:

(string) token,

(int) device_id,

(int) period

Request example:

{ "token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae", "device_id": 118, "period": 1 // number of days } response:

response parameters: (array to objects)

Example response:

{
	"id":"1301",
	"controller_id":"6",
	"device_id":"118",
	"name":"Розетка",
	"code":"81",
	"pulse_len":null,
	"bit_len":null,
	"protocol":null,
	"groups":null,
	"type":null,
	"date_time":"2017-08-21 04:55:18",
	"active":null,
	"new":"1"
	},
	{
	"id":"4067",
	"controller_id":"6",
	...
}

Devices adding Wizard

Door open sensor (create-door-open-sensor)

URL: [site]/api/wizard/create-door-open-sensor

Parameters: controller_id (required): int token (required): string, 64 device_name (optional): string, 256 code_ready (optional): string, 64 //Readiness code name code_alarm (optional): string, 64 //Alert code name code_low_battery (optional): string, 64 //Name of low battery code

RESPONSE:

{
	data:{
		'response': 'OK'
		},
	error: null
}

After sending the parameters, the added device is expected to be activated. When triggered, the process of adding occurs, and only after that the answer comes.


Flood sensor (create-flood-sensor)

Request URL: [site]/api/wizard/create-flood-sensor

Params:

controller_id (required): int

token (required): string, 64

device_name (optional): string, 256 code_alarm (optional): string, 64 //Alert code name

code_tamper (optional): string, 64 //Intervention code name

code_low_battery (optional): string, 64 //Name of low battery code

RESPONSE:

{
	data: {
		'response': 'OK'
		},
	error: null
}

After sending the parameters, the added device is expected to be activated. When triggered, the process of adding occurs, and only after that the answer comes.


Remote, 4 buttons (create-console)

Request URL: [site]/api/wizard/create-console

Params:

controller_id (required): int

token (required): string, 64

device_name (optional): string, 256

code_lock (optional): string, 64 //Lock code name

code_unlock (optional): string, 64 //Unlock code name

code_s (optional): string, 64 //"s" code name

code_alarm (optional): string, 64 //Alert code name

RESPONSE:

{
	data: {
		'response': 'OK'
	},
	error: null
}

After sending the parameters, the added device is expected to be activated. When triggered, the process of adding occurs, and only after that the answer comes.


Siren (create-siren)

Request URL: [site]/api/wizard/create-siren

Params:

controller_id (required): int

token (required): string, 64

device_name (optional): string, 256

code_on (optional): string, 64 //Name of the inclusion code

code_off (optional): string, 64 //Shutdown code name

code_blank (optional): string, 64 // blank code name

RESPONSE:

{
	data: {
		'response': 'OK'
		},
	error: null
}

Before sending the parameters, it is necessary to transfer the siren to the training mode


Weather Station: Get a list of weather stations found in the last 10 minutes (get-meteos)

Request URL: [site]/api/wizard/get-meteos

Params:

controller_id (required): int

token (required): string, 64

RESPONSE:

{
	"error":null,
	"data":				 	[{"id":"93","controller_id":"79","date":"1528389351","type":"7","family":"0","rf_code":null,"rf_bit_len":null,"rf_pulse_len":null,"rf_protocol":null,"rf_freq":null,"ir_code":null,"ir_bit_len":null,"ir_address":null,"ir_protocol":null,"meteo_num":"0"}]
}

Adding Weather Station (create-meteo)

Request URL: [site][site]/api/wizard/create-meteo

Params:

controller_id (required): int

token (required): string, 64

meteo_num (required): int //It turns out in the list above

device_name (optional): string, 256

RESPONSE:

{
	"error":null,
	"data":{
		"response":"OK"
		}
}


Water tap

The procedure for adding a crane: 1) Generate codes

2) Press the button on the tap until the tap flashes three times.

3) Send one code

4) Press the button on the tap once

5) Press the button on the tap until it blinks 4 times

6) Send the second code from the generated

7) Press the button on the tap once

8) Send a request to create a crane.


Code Generation

Request URL: [site]/api/wizard/create-codes

Params:

controller_id (required): int

token (required): string, 64

Response:

{
	"error":null,
	"data":{"response":{"id":30,"masks":"[6,4,0,1]","code_1":"9920950","code_2":"9920948","code_3":"9920944","code_4":"9920945"}
		}
}


Code Execution

Request URL: [site]/api/wizard/execute-code

Params:

controller_id (required): int

token (required): string, 64

code (required): int // Takes from generated

Response:

{
	error: null,
	data: {
		"response":"OK"
		}
}

Adding a tap

Request URL: [site]/api/wizard/create-crane-by-codes

Params:

controller_id (required): int

token (required): string, 64

code_1 (required): int

code_2 (required): int

device_name (optional): string, 256

code_open (optional): string, 64 //The name of the opening code

code_close (optional): string, 64 //Closing code name

RESPONSE:

{
	data:{'response': 'OK'},
	error: null
}

Название кода закрытия

The procedure for adding the socket is as follows:

1) Generate codes

2) Press the button on the outlet until it flashes

3) Send one code

4) Press the button on the outlet until it flashes

4) Зажать на розетке кнопку, пока она не начнет мигать

6) Send a request to create an outlet


Generation of codes (create-codes)

Request URL: [site]/api/wizard/create-codes

Params:

controller_id (required): int

token (required): string, 64

socket (required): любое значение.

Response:

{
	"error":null,
	"data":{
		"response":{"id":30,"masks":"[257, 258]","code_1":"8737025","code_2":"8737026"}
		}
}


Code Execution (execute-code)

Request URL: [site]/api/wizard/execute-code

Params:

controller_id (required): int

token (required): string, 64

code (required): int // Takes from generated

Response

{
	error: null,
	data: {'response' => 'OK'}
}


Add a socket (create-socket)

Request URL: [site]/api/wizard/create-socket

Params:

controller_id (required): int

token (required): string, 64

code_1 (required): int

code_2 (required): int

device_name (optional): string, 256

code_off (optional): string, 64 //Shutdown Code Name

code_on (optional): string, 64 //Name of the inclusion code

RESPONSE:

{
	data: {'response':'OK'},
	error: null
}

Scripts

List of scripts (list)

request: Request URL: [site]/api/scheduler/list/

request parameters: (string) token

Request example:

{
	"token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae"
}

response:

response parameters:

Example response:

{
"0":{
	"id":9,
	"external_id":42,
	"name":"test_form_web",
	"operation":"local",
	"armed":0,
	"type":"meteo",
	"action_id":1,
	"a_controller_id":6,
	"a_device_id":112,
	"a_code_id":0,
	"a_device_external_id":38,
	"a_armed":0,
	"a_conf1":0,
	"a_conf2":0,
	"a_conf3":0,
	"a_conf4":0,
	"a_conf5":0,
	"a_conf6":0,
	"a_conf7":0,
	"a_conf8":0,
	"target_id":1,
	"t_controller_id":6,
	"t_device_id":119,
	"t_code_id":203,
	"t_device_external_id":7,
	"t_armed":0,
	"t_conf1":0,
	"t_conf2":0,
	"t_conf3":0,
	"t_conf4":0,
	"t_conf5":0,
	"t_conf6":0,
	"t_conf7":0,
	"t_conf8":0,
	"date":null,
	"repetition":"0",
	"sensor_type":"1",
	"logic_operation":"=",
	"value":"3",
	"active":1
	},
"1":{
	"id":10,
	"external_id":45
	...
	} 
}


Update Scripts (update)

The request is carried out in 2 stages: in the first stage it occurs when a request is made to update the Controller (see "Updating the Controller"); at the second stage, information about each action is updated.

request: Request URL: [site]/api/scheduler/update/

request parameters:

(int) controller_id,

(string) token

Request example:

{
	"controller_id": 6 ,
	"token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae",
}

response:

response parameters:

Example response:

{
	"result": "Ok" // ответ что запрос ушел
}

The update process happens automatically. To get the result, a timeout is required, after which a standard data request is made (controller, actions)


Script Information (info)

request: Request URL: [site]/api/scheduler/info/

request parameters:

(int) scheduler_id,

(string) token

Example response:

{
	"scheduler_id": 122,
	"token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae"
}

response:

response parameters:

Example response:

{
	"id":9,
	"external_id":42,
	"name":"test_form_web",
	"operation":"local",
	"armed":0,
	"type":"meteo",
	"action_id":1,
	"a_controller_id":6,
	"a_device_id":112,
	"a_code_id":0,
	"a_device_external_id":38,
	"a_armed":0,
	"a_conf1":0,
	"a_conf2":0,
	"a_conf3":0,
	"a_conf4":0,
	"a_conf5":0,
	"a_conf6":0,
	"a_conf7":0,
	"a_conf8":0,
	"target_id":1,
	"t_controller_id":6,
	"t_device_id":119,
	"t_code_id":203,
	"t_device_external_id":7,
	"t_armed":0,
	"t_conf1":0,
	"t_conf2":0,
	"t_conf3":0,
	"t_conf4":0,
	"t_conf5":0,
	"t_conf6":0,
	"t_conf7":0,
	"t_conf8":0,
	"date":null,
	"repetition":"0",
	"sensor_type":"1",
	"logic_operation":"=",
	"value":"3",
	"active":1
}


User logs (logs)

request:

Request URL: [site]/api/profile/logs/

request parameters: (string) token

Request example:

{
	"token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae"
}

response:

response parameters: (object) example: {

}




Codes

Getting code info (info)

request:

Request URL: [site]/api/property/info/

request parameters: (int) controller_id,

(int) device_id,

(int) code_id,

(string) token

Request example:

{
	"controller_id": 6,
	"device_id": 109, 
	"code_id": 192,
	"token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae"

}

response: response parameters:

Example response:

{
	"id":"192",
	"external_cod_id":"67",
	"device_id":"109",
	"name":"4 OFF",
	"code":"12209156",
	"protocol":"1",
	"pulse_len":null,
	"group_1":"1",
	"group_2":"0",
	"group_3":"0",
	"group_4":"0",
	"group_5":"0",
	"group_6":"0",
	"group_7":"0",
	"group_8":"0",
	"active":"1"
}


Change code name (update-code-name)

Request URL: [site]/api/device/update-code-name

Request Params:

token (required): string(64)

code_id (required): int

name (optional): string(255)

SUCCESS RESPONSE:

{
	data: {
		'message': "OK"
		},
	error: null
}

Receiving codes by signal type (get-codes-by-subtype)

Request URL: [site]/api/device/get-codes-by-subtype

Request Params:

token (required): string(64)

device_subtype_id (optional): int, default 0.

Getting a list of codes (get-codes)

Request URL: [site]/api/device/get-codes

PARAMS: token (required): string 64

controller_id (required): int

SUCCESS RESPONSE:

{
	data: [
		{
			devices:	[
			{
				id:	13
				external_id:	7,
				controller_id:	5,
				name:	"Simple device",
				type_id:	2,
				password:	null,
				codes:	"a:4:{i:0;i:46;i:1;i:47;i:2;i:48;i:3;i:45;}",
				state:	1,
				on_dashboard:	0,
				active:	1,
				new:	1,
				family:	DEVICE_FAMILY_RADIO,
				camera_id:	null,
				camera_host:	null
			},
			{
				id:	14
				external_id:	8,
				controller_id:	5,
				name:	"Simple device",
				type_id:	2,
				password:	null,
				codes:	"a:4:{i:0;i:46;i:1;i:47;i:2;i:48;i:3;i:45;}",
				state:	1,
				on_dashboard:	0,
				active:	1,
				new:	1,
				family:	DEVICE_FAMILY_RADIO,
				camera_id:	null,
				camera_host:	null
			},
		],
		code: {
			id:	12,
			controller_id: 5,
			device_type_id:	2,
			code: 498654,
			protocol: 1,
			bit_len: 32,
			pulse_len:	86,
			freq:	77,
			address:	94,
			num:	1,
			date_create: '2018-04-13 18:29:11"

		}
		}, 

		{
			devices:	[
			{
				id:	13
				external_id:	7,
				controller_id:	5,
				name:	"Simple device",
				type_id:	2,
				password:	null,
				codes:	"a:4:{i:0;i:46;i:1;i:47;i:2;i:48;i:3;i:45;}",
				state:	1,
				on_dashboard:	0,
				active:	1,
				new:	1,
				family:	DEVICE_FAMILY_RADIO,
				camera_id:	null,
				camera_host:	null
			},
			{
				id:	14
				external_id:	8,
				controller_id:	5,
				name:	"Simple device",
				type_id:	2,
				password:	null,
				codes:	"a:4:{i:0;i:46;i:1;i:47;i:2;i:48;i:3;i:45;}",
				state:	1,
				on_dashboard:	0,
				active:	1,
				new:	1,
				family:	DEVICE_FAMILY_RADIO,
				camera_id:	null,
				camera_host:	null
			},
		],
		code: {
			id:	12,
			controller_id: 5,
			device_type_id:	2,
			code: 498654,
			protocol: 1,
			bit_len: 32,
			pulse_len:	86,
			freq:	77,
			address:	94,
			num:	1,
			date_create: '2018-04-13 18:29:11"

		}
		}, 
	},
	error: null,
}

Adding code to a device (set-code-to-device)

Request URL: [site]/api/device/set-code-to-device

PARAMS:

token (required): string 64

code_id (required): int

device_id (required): int

name (optional): string 256

SUCCESS RESPONSE:

{
	data:	{
		id: 5,
		external_cod_id: 15,
		device_id: 14,
		name: "Name"
		code: 8463517,
		protocol: 0,
		pulse_len:	86, 
		active: 1,
	},
	error: null
}

Remove code (remove-code)

Request URL: [site]/api/device/remove-code PARAMS:

token (required): string 64

code_id (required): int

SUCCESS RESPONSE:

{
	data:	{
		message: "OK"
	},
	error: null
}

Events

Press the button on the device (event)

request:

Request URL: [site]/api/device/event/

request parameters:

(string) controller_name,

(int) device_external_id,

(int) cod_external_id,

(string) token,

(int) device_type

Request example:

{
	"controller_name": " AS_7F26335CCF4B" ,
	"device_external_id": 19,
	"cod_external_id": 1,
	"device_type": 1,
	"token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae"
}

since MQTT is one-way, there can be no answer. An answer may be returned that the request has been sent:

response:

response parameters:

Sample answer:

{
	"result": "Ok"
}

Places

Getting a list of places (places-list)

Request URL: [site]/api/places/places-list

Request params:

token (required): string, 64

Response:

{
	"error":null,
	"data":{
		"rooms":[{"id":1,"root_id":1,"user_id":424,"lvl":0,"name":"Дом","icon":0,"icon_type":1,"color":"#fff2cc","readonly":0,"visible":1},{"id":2,"root_id":1,"user_id":424,"lvl":1,"name":"Спальня","icon":0,"icon_type":1,"color":"#b6d7a8","readonly":0,"visible":1}]
		}
}


Creating a place (create)

Request URL: [site]/api/places/create

Request params:

token (required): string, 64

root (optional): int, default 1

lft (optional): int, from 1 to 5 //Summ of rgt should be 5

rgt (optional): int, from 1 to 5 //Summ of lft should be 5

lvl (optional): int, default 0

name (optional): string, 64, default 'Simple name'

icon (optional): string, default //Valid parameters are keys that are presented above

color (optional): string, default: '#ccc' //Any color in HEX format, the grid at the beginning is required

active (optional): int, default 1

selected (optional): int, default 0

disabled (optional): int, default 0

readonly (optional): int, default 0

visible (optional): int, default 1

collapsed (optional): int, default 0

movable_u (optional): int, default 1

movable_d (optional): int, default 1

movable_l (optional): int, default 1

movable_r (optional): int, default 1

removable (optional): int, default 1

removable_all (optional): int, default 0

inverse_text (optional): string, default 'black'


Response:

{
	error:null,
	data: {'message': 'OK'}
}


Editing a place (edit)

Request URL: [site]/api/places/edit

Request params:

token (required): string, 64

place_id (required): int

root (optional): int, default 1

lft (optional): int, from 1 to 5 //Summ of rgt should be 5

rgt (optional): int, from 1 to 5 //Summ of lft should be 5

lvl (optional): int, default 0

name (optional): string, 64, default 'Simple name'

icon (optional): string, default //Allowed parameters as object keys are presented above

color (optional): string, default: '#ccc' //Any color in HEX format, the grid at the beginning is required

active (optional): int, default 1

selected (optional): int, default 0

disabled (optional): int, default 0

readonly (optional): int, default 0

visible (optional): int, default 1

collapsed (optional): int, default 0

movable_u (optional): int, default 1

movable_d (optional): int, default 1

movable_l (optional): int, default 1

movable_r (optional): int, default 1

removable (optional): int, default 1

removable_all (optional): int, default 0

inverse_text (optional): string, default 'black'


Response:

{
	error:null,
	data: {'message': 'OK'}
}

Deleting a place (delete)

Request URL: [site]/api/places/delete

Request params:

token (required): string, 64

place_id (required): int

Response:

{
	error:null,
	data: {'message': 'OK'}
}



Ebus subscription activation

Getting the subscription status on the Controller - “in/subscription/get”:

{
	"id": 1, // Subscription ID (see below)
	"seq_id": 0
}

Response:

{
	"seq_id": 0,
	"remain_time": 100, // remaining time in seconds; 4294967295 is unlimited
	"success": 0/1
}

Subscription setting on the Controller - “in/subscription/set”:

{
	"seq_id": 0,
	"id": 1, // Subscription ID (see below)
	"remain_time": 100 // Remaining time in seconds; 4294967295 is unlimited
}

Response:

{
	"seq_id": 0,
	"success": 0/1
}

Subscription IDs: SUBSCRIPTION_EBUS = 1

Controller Status

The Controller sends information about its online/offline status to the “out/status” topic.

Request format:

{
	"status": 1 // see below
}

The “status” field can have the following values:

• "0" - offline

• "1" - online

• "2" - online after power on

When receiving a message with the status "2", the portal should send information about user subscriptions to the Controller, as described in the "Subscriptions" section.


Errors

error parameters:

{
	"errors":{
		"password": [
			"Incorrect username."
		]
	}
}