Web API
- API v01 *
API ( json )
Содержание
- 1 Account
- 2 Controllers
- 2.1 List of User Controllers (list)
- 2.2 Controller Information (info)
- 2.3 Arming / disarming the Controller (armed)
- 2.4 Add Controller (add)
- 2.5 Update controller status (update-status)
- 2.6 Getting the current status of the Controller (get-status)
- 2.7 Transmit Local IP Controller (get-ip)
- 2.8 Setting a Subscription on the Controller
- 2.9 View Subscription Status (get-subscribe-status)
- 2.10 Activation / extension / purchase of a subscription (set-subscribe)
- 2.11 Getting phone list (get-phones)
- 2.12 Edit phone (edit-phone)
- 2.13 Delete phone (delete-phone)
- 2.14 Add Phone (add-phone)
- 3 Devices
- 3.1 Getting a list of user devices (list)
- 3.2 Device Information (info)
- 3.3 Update Device Information (update)
- 3.4 Deleting a device (delete)
- 3.5 Getting weather data (last)
- 3.6 Receiving meteorological data for the period
- 3.7 Receive power data (last)
- 3.8 Obtain power data for a period (period)
- 3.9 Getting data about third-party devices (other-last)
- 3.10 Get data on third-party devices for the period (other-period)
- 4 Devices adding Wizard
- 4.1 Door open sensor (create-door-open-sensor)
- 4.2 Flood sensor (create-flood-sensor)
- 4.3 Remote, 4 buttons (create-console)
- 4.4 Siren (create-siren)
- 4.5 Weather Station: Get a list of weather stations found in the last 10 minutes (get-meteos)
- 4.6 Adding Weather Station (create-meteo)
- 4.7 Water tap
- 4.8 Добавление розетки
- 5 Сценарии
- 6 Логи пользователя (logs)
- 7 Коды
- 8 События
- 9 Места
- 10 Ошибки
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:
- (int) controller_id,
- (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:
- (int) controller_id,
- (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) Отправить один код
4) Нажать на кране кнопку однократно
5) Зажать на кране кнопку, пока не мигнёт 4 раза
6) Отправить второй код из сгенерированных
7) Нажать на кране кнопку однократно
8) Отправить запрос на создание крана.
Генерация кодов
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"} } }
Выполнение кода
Request URL: [site]/api/wizard/execute-code
Params:
controller_id (required): int
token (required): string, 64
code (required): int // Берется из сгенерированных
Response:
{ error: null, data: { "response":"OK" } }
Добавление крана
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 //Название кода открытия
code_close (optional): string, 64 //Название кода закрытия
RESPONSE:
{ data:{'response': 'OK'}, error: null }
Добавление розетки
порядок добаления розетки следующий:
1) Сгенерировать коды
2) Зажать на розетке кнопку, пока она не начнет мигать
3) Отправить один код
4) Зажать на розетке кнопку, пока она не начнет мигать
5) Отправить второй код из сгенерированых
6) Отправить запрос на создание розетки
Генерация кодов (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"} } }
Выполнение кода (execute-code)
Request URL: [site]/api/wizard/execute-code
Params:
controller_id (required): int
token (required): string, 64
code (required): int // Берется из сгенерированных
Response
{ error: null, data: {'response' => 'OK'} }
Добавление розетки (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 //Название кода открытия
code_on (optional): string, 64 //Название кода закрытия
RESPONSE:
{ data: {'response':'OK'}, error: null }
Сценарии
Список сценариев (list)
request: Request URL: [site]/api/scheduler/list/
параметры запроса: (string) token
Пример запроса:
{ "token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae" }
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)
Запрос осуществляется в 2 этапа: на первом этапе происходит при запросе на обновление Контроллера (см. "Обновление Контроллера"); на втором этапе обновляется информация о каждом действии.
request: Request URL: [site]/api/scheduler/update/
параметры запроса:
(int) controller_id,
(string) token
Пример запроса:
{ "controller_id": 6 , "token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae", }
response:
параметры ответа:
Пример ответа:
{ "result": "Ok" // ответ что запрос ушел }
Процесс обновления происходит автоматически. Для получения результата требуется таймаут, после чего делается стандартный запрос на получение данных (Контроллер, действия)
Информация о сценарии (info)
request: Request URL: [site]/api/scheduler/info/
параметры запроса:
(int) scheduler_id,
(string) token
Пример ответа:
{ "scheduler_id": 122, "token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae" }
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 }
Логи пользователя (logs)
request:
Request URL: [site]/api/profile/logs/
параметры запроса: (string) token
Пример запроса:
{ "token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae" }
response: параметры ответа: (object) пример: {
}
Коды
Получение информации о коде (info)
request:
Request URL: [site]/api/property/info/
параметры запроса: (int) controller_id,
(int) device_id,
(int) code_id,
(string) token
Пример запроса:
{ "controller_id": 6, "device_id": 109, "code_id": 192, "token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae" }
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" }
Изменение имени кода (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 }
Получение кодов по типу сигнала (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.
Получение списка кодов (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, }
Добавление кода к устройству (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)
Request URL: [site]/api/device/remove-code PARAMS:
token (required): string 64
code_id (required): int
SUCCESS RESPONSE:
{ data: { message: "OK" }, error: null }
События
Нажатие кнопки на устройстве (event)
request:
Request URL: [site]/api/device/event/ параметры запроса:
(string) controller_name,
(int) device_external_id,
(int) cod_external_id,
(string) token,
(int) device_type
Пример запроса:
{ "controller_name": " AS_7F26335CCF4B" , "device_external_id": 19, "cod_external_id": 1, "device_type": 1, "token":"_zcX0_QceAqgP_seIvjG32EC3HMO34ae" }
так как MQTT односторонний - ответа быть не может. Может быть возвращён ответ, что запрос отправлен: response:
параметры ответа:
Пример ответа:
{ "result": "Ok" }
Места
Получение списка мест (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}] } }
Создание места (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 //В сумме с rgt должно быть 5
rgt (optional): int, from 1 to 5 //В сумме с lft должно быть 5
lvl (optional): int, default 0
name (optional): string, 64, default 'Simple name'
icon (optional): string, default //Допускаемые параметры -- ключи объекта выше
color (optional): string, default: '#ccc' //Любой цвет в формате HEX, решетка в начале обязательна
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'} }
Редактирование места (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 //В сумме с rgt должно быть 5
rgt (optional): int, from 1 to 5 //В сумме с lft должно быть 5
lvl (optional): int, default 0
name (optional): string, 64, default 'Simple name'
icon (optional): string, default //Допускаемые параметры -- ключи объекта выше
color (optional): string, default: '#ccc' //Любой цвет в формате HEX, решетка в начале обязательна
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'} }
Удаление места (delete)
Request URL: [site]/api/places/delete
Request params:
token (required): string, 64
place_id (required): int
Response:
{ error:null, data: {'message': 'OK'} }
Активация подписки Ebus
Получение состояния подписки на Контроллере - “in/subscription/get”:
{ "id": 1, // ID подписки (см. ниже) "seq_id": 0 }
Ответ:
{ "seq_id": 0, "remain_time": 100, // оставшееся время в секундах, 4294967295 – неограниченно "success": 0/1 }
Установка подписки на Контроллере - “in/subscription/set”:
{ "seq_id": 0, "id": 1, // ID подписки (см. ниже) "remain_time": 100 // оставшееся время в секундах, 4294967295 - неограниченно }
Ответ:
{ "seq_id": 0, "success": 0/1 }
Идентификаторы подписок: SUBSCRIPTION_EBUS = 1
Статус Контроллера
Контроллер отправляет информацию о своем онлайн/оффлайн статусе в топик “out/status”.
Формат сообщения:
{ "status": 1 // см. ниже }
Поле “status” может принимать следующие значения:
• "0" – оффлайн
• "1" – онлайн
• "2" – онлайн, после включения питания
При получении сообщения со статусом "2", портал должен отправить Контроллеру информацию о пользовательских подписках, как это описано в разделе «Подписки».
Ошибки
параметры ошибки:
пример:
{ "errors":{ "password": [ "Incorrect username." ] } }