{
  "id": "vn.agritrace.irrigation-controller",
  "version": "1.0.0",
  "vendor": "generic",
  "category": "irrigation",
  "description": "Local irrigation and fertigation controller (valves, pump, dosing, grow lights). The platform sends it signed, expiring commands: run one zone for a bounded time and volume, or lease it a program until a deadline (at most a day): up to 48 steps, each running one zone from start_s seconds after the controller's local midnight for a bounded time and volume. The controller decides locally whether to run them (interlocks, manual override, its own limits) and reports what it accepted and what it delivered (valve and pump state, grow-light level, water and dose volumes); the cloud never opens or closes a valve directly.",
  "driver": "irrigation-controller",
  "connectivity": ["mqtt-native"],
  "produces": [
    {"capability": "valve.state"},
    {"capability": "pump.state"},
    {"capability": "light.level"},
    {"capability": "water.volume_delivered"},
    {"capability": "dose.volume"}
  ],
  "events": [],
  "requires": [],
  "mobility": "fixed",
  "commands": {
    "run_zone": {
      "params": {
        "zone": {"type": "integer", "min": 1, "max": 16},
        "duration_s": {"type": "integer", "min": 1, "max": 3600, "unit": "s"},
        "max_volume_l": {"type": "number", "min": 1, "max": 20000, "unit": "L"}
      },
      "required": ["zone", "duration_s", "max_volume_l"],
      "actuation": true,
      "max_expiry_s": 300
    },
    "set_program": {
      "params": {
        "program": {
          "type": "object",
          "properties": {
            "steps": {
              "type": "array",
              "max_items": 48,
              "items": {
                "type": "object",
                "properties": {
                  "zone": {"type": "integer", "min": 1, "max": 16},
                  "start_s": {"type": "integer", "min": 0, "max": 86399, "unit": "s"},
                  "duration_s": {"type": "integer", "min": 1, "max": 3600, "unit": "s"},
                  "max_volume_l": {"type": "number", "min": 1, "max": 20000, "unit": "L"}
                },
                "required": ["zone", "start_s", "duration_s", "max_volume_l"]
              }
            }
          },
          "required": ["steps"]
        },
        "program_version": {"type": "integer", "min": 1, "max": 2147483647},
        "valid_until_s": {"type": "integer", "min": 60, "max": 86400, "unit": "s"}
      },
      "required": ["program", "program_version", "valid_until_s"],
      "actuation": true,
      "max_expiry_s": 300
    }
  }
}
