Comment on page
Public API ERa hỗ trợ
Ghi chú
- Trigger action chỉ dành cho các widget là action
- Response data sẽ trả nhiều field hơn so với những ví dụ, cho nên chỉ tập trung nhưng field ví dụ.
Bước 1: Đăng nhập app.e-ra.io
Bước 2: Chọn profile

Bước 3: Copy Auth Token

- METHOD: GET
- HEADERS: {Authorization: Token}
- RESPONS_STATUS_CODE: 200
- RESPONSE_DATA:
{
id: unit_id,
name: "Unit Name",
stations: [
{
id: subunit_id,
name: "Sub-unit Name",
devices: [
{
id: end_device_id,
name: "end device led 1",
},
],
},
],
}
--> Lấy end_device_id
- METHOD: GET
- HEADERS: {Authorization: Token}
- RESPONS_STATUS_CODE: 200
- RESPONSE_DATA
{
Items: [
{
id: widget_id,
order: 0,
template: "action",
type: "action",
configuration: {
id: action_display_id,
template: "on_off_button_action_template",
title: "",
configuration: {
action_on: "key_on",
action_off: "key_off",
text_on: "ON",
text_off: "OFF",
},
},
},
];
}
--> Lấy action_on hoặc action off
- METHOD: POST
- BODY:
{
"key": "key_on",
"source": "internet"
}
- HEADERS: {Authorization: Token}
- RESPONS_STATUS_CODE: 200
- RESPONSE_DATA:
{
result: "ok",
};
- METHOD: GET
- HEADERS: {Authorization: Token}
- RESPONS_STATUS_CODE: 200
- RESPONSE_DATA:
{
current_value_only: 0,
};
- RESPONSE_DATA:
{
id: 1,
name: "Unit Name",
stations: [
{
id: 2,
name: "Sub-unit Name",
devices: [
{
id: 3,
name: "end device led 1",
},
],
},
],
};
--> end_device_id là 3
- RESPONSE_DATA:
{
items: [
{
id: 1,
order: 0,
template: "action",
type: "action",
configuration: {
id: 103,
template: "on_off_button_action_template",
title: "",
configuration: {
action_on: "c163e4a9-79a6-4ae5-9dd9-c5cf8377d3e3",
action_off: "dbd5b4d7-8c5c-485f-8aca-90474ffe9d84",
icon_on: "PoweroffOutlined",
icon_off: "PoweroffOutlined",
config: 163,
text_on: "ON",
text_off: "OFF",
},
},
},
],
};
--> action_on key là c163e4a9-79a6-4ae5-9dd9-c5cf8377d3e3
--> action_off key là dbd5b4d7-8c5c-485f-8aca-90474ffe9d84
- Gọi api điều khiển thiết bị
{
key: "c163e4a9-79a6-4ae5-9dd9-c5cf8377d3e3",
source: "internet"
}
- RESPONSE_DATA:
{
result: "ok",
};
- API Lấy giá trị của datastream
- RESPONSE_DATA:
{
current_value_only: 1,
};
Last modified 15d ago