Tài liệu › Tham chiếu API › IoT (chỉ đọc)

IoT (chỉ đọc)

Thiết bị, số đo cảm biến, cảnh báo, lịch tưới. API key không có API điều khiển thiết bị.

24 thao tác · gốc /api/v1/iot

GET/api/v1/iot/alert-rules

Danh sách rule cảnh báo

Lọc theo deviceId (tùy chọn).

Scope: iot.alerts.viewThử trong API Explorer ▶

Tham số

Tham sốKiểuVị tríBắt buộcMô tả
deviceIdGUIDquerykhông—

Ví dụ

curl -X GET "https://api-prod.nextfarm.vn/api/v1/iot/alert-rules" \
  -H "Authorization: Bearer <ACCESS_TOKEN>"

Phản hồi mẫu

200 OK
[
  {
    "consecutive_breach_count": 1,
    "cooldown_hours": 1,
    "device_code": "…",
    "device_id": "0190a3c2-5b1e-7c3d-8e4f-000000000001",
    "device_name": "…",
    "id": "0190a3c2-5b1e-7c3d-8e4f-000000000001",
    "is_active": true,
    "sensor_type": "…",
    "threshold_max": 1.5,
    "threshold_min": 1.5
  }
]
GET/api/v1/iot/alerts

Danh sách cảnh báo

Lọc theo deviceId / status / severity / from / to. Phân trang.

Scope: iot.alerts.viewThử trong API Explorer ▶

Tham số

Tham sốKiểuVị tríBắt buộcMô tả
deviceIdGUIDquerykhông—
statusstringquerykhông—
severitystringquerykhông—
fromdatequerykhông—
todatequerykhông—
pageintquerykhông—
pageSizeintquerykhông—

Ví dụ

curl -X GET "https://api-prod.nextfarm.vn/api/v1/iot/alerts" \
  -H "Authorization: Bearer <ACCESS_TOKEN>"

Phản hồi mẫu

200 OK
{
  "items": [
    {
      "acknowledged_at": "2026-10-28T07:30:00Z",
      "device_code": "…",
      "device_id": "0190a3c2-5b1e-7c3d-8e4f-000000000001",
      "id": "0190a3c2-5b1e-7c3d-8e4f-000000000001",
      "resolved_at": "2026-10-28T07:30:00Z",
      "rule_id": "0190a3c2-5b1e-7c3d-8e4f-000000000001",
      "sensor_type": "…",
      "severity": "…",
      "status": "…",
      "threshold": "…",
      "triggered_at": "2026-10-28T07:30:00Z",
      "value": 1.5
    }
  ],
  "page": 1,
  "page_size": 1,
  "total": 1
}
GET/api/v1/iot/commands

Danh sách lệnh thiết bị

Lọc theo deviceId (tùy chọn). Phân trang.

Scope: iot.devices.viewThử trong API Explorer ▶

Tham số

Tham sốKiểuVị tríBắt buộcMô tả
deviceIdGUIDquerykhông—
pageintquerykhông—
pageSizeintquerykhông—

Ví dụ

curl -X GET "https://api-prod.nextfarm.vn/api/v1/iot/commands" \
  -H "Authorization: Bearer <ACCESS_TOKEN>"

Phản hồi mẫu

200 OK
{
  "items": [
    {
      "acknowledged_at": "2026-10-28T07:30:00Z",
      "command_type": "…",
      "device_code": "…",
      "device_id": "0190a3c2-5b1e-7c3d-8e4f-000000000001",
      "id": "0190a3c2-5b1e-7c3d-8e4f-000000000001",
      "payload": "…",
      "sent_at": "2026-10-28T07:30:00Z",
      "sent_by_user_id": "0190a3c2-5b1e-7c3d-8e4f-000000000001",
      "status": "…"
    }
  ],
  "page": 1,
  "page_size": 1,
  "total": 1
}
GET/api/v1/iot/devices

Danh sách thiết bị IoT

Lọc theo status. Phân trang.

Scope: iot.devices.viewThử trong API Explorer ▶

Tham số

Tham sốKiểuVị tríBắt buộcMô tả
statusstringquerykhông—
pageintquerykhông—
pageSizeintquerykhông—
parcelIdGUIDquerykhông—
unassignedboolquerykhông—
zoneIdGUIDquerykhông—

