Download a schedule?

In case it interests anyone. i wrote a little script for google app script engine that lets you populate a spreadsheet with all rachios in your account , each zone and their settings. I just typed it up after dinner tonight so its a bit rough. But basically put your API key in cell A:2 (i used A1 to put a label that this was my API key) and go to google script engine and put this into file and run the function GetRachioZoneSettings() and it will populate that same sheet as your API key is in with each zone and their settings.

I find it easier to do this for a quick overview of all my zone settings than to head in to the GUI to validate.
I’ll build it out and make it look prettier (and pull in all zone settings) over the next couple of days, but i hope some of you will find use in this. To get the API key login to the web and click on your account “get api key”. Just paste that text in Cell A2 on the active sheet and you’ll be golden.

I haven’t decided if i want to swap rows/columns yet but just getting real time data into google sheet is great. Trying to decode the json to see what all the data represents. Much is obvious but some things are not.

ps. the forum may reformat the text below and make it impossible to paste. if so just pm me and i can mail it to you. This does not do any modifications to any settings, it is only doing a GET operation on your device(s). I spelled out things a bit more than needed to make this more accessible for people not familiar with more complex data structures and functions.

code:

function fetchAPIKey(){
  var f = SpreadsheetApp.getActiveSheet().getRange(1, 2).getValue();
  Logger.log(f);
  return(f);
}

function GetPersonID(Key) {
  var url = "https://api.rach.io/1/public/person/info";
  var headers = {
    "contentType": "application/json",
    "headers":{"Authorization": "Bearer " + Key}
  };
  var response = UrlFetchApp.fetch(url, headers);
  var PersonID = JSON.parse(response.getContentText());
  return (PersonID.id)
}

function length(obj) {
    return Object.keys(obj).length;
}



function GetRachioZoneSettings(){
  var APIKey = fetchAPIKey();
  var PersonID = GetPersonID(APIKey);
  var url = "https://api.rach.io/1/public/person/" + PersonID;
  var headers = {
    "contentType": "application/json",
    "headers":{"Authorization": "Bearer " + APIKey}
  };
  

  var response = UrlFetchApp.fetch(url, headers);
  var DeviceID = JSON.parse(response.getContentText());
  
  // Setup the sheet
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheets = ss.getSheets();
  var sheet = ss.getActiveSheet();

  var dataSet = DeviceID;
  var rows = [],
      data;
  
  var DeviceCount;
  DeviceCount = length(dataSet.devices);
  Logger.log("devices = %s", DeviceCount);
  
  var Zones;
  var rows = [];
  var sheet = SpreadsheetApp.getActiveSheet();
  var arr = [];
  var c = [];
 
 var RowNum = 0;
 
 var c = [] ;
 // Do the headers first so we know the data
 c[RowNum] = new Array(9);
 c[RowNum] = ["Controller Name", "Zone Number", "Zone Name", "Inches per Hour", "Crop", "Crop Coefficient", "Root Depth", "Depletion", "Efficiency" ];
// c[RowNum] = ["Controller Name", "Zone Number", "Zone Name", "Inches per Hour", "Crop"];
RowNum++;
 
 //Iterate on each rachio device
 for ( i = 0; i < DeviceCount; i++){
    Zones = length(dataSet.devices[i].zones);
    //iterate on the zones in each rachio device for this account
    for ( k = 0; k < Zones; k++){    
       // only output to the spreadsheet zones that are enabled
       if(dataSet.devices[i].zones[k].enabled == true){
         c[RowNum] = new Array(4);
         var n = 0;
         c[RowNum][n++] = dataSet.devices[i].name, 
         c[RowNum][n++] = dataSet.devices[i].zones[k].zoneNumber
         c[RowNum][n++] = dataSet.devices[i].zones[k].name;         
         c[RowNum][n++] = dataSet.devices[i].zones[k].customNozzle.inchesPerHour;
         c[RowNum][n++] = dataSet.devices[i].zones[k].customCrop.name;
         c[RowNum][n++] = dataSet.devices[i].zones[k].customCrop.coefficient;
         c[RowNum][n++] = dataSet.devices[i].zones[k].rootZoneDepth;
         c[RowNum][n++] = dataSet.devices[i].zones[k].managementAllowedDepletion;
         c[RowNum][n++] = dataSet.devices[i].zones[k].efficiency;
         RowNum++;
       }
    }
  }
  
  destinationRange = sheet.getRange(2, 1, RowNum, n);
  destinationRange.setValues(c);   
}