Hướng dẫn
Bảng điều khiển IoT cho trại
Hiện số đo cảm biến mới nhất, lịch sử và cảnh báo của một trại trên màn hình của bạn — kéo định kỳ + nhận cảnh báo tức thì qua webhook.
1. Tạo API key chỉ đọc IoT
Chủ trại tạo khoá với scope iot.devices.view, iot.telemetry.view, iot.alerts.view.
2. Liệt kê thiết bị và số đo mới nhất
Gọi mỗi 1–5 phút; hiện is_online để biết thiết bị nào mất kết nối.
Lệnh mẫucurl https://api-prod.nextfarm.vn/api/v1/iot/devices -H "Authorization: Bearer nfk_..." curl https://api-prod.nextfarm.vn/api/v1/iot/sensor-readings/latest -H "Authorization: Bearer nfk_..."3. Vẽ biểu đồ lịch sử
Lịch sử theo thiết bị hoặc vùng trong khoảng thời gian.
Lệnh mẫucurl "https://api-prod.nextfarm.vn/api/v1/iot/sensor-readings?deviceId=<device_id>&from=2026-10-27&to=2026-10-28" -H "Authorization: Bearer nfk_..."4. Nhận cảnh báo tức thì
Đăng ký webhook iot.alert.raised và iot.device.offline thay vì kéo liên tục; verify signature trước khi tin.