Ví dụ

curl -X GET "https://api-prod.nextfarm.vn/api/v1/iot/devices" \
  -H "Authorization: Bearer <ACCESS_TOKEN>"

Phản hồi mẫu

200 OK
{
  "items": [
    {
      "created_at": "2026-10-28T07:30:00Z",
      "device_code": "…",
      "device_type": "…",
      "dong_ho_nuoc": "…",
      "id": "0190a3c2-5b1e-7c3d-8e4f-000000000001",
      "is_online": true,
      "last_heartbeat": "2026-10-28T07:30:00Z",
      "location_lat": 1.5,
      "location_lng": 1.5,
      "mac_address": "…",
      "manual_max_min": 1,
      "mcv_valve_variant": "…",
      "mqtt_topic_prefix": "…",
      "name": "…",
      "niche": "…",
      "parcel_ids": [
        "0190a3c2-5b1e-7c3d-8e4f-000000000001"
      ],
      "provision_status": "…",
      "scene_kind": "…",
      "shared_in_zone": true,
      "status": "…",
      "tran_thoi_luong": "…",
      "zone_id": "0190a3c2-5b1e-7c3d-8e4f-000000000001"
    }
  ],
  "page": 1,
  "page_size": 1,
  "total": 1
}
GET/api/v1/iot/devices/control-states

Trạng thái điều khiển nhiều thiết bị (màn hình nhiều nhà)

Lọc theo zoneId (tùy chọn).

Scope: iot.devices.viewThử trong API Explorer ▶

Tham số

Tham sốKiểuVị tríBắt buộcMô tả
zoneIdGUIDquerykhông—

Ví dụ

curl -X GET "https://api-prod.nextfarm.vn/api/v1/iot/devices/control-states" \
  -H "Authorization: Bearer <ACCESS_TOKEN>"

Phản hồi mẫu

200 OK
[
  {
    "catalog": [
      {
        "key": "…",
        "kind": "…",
        "label": "…",
        "valid_values": [
          1
        ]
      }
    ],
    "device_code": "…",
    "device_id": "0190a3c2-5b1e-7c3d-8e4f-000000000001",
    "device_outputs": [
      {
        "auto_mode": 1,
        "family": "…",
        "index": 1,
        "key": "…",
        "kind": "…",
        "label": "…",
        "mcv_actual": 1,
        "mcv_set": 1,
        "mcv_stat": 1,
        "port": 1,
        "role": "…",
        "state": 1,
        "type": "…",
        "valid_values": [
          1
        ]
      }
    ],
    "fert1_open": true,
    "fert2_open": true,
    "fert_open_mask": 1,
    "fert_pump_lock": 1,
    "fert_pump_run": 1,
    "fert_pump_suy_ra": 1,
    "fert_pump_why": 1,
    "flow_lmin": 1.5,
    "is_gateway_firmware": true,
    "is_online": true,
    "mcv_run": null,
    "outputs": 1,
    "pump_flushing": true,
    "pump_irrigating": true,
    "pump_mode": 1,
    "pump_on": true,
    "reported_at": "2026-10-28T07:30:00Z",
    "shade": 1,
    "shade_closing": true,
    "shade_opening": true,
    "vol_cur_ml": 1
  }
]
GET/api/v1/iot/devices/{deviceId}/control-state

Trạng thái điều khiển thực tế của 1 thiết bị

Giải mã từ outputs bitmask + pump/winch/shade/flow (status mỗi 5s). FE poll ~5s.

Scope: iot.devices.viewThử trong API Explorer ▶

Tham số

Tham sốKiểuVị tríBắt buộcMô tả
deviceIdGUIDpathcó—

Ví dụ

curl -X GET "https://api-prod.nextfarm.vn/api/v1/iot/devices/<deviceId>/control-state" \
  -H "Authorization: Bearer <ACCESS_TOKEN>"

Phản hồi mẫu

200 OK
{
  "catalog": [
    {
      "key": "…",
      "kind": "…",
      "label": "…",
      "valid_values": [
        1
      ]
    }
  ],
  "device_code": "…",
  "device_id": "0190a3c2-5b1e-7c3d-8e4f-000000000001",
  "device_outputs": [
    {
      "auto_mode": 1,
      "family": "…",
      "index": 1,
      "key": "…",
      "kind": "…",
      "label": "…",
      "mcv_actual": 1,
      "mcv_set": 1,
      "mcv_stat": 1,
      "port": 1,
      "role": "…",
      "state": 1,
      "type": "…",
      "valid_values": [
        1
      ]
    }
  ],
  "fert1_open": true,
  "fert2_open": true,
  "fert_open_mask": 1,
  "fert_pump_lock": 1,
  "fert_pump_run": 1,
  "fert_pump_suy_ra": 1,
  "fert_pump_why": 1,
  "flow_lmin": 1.5,
  "is_gateway_firmware": true,
  "is_online": true,
  "mcv_run": null,
  "outputs": 1,
  "pump_flushing": true,
  "pump_irrigating": true,
  "pump_mode": 1,
  "pump_on": true,
  "reported_at": "2026-10-28T07:30:00Z",
  "shade": 1,
  "shade_closing": true,
  "shade_opening": true,
  "vol_cur_ml": 1
}
GET/api/v1/iot/devices/{deviceId}/display-prefs

GET /api/v1/iot/devices/{deviceId}/display-prefs

Scope: iot.devices.viewThử trong API Explorer ▶

Tham số

Tham sốKiểuVị tríBắt buộcMô tả
deviceIdGUIDpathcó—

Ví dụ

curl -X GET "https://api-prod.nextfarm.vn/api/v1/iot/devices/<deviceId>/display-prefs" \
  -H "Authorization: Bearer <ACCESS_TOKEN>"

Phản hồi mẫu

200 OK
{
  "control_sensors": [
    "…"
  ],
  "device_id": "0190a3c2-5b1e-7c3d-8e4f-000000000001"
}
GET/api/v1/iot/devices/{deviceId}/fert-meters

Đồng hồ các bồn phân: chỗ cắm, hệ số bo đang dùng, và số đếm xung thô mới nhất

pulse_at = null nghĩa là CHƯA BAO GIỜ nhận được xung nào từ thiết bị này. Trong mỗi kênh: pulse = -1 là không có đồng hồ / không đọc được · 0 là CÓ đồng hồ mà chưa quay · null là bo chưa gửi trường đó. Ba giá trị, ba nghĩa khác nhau.

Scope: iot.devices.viewThử trong API Explorer ▶

Tham số

Tham sốKiểuVị tríBắt buộcMô tả
deviceIdGUIDpathcó—

Ví dụ

curl -X GET "https://api-prod.nextfarm.vn/api/v1/iot/devices/<deviceId>/fert-meters" \
  -H "Authorization: Bearer <ACCESS_TOKEN>"

Phản hồi mẫu

200 OK
{
  "channels": [
    {
      "chu_ky_ly_do": "…",
      "chu_ky_server_tinh": {
        "lit": 1.5,
        "moc_tai": "2026-10-28T07:30:00Z",
        "xung_tu_dau_cu": 1
      },
      "cu_truoc_lit": 1.5,
      "dong_bo": {
        "da_gui": 1,
        "echo_luc": "2026-10-28T07:30:00Z",
        "gui_luc": "2026-10-28T07:30:00Z",
        "trang_thai": "…"
      },
      "idx": 1,
      "meter_id": 1,
      "meter_in": 1,
      "meter_ulp": 1,
      "meter_ulp_operator": 1,
      "meter_ulp_operator_at": "2026-10-28T07:30:00Z",
      "pulse": 1,
      "server_tinh": {
        "lit": 1.5,
        "ly_do": "…",
        "nguon": "…",
        "ulp_da_dung": 1
      }
    }
  ],
  "chu_ky_bat_dau_luc": "2026-10-28T07:30:00Z",
  "device_code": "…",
  "flow_meter_in": 1,
  "flow_pulse": 1,
  "muc_tieu_lit_chu_ky": 1,
  "pulse_at": "2026-10-28T07:30:00Z",
  "pulse_ml": 1,
  "pulse_ul": 1,
  "water_chu_ky_server_tinh": {
    "lit": 1.5,
    "ly_do": "…",
    "nguon": "…",
    "ulp_da_dung": 1
  },
  "water_server_tinh": {
    "lit": 1.5,
    "ly_do": "…",
    "nguon": "…",
    "ulp_da_dung": 1
  },
  "water_ulp_operator": 1,
  "water_ulp_operator_at": "2026-10-28T07:30:00Z"
}
GET/api/v1/iot/devices/{deviceId}/output-config/channels

