Browse developer docs

Smart Farm

Read farm servers, IoT device inventory, irrigation status, and operation history.

Integration workflow

Build an irrigation dashboard. Discover the farm server and devices, show which readings are current, and reconcile command acknowledgement against operation logs and device state.

  1. Find the farm server
  2. org_id + fs_snList devices
  3. Device ID + model typeRead status or history
Example irrigation monitoring flow based on the farm-server, device-list, status and history services.

Compatibility. Service support varies by device type. Inventory and batch status cover electric valves and smart switches. Check the device type table for controllers and attachments. Treat long farm and scene IDs as strings.

List IoT devices

POST /open/service

serviceName=farm-device-list

Obtain org_id from your authorized farm and the server serial through farm-server-list. Check lastTime before treating the returned device state as current.

Set XAG_APP_UID and XAG_APP_SECRET in your server environment. Substitute the sample IDs with authorized values.

Request
# Requires curl 7.87+, Python 3 and OpenSSL.
: "${XAG_APP_UID:?Set XAG_APP_UID}"
: "${XAG_APP_SECRET:?Set XAG_APP_SECRET}"
timestamp=$(python3 -c 'import time; print(time.time_ns() // 1000000)')
token=$(printf "%s" "$XAG_APP_UID$timestamp$XAG_APP_SECRET" | openssl dgst -sha1 -r | cut -d " " -f 1)

curl --silent --show-error --fail-with-body --max-time 30 --request POST \
  'https://open.xa.com/open/service' \
  --url-query 'serviceName=farm-device-list' \
  --url-query "appUid=$XAG_APP_UID" \
  --url-query "timestamp=$timestamp" \
  --url-query "token=$token" \
  --header 'Content-Type: application/json' \
  --data '{
  "org_id": "YOUR_FARM_ID",
  "fs_sn": "YOUR_FARM_SERVER_SN",
  "pageNo": 1,
  "pageSize": 20
}'
Illustrative response
{
  "status": 200,
  "success": true,
  "data": [
    {
      "deviceId": "example-valve",
      "device_name": "Example valve",
      "model_type": 16,
      "lastTime": 1788200000
    }
  ]
}

Review request signing

Service reference

All services use /open/service with the common signed query parameters. Additional fields are listed below. Open an operation for its parameters, examples and response notes.

List IoT devices

POSTfarm-device-list

Required service parameters
org_id, fs_sn, pageNo, pageSize

Cache deviceId and model_type for follow-up reads.

View operation

Read the command log

POSTfarm-device-operate-log

Required service parameters
org_id, fs_sn, beginTimeStamp, endTimeStamp, pageNo, pageSize

Use Unix seconds. Status 103 is receipt acknowledged, while 108 indicates a callback was received.

View operation

Read farm facilities

POSTfarm-info-list

Required service parameters
org_id, fs_sn, modules

The default module list is ["facility"]. Optional time bounds are seconds.

View operation

Submit an IoT command

POSTfarm-device-action

Changes state

Required service parameters
org_id, fs_sn, device_id, model_type, action_name, params

The command and parameters depend on the hardware. Confirm execution using the command log and device state.

View operation

Change device wake mode

POSTfarm-device-switch-work-model

Changes state

Required service parameters
org_id, fs_sn, device_type, work_model

Applies by device type. Use 1 for smart wake or 2 for fast wake.

View operation

List irrigation scenes

POSTfarm-device-smart-list

Required service parameters
org_id, fs_sn, page_no, page_size, type

Choose the documented scene type. The scene property schema depends on that type.

View operation

Control an irrigation scene

POSTfarm-device-smart-control

Changes state

Required service parameters
org_id, fs_sn, control_type, scene_id

Some irrigation starts require extent with a level device and a water-level or duration target. Match the parameters to the selected control type.

View operation

Cancel a pending device command

POSTfarm-device-manage-cancel-action

Changes state

Required service parameters
org_id, fs_sn, device_id, oper_id

Use the operation ID from the log. Recheck device state after cancellation.

View operation
Location
Richmond Hill, Ontario, Canada