Danh sách kênh ngõ ra đã cấu hình (đọc bản backend đã persist từ echo dev_cfg — không phụ thuộc realtime)

Scope: iot.devices.viewThử trong API Explorer ▶

Tham số

Tham sốKiểuVị tríBắt buộcMô tả
deviceIdGUIDpathcó—

Ví dụ

curl -X GET "https://api-prod.nextfarm.vn/api/v1/iot/devices/<deviceId>/output-config/channels" \
  -H "Authorization: Bearer <ACCESS_TOKEN>"

Phản hồi mẫu

200 OK
[
  {
    "auto_mode": 1,
    "eh": 1,
    "em": 1,
    "idx": 1,
    "kind": 1,
    "label": "…",
    "manual_max_min": 1,
    "online": true,
    "out_a": 1,
    "out_b": 1,
    "reported_at": "2026-10-28T07:30:00Z",
    "role": "…",
    "sh": 1,
    "sm": 1,
    "thr_off": 1,
    "thr_on": 1
  }
]
GET/api/v1/iot/devices/{deviceId}/output-config/irrigation

Cấu hình hệ tưới đã gán: bơm/van vùng/van phân bón kể cả van Denso (đọc bản backend đã persist từ echo irr_out — không phụ thuộc realtime)

Scope: iot.devices.viewThử trong API Explorer ▶

Tham số

Tham sốKiểuVị tríBắt buộcMô tả
deviceIdGUIDpathcó—

Ví dụ

curl -X GET "https://api-prod.nextfarm.vn/api/v1/iot/devices/<deviceId>/output-config/irrigation" \
  -H "Authorization: Bearer <ACCESS_TOKEN>"

Phản hồi mẫu

200 OK
[
  {
    "idx": 1,
    "kind": "…",
    "label": "…",
    "manual_max_min_bo": 1,
    "mcv_id": 1,
    "meter_echo_at": "2026-10-28T07:30:00Z",
    "meter_id": 1,
    "meter_in": 1,
    "meter_ulp": 1,
    "meter_ulp_operator": 1,
    "meter_ulp_operator_at": "2026-10-28T07:30:00Z",
    "meter_ulp_pushed": 1,
    "meter_ulp_pushed_at": "2026-10-28T07:30:00Z",
    "out": 1,
    "parcel_id": "0190a3c2-5b1e-7c3d-8e4f-000000000001",
    "role": "…",
    "updated_at": "2026-10-28T07:30:00Z"
  }
]
GET/api/v1/iot/devices/{deviceId}/output-config/mcv-cfg

Trạng thái đồng bộ cài đặt van Denso: giá trị đã đặt (desired), bo đang giữ (reported, từ echo dev_cfg), ack và 1 trong 8 trạng thái

Scope: iot.devices.viewThử trong API Explorer ▶

Tham số

Tham sốKiểuVị tríBắt buộcMô tả
deviceIdGUIDpathcó—

Ví dụ

curl -X GET "https://api-prod.nextfarm.vn/api/v1/iot/devices/<deviceId>/output-config/mcv-cfg" \
  -H "Authorization: Bearer <ACCESS_TOKEN>"

Phản hồi mẫu

200 OK
{
  "ack": {
    "applied": {
      "count": 1,
      "count_max": 1,
      "ec_cap": 1.5,
      "ec_on": true,
      "ec_target": 1.5,
      "enabled": true,
      "fert": [
        1
      ],
      "k_ul": [
        1
      ],
      "liters": 1.5,
      "pump_fb": 1,
      "ratio": [
        1
      ],
      "types": [
        1
      ],
      "v": 1,
      "wait_min": 1
    },
    "applied_at": "…",
    "detail": "…",
    "err": "…",
    "ok": true,
    "seq": 1,
    "ts": 1
  },
  "desired": {
    "count": 1,
    "count_max": 1,
    "ec_cap": 1.5,
    "ec_on": true,
    "ec_target": 1.5,
    "enabled": true,
    "fert": [
      1
    ],
    "k_ul": [
      1
    ],
    "liters": 1.5,
    "pump_fb": 1,
    "ratio": [
      1
    ],
    "types": [
      1
    ],
    "v": 1,
    "wait_min": 1
  },
  "echo_at": "2026-10-28T07:30:00Z",
  "pushed_at": "2026-10-28T07:30:00Z",
  "reported": {
    "count": 1,
    "count_max": 1,
    "ec_cap": 1.5,
    "ec_on": true,
    "ec_target": 1.5,
    "enabled": true,
    "fert": [
      1
    ],
    "k_ul": [
      1
    ],
    "liters": 1.5,
    "pump_fb": 1,
    "ratio": [
      1
    ],
    "types": [
      1
    ],
    "v": 1,
    "wait_min": 1
  },
  "seq": 1,
  "state": "…"
}
GET/api/v1/iot/devices/{deviceId}/output-config/summary

Gói tóm tắt cấu hình ngõ ra server đã NHỚ (free_ports…) — trả JSON thô, không phụ thuộc realtime (hết chập chờn). 204 nếu server chưa từng nhận.

Scope: iot.devices.viewThử trong API Explorer ▶

Tham số

Tham sốKiểuVị tríBắt buộcMô tả
deviceIdGUIDpathcó—

Ví dụ

curl -X GET "https://api-prod.nextfarm.vn/api/v1/iot/devices/<deviceId>/output-config/summary" \
  -H "Authorization: Bearer <ACCESS_TOKEN>"

Phản hồi mẫu

Tuyến này chưa khai schema phản hồi — gọi thử trong API Explorer để xem hình dạng.

GET/api/v1/iot/devices/{deviceId}/schedules

Danh sách lịch hẹn giờ của thiết bị

Scope: iot.devices.viewThử trong API Explorer ▶

Tham số

Tham sốKiểuVị tríBắt buộcMô tả
deviceIdGUIDpathcó—

Ví dụ

curl -X GET "https://api-prod.nextfarm.vn/api/v1/iot/devices/<deviceId>/schedules" \
  -H "Authorization: Bearer <ACCESS_TOKEN>"

Phản hồi mẫu

200 OK
[
  {
    "device_id": "0190a3c2-5b1e-7c3d-8e4f-000000000001",
    "duration_minutes": 1,
    "duration_seconds": 1,
    "ec_cap": 1.5,
    "ec_target": 1.5,
    "enabled": true,
    "end_date": "2026-10-28",
    "family": "…",
    "field": "…",
    "id": "0190a3c2-5b1e-7c3d-8e4f-000000000001",
    "idx": 1,
    "label": "…",
    "last_fired_on": "2026-10-28",
    "name": "…",
    "note": "…",
    "start_date": "2026-10-28",
    "stop_mode": "…",
    "target_liters": 1,
    "time_of_day": "…",
    "value": 1,
    "weekdays": 1,
    "zone_id": "0190a3c2-5b1e-7c3d-8e4f-000000000001"
  }
]
GET/api/v1/iot/devices/{deviceId}/setpoints

GET /api/v1/iot/devices/{deviceId}/setpoints

Scope: iot.devices.viewThử trong API Explorer ▶

Tham số

Tham sốKiểuVị tríBắt buộcMô tả
deviceIdGUIDpathcó—

Ví dụ

curl -X GET "https://api-prod.nextfarm.vn/api/v1/iot/devices/<deviceId>/setpoints" \
  -H "Authorization: Bearer <ACCESS_TOKEN>"

Phản hồi mẫu

200 OK
{
  "alarm_temp": 1,
  "auto_fan": 1,
  "auto_shade": 1,
  "auto_winch1": 1,
  "auto_winch2": 1,
  "device_id": "0190a3c2-5b1e-7c3d-8e4f-000000000001",
  "fert1_rate": 1,
  "fert2_rate": 1,
  "flow_pulse_ml": 1,
  "mcv1": 1,
  "mcv2": 1,
  "mcv3": 1,
  "mcv4": 1,
  "mcv5": 1,
  "mcv6": 1,
  "sched_s_eh": 1,
  "sched_s_em": 1,
  "sched_s_sh": 1,
  "sched_s_sm": 1,
  "sched_w_eh": 1,
  "sched_w_em": 1,
  "sched_w_sh": 1,
  "sched_w_sm": 1,
  "thresh_fan_hum_off": 1,
  "thresh_fan_hum_on": 1
}
GET/api/v1/iot/devices/{id}

Chi tiết thiết bị IoT — đầy đủ fields cho 4-tab detail page

Scope: iot.devices.viewThử trong API Explorer ▶

Tham số

Tham sốKiểuVị tríBắt buộcMô tả
idGUIDpathcó—

Ví dụ

curl -X GET "https://api-prod.nextfarm.vn/api/v1/iot/devices/<id>" \
  -H "Authorization: Bearer <ACCESS_TOKEN>"

Phản hồi mẫu

200 OK
{
  "created_at": "2026-10-28T07:30:00Z",
  "customer_code": "…",
  "description": "…",
  "device_code": "…",
  "device_type": "…",
  "dong_ho_nuoc": "…",
  "firmware_version": "…",
  "id": "0190a3c2-5b1e-7c3d-8e4f-000000000001",
  "installed_at": "2026-10-28",
  "is_online": true,
  "last_heartbeat": "2026-10-28T07:30:00Z",
  "location_lat": 1.5,
  "location_lng": 1.5,
  "mac_address": "…",
  "manual_max_min": 1,
  "mcv_valve_variant": "…",
  "metadata_json": "…",
  "mqtt_topic_prefix": "…",
  "name": "…",
  "niche": "…",
  "parcel_ids": [
    "0190a3c2-5b1e-7c3d-8e4f-000000000001"
  ],
  "provision_status": "…",
  "provisioned_at": "2026-10-28T07:30:00Z",
  "scene_kind": "…",
  "shared_in_zone": true
}
GET/api/v1/iot/emergency-stop

Khoá dừng khẩn đang hiệu lực (activeOnly=true, mặc định) hoặc 20 lần gần nhất

Scope: iot.devices.viewThử trong API Explorer ▶

Tham số

Tham sốKiểuVị tríBắt buộcMô tả
activeOnlyboolquerykhông—

Ví dụ

curl -X GET "https://api-prod.nextfarm.vn/api/v1/iot/emergency-stop" \
  -H "Authorization: Bearer <ACCESS_TOKEN>"

Phản hồi mẫu

200 OK
[
  {
    "active": true,
    "already_active": true,
    "device_ids": [
      "0190a3c2-5b1e-7c3d-8e4f-000000000001"
    ],
    "failed_count": 1,
    "id": "0190a3c2-5b1e-7c3d-8e4f-000000000001",
    "parcel_id": "0190a3c2-5b1e-7c3d-8e4f-000000000001",
    "reason": "…",
    "release_note": "…",
    "released_at": "2026-10-28T07:30:00Z",
    "released_by": "0190a3c2-5b1e-7c3d-8e4f-000000000001",
    "repeat_count": 1,
    "results": [
      {
        "command_id": "0190a3c2-5b1e-7c3d-8e4f-000000000001",
        "device_code": "…",
        "device_id": "0190a3c2-5b1e-7c3d-8e4f-000000000001",
        "error": "…",
        "error_code": "…",
        "family": "…",
        "idx": 1,
        "label": "…",
        "ok": true
      }
    ],
    "scope": "…",
    "stopped_schedules": 1,
    "triggered_at": "2026-10-28T07:30:00Z",
    "triggered_by": "0190a3c2-5b1e-7c3d-8e4f-000000000001"
  }
]
GET/api/v1/iot/reports/irrigation-logs

Danh sách lịch sử tưới (phân trang)

Từng chu kỳ tưới có phân trang cho bảng Lịch sử tưới. Lọc theo deviceId / zoneId / from / to. Sắp xếp mới nhất trước. Mặc định 7 ngày gần nhất, pageSize=20.

Scope: iot.telemetry.viewThử trong API Explorer ▶

Tham số

Tham sốKiểuVị tríBắt buộcMô tả
deviceIdGUIDquerykhông—
zoneIdGUIDquerykhông—
fromdatequerykhông—
todatequerykhông—
pageintquerykhông—
pageSizeintquerykhông—

Ví dụ

curl -X GET "https://api-prod.nextfarm.vn/api/v1/iot/reports/irrigation-logs" \
  -H "Authorization: Bearer <ACCESS_TOKEN>"

Phản hồi mẫu

200 OK
{
  "items": [
    {
      "cycle_at": "2026-10-28T07:30:00Z",
      "device_code": "…",
      "device_id": "0190a3c2-5b1e-7c3d-8e4f-000000000001",
      "duration_sec": 1,
      "fert_mask": 1,
      "fert_ml": [
        1
      ],
      "fert_sec": 1,
      "trigger": 1,
      "trigger_source": "…",
      "volume_l": 1.5,
      "zone_id": "0190a3c2-5b1e-7c3d-8e4f-000000000001",
      "zone_mask": 1
    }
  ],
  "page": 1,
  "page_size": 1,
  "total": 1
}
GET/api/v1/iot/reports/irrigation-summary

Tổng hợp báo cáo tưới tiêu

Tổng lít nước đã tưới + số lệnh điều khiển + tỷ lệ thành công trong khoảng thời gian. Mặc định 7 ngày gần nhất.

Scope: iot.telemetry.viewThử trong API Explorer ▶

Tham số

Tham sốKiểuVị tríBắt buộcMô tả
deviceIdGUIDquerykhông—
fromdatequerykhông—
todatequerykhông—

Ví dụ

curl -X GET "https://api-prod.nextfarm.vn/api/v1/iot/reports/irrigation-summary" \
  -H "Authorization: Bearer <ACCESS_TOKEN>"

Phản hồi mẫu

200 OK
{
  "command_count": 1,
  "from": "2026-10-28T07:30:00Z",
  "success_command_count": 1,
  "success_rate": 1.5,
  "to": "2026-10-28T07:30:00Z",
  "total_volume_l": 1.5
}
GET/api/v1/iot/reports/irrigation-summary/export

Xuất báo cáo tưới tiêu ra Excel

Bảng chi tiết từng chu kỳ tưới trong khoảng thời gian. Mặc định 7 ngày gần nhất.

Scope: iot.telemetry.viewThử trong API Explorer ▶

Tham số

Tham sốKiểuVị tríBắt buộcMô tả
deviceIdGUIDquerykhông—
fromdatequerykhông—
todatequerykhông—

Ví dụ

curl -X GET "https://api-prod.nextfarm.vn/api/v1/iot/reports/irrigation-summary/export" \
  -H "Authorization: Bearer <ACCESS_TOKEN>"

Phản hồi mẫu

Tuyến này chưa khai schema phản hồi — gọi thử trong API Explorer để xem hình dạng.

GET/api/v1/iot/schedules/upcoming

Các cữ tưới sắp chạy của cả trại (gộp theo cữ)

from (yyyy-MM-dd, mặc định hôm nay giờ VN), days 1–7, device_id tuỳ chọn.

Scope: iot.devices.viewThử trong API Explorer ▶

Tham số

Tham sốKiểuVị tríBắt buộcMô tả
fromdatequerykhông—
daysintquerykhông—
device_idGUIDquerykhông—

Ví dụ

curl -X GET "https://api-prod.nextfarm.vn/api/v1/iot/schedules/upcoming" \
  -H "Authorization: Bearer <ACCESS_TOKEN>"

Phản hồi mẫu

200 OK
{
  "items": [
    {
      "anchor_schedule_id": "0190a3c2-5b1e-7c3d-8e4f-000000000001",
      "date": "2026-10-28",
      "device_id": "0190a3c2-5b1e-7c3d-8e4f-000000000001",
      "device_name": "…",
      "duration_seconds": 1,
      "exception_id": "0190a3c2-5b1e-7c3d-8e4f-000000000001",
      "fired": true,
      "name": "…",
      "run_once": true,
      "skipped": true,
      "time": "…",
      "valves": [
        "…"
      ]
    }
  ]
}
GET/api/v1/iot/sensor-readings

Tra cứu số liệu cảm biến theo khoảng thời gian

Lọc theo deviceId / zoneId / from / to. Sắp xếp mới nhất trước. Mặc định pageSize=200.

Scope: iot.telemetry.viewThử trong API Explorer ▶

Tham số

Tham sốKiểuVị tríBắt buộcMô tả
deviceIdGUIDquerykhông—
zoneIdGUIDquerykhông—
fromdatequerykhông—
todatequerykhông—
pageintquerykhông—
pageSizeintquerykhông—

Ví dụ

curl -X GET "https://api-prod.nextfarm.vn/api/v1/iot/sensor-readings" \
  -H "Authorization: Bearer <ACCESS_TOKEN>"

Phản hồi mẫu

200 OK
{
  "items": [
    {
      "activity_pct": 1.5,
      "air_humidity_pct": 1.5,
      "air_humidity_pct1": 1.5,
      "air_humidity_pct2": 1.5,
      "air_humidity_pct3": 1.5,
      "air_temp_c": 1.5,
      "air_temp_c1": 1.5,
      "air_temp_c2": 1.5,
      "air_temp_c3": 1.5,
      "co2_ppm": 1.5,
      "device_code": "…",
      "device_id": "0190a3c2-5b1e-7c3d-8e4f-000000000001",
      "do_mg_l": 1.5,
      "ec_us_cm": 1.5,
      "feed_level_pct1": 1.5,
      "feed_level_pct2": 1.5,
      "feed_weight_kg1": 1.5,
      "feed_weight_kg2": 1.5,
      "fert_ec_us_cm": 1.5,
      "fert_ph": 1.5,
      "fw_ver": "…",
      "id": "0190a3c2-5b1e-7c3d-8e4f-000000000001",
      "light_lux": 1.5,
      "nh3_ppm": 1.5,
      "orp_mv": 1.5
    }
  ],
  "page": 1,
  "page_size": 1,
  "total": 1
}
GET/api/v1/iot/sensor-readings/latest

Giá trị mới nhất của từng thiết bị (30 phút gần nhất)

Dùng cho Dashboard thời gian thực. Lọc theo zoneId tùy chọn.

Scope: iot.telemetry.viewThử trong API Explorer ▶

Tham số

Tham sốKiểuVị tríBắt buộcMô tả
zoneIdGUIDquerykhông—

Ví dụ

curl -X GET "https://api-prod.nextfarm.vn/api/v1/iot/sensor-readings/latest" \
  -H "Authorization: Bearer <ACCESS_TOKEN>"

Phản hồi mẫu

200 OK
[
  {
    "activity_pct": 1.5,
    "air_humidity_pct": 1.5,
    "air_humidity_pct1": 1.5,
    "air_humidity_pct2": 1.5,
    "air_humidity_pct3": 1.5,
    "air_temp_c": 1.5,
    "air_temp_c1": 1.5,
    "air_temp_c2": 1.5,
    "air_temp_c3": 1.5,
    "co2_ppm": 1.5,
    "device_code": "…",
    "device_id": "0190a3c2-5b1e-7c3d-8e4f-000000000001",
    "do_mg_l": 1.5,
    "ec_us_cm": 1.5,
    "feed_level_pct1": 1.5,
    "feed_level_pct2": 1.5,
    "feed_weight_kg1": 1.5,
    "feed_weight_kg2": 1.5,
    "fert_ec_us_cm": 1.5,
    "fert_ph": 1.5,
    "fw_ver": "…",
    "id": "0190a3c2-5b1e-7c3d-8e4f-000000000001",
    "light_lux": 1.5,
    "nh3_ppm": 1.5,
    "orp_mv": 1.5
  }
]
GET/api/v1/iot/setup/progress

Tiến trình onboarding thiết bị IoT suy từ dữ liệu hiện có

Scope: iot.devices.viewThử trong API Explorer ▶

Tham số

Không có tham số.

Ví dụ

curl -X GET "https://api-prod.nextfarm.vn/api/v1/iot/setup/progress" \
  -H "Authorization: Bearer <ACCESS_TOKEN>"

Phản hồi mẫu

200 OK
{
  "completed": 1,
  "steps": [
    {
      "count": 1,
      "detail": "…",
      "done": true,
      "key": "…",
      "warning": "…"
    }
  ],
  "total": 1
}