Download a schedule?

Great formulas. i got them into a spreadsheet and played around with the rachio to sanity test my spredsheet.

One of things i found interesting is that when i go to the rachio app to check the values for crop evortranspiration, they appear to follow linearly the crop co-efficient factor. If i set the crop coefficient factor to 95, and go to the soil moisture tab to see the crop evotranspiration i get the following for one of my zones: 0.13 0.18 0.16 0.15 0.19 0.21 0.21
The number seems reasonable (1.23 at 95% crop coefficency).

When i set my crop co-efficiency to 45 and check the crop evotranspiration i get the following 0.13 0.18 0.16 0.08 0.1 0.11 0.11

Its not exactly half, but it seems to be exactly proportional vs the input. I assume that the historical days doesn’t change, and the calculation is only forward looking

    |0.13|0.18|0.16|0.15|0.19|0.21|0.21| 95%
    |--- |--- |--- |--- |*** |--- |--- | 
    |0.13|0.18|0.16|0.08|0.10|0.11|0.11| 45%

I put asterisks on todays date to make that point.
This is just a guess on my part, i don’t know how to make rachio calculate farther out to see the long term effect.

Anyway, i am getting a decent handle on the rachio and what it actually does.

As I said above:

So, yes, Crop Evapotranspiration is directly proportional to the Crop Coefficient: if you increase the Crop Coefficient 20%, Rachio will calculate that each day needs 20% more water.

When using Flex Daily, Rachio will only calculate out about 3 weeks into the schedule. It is using the FORECAST weather for that time, not historic data (although I’m sure forecasts that far in advance consider historic data as well). In any event, it’s the best guess it has at this time of the weather for the future, even including estimated rainfall. As the dates get closer, the forecast gets more accurate, and eventually Rachio uses the actual rainfall for the previous day, estimated rainfalls for following days, and the most accurate temperatures. Pretty neat system, actually. :wink:

1 Like

When i click on a schedule and see “water duration”
That correlates strongly (ie the numbers are identical) with the current model that i have in my spreadsheet of how much water the rachio will provide each watering session per zone.

I assume this is what it is?
Since minutes of watering per zone can be changed in this dialogue , is this an override that lets the user obsolete the calculations?

Also, many crops have different coefficient factors depending on dormancy, growth phase, flowering, fruiting etc. Does rachio adjust any of that or is the coefficient fixed for the year and i just need to pick an average?

Grass isn’t as much impacted by this as flowers and fruit trees according the the articles i read from uc davis. It would be pretty dang neat if the coefficiencts also adjusts with the season, but to do that we need a way to track each specific crop -not just crop type.

My spreadsheet is glorious by the way. it perfectly calculates what rachio would do.
It sucks a bit to hand copy over the crop evapo-transpiration to make the numbers make sense, but besides that i got the model well understood. Lots of manual labor to cross reference my spreadsheet model with what rachio actually is planning to do in order to validate the model with the rachio. Maybe i can build a screen scraper to fetch it to my spreadsheet.

what i have done with this is setup triggers. i read my watering companies flow sensor continously and i have taken my mathematical model and use that to drive alerts at specific tresholds from readings of the water meter so that if i start consuming water outside the model + household use, i get a real alert.
But more importantly, i have a good way to start systematically reduce my water bill by targeting crops to be replanted for more efficient crops.

par

The only two variables at the output are valve duration and period, modified by the weather. Why do you need so many input values (crop efficiency, root depth, allowed depletion, nozzle inches) to calculate such a simple two-parameter output? They must be contradictory.

How do you calculate the time the valve is turned on for?
That is a function of A) root depth, b) depletion setting, c) soil type, D) efficiencies in your watering system, E) how much output your nozzle provides and F) what type of crop you have eg the coefficients and finally Yes the weather.

Of these weather should be the only externally variable factor. But i wanted to learn the math and science behind the rachio. Not the complicated although the language used is very specific to those skilled in the art.

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);   
}

@rraisley I have a question that maybe you can help me with.
Here is a google spreadsheet i’ve created.

I’ve just taken a few of the zones in my yard, but they are representative.
The data from this spreadsheet is something i directly feed into it from the Rachio API via google Apps script engine. I’ve double checked the values that are relevant vs. the GUI on my phone and the gui agrees with the output from Rachios API’s.

What i am trying to figure out is why i am getting a minor difference (under 2%) in runtime (eg. minutes a valve is running based on zone configuration that i am calculating in this spreadsheet) vs what rachio is reporting as its calculated value)?

I tried to theorize that it was a rounding error, but i just can’t see it. The cells in the sheet contains raw rachio api data and you can expand it to 9 decimals if you want.

Do i have a math error in my calculation somewhere? I double checked the Scale Factor math but i don’t see it there. The others doesn’t seem that wrong either.

Would you mind taking a peak and tell me what i got wrong?

Its not that i’m worried about the error given how small it is, but i also don’t like the idea of my math not being right. A bigger error could really mess up things downstream.

i’m working on building a webhook for this, but i want to make sure i am getting the basics right.

thanks!

1 Like

Very nice! I was thinking of doing the same thing, compiling it from various posts, etc. Now, I do not have to. I did not take a close look as I believe others would be better suited.

Thomas, give me a day or two and I’ll get you a script that you run in a Google spreadsheet that pull home all your zone configuration data. I just want to make sure my math is 100% before I post it.

1 Like

Perfect, I already downloaded what you have as an XLS and can do things with the API, but you will save me more time. I would like to be able to play around with numbers to see how it changes, etc. Thank you!

Okay, I played a bit. Where do the following come from in the UI?

  1. Saturated depth of water
  2. Depth of water
  3. Run Time from rachio API (json field zone.runtime)

It appears the following do not come down or used in the calculation?

  1. Soil type
  2. Slope

I will have to get the values through the API to check it out. The last time I ran it for that low of time (the first part of last year), it stressed my grass out for not getting enough water. Maybe I do not have some thing set correctly in the spreadsheet or my app.

1 and 2 are questions I just asked in the API section of the forum. Not sure what they are, i speculate that they may be part of the moisture report for a zone but I hope someone will share what they are in that thread. I do not use them in calculation but kept them in the sheet as I’m investigating them.

3 is there run time for a zone. I think it’s what is reported in the schedule as runtime. I calculated that out in the sheet and compare my calculations based on zone settings vs what the rachio computes. To me this is a sanity check, maybe I’ll remove it.

I do not know that I would personally remove anything, especially the runtime. It would be good to see that.

I don’t see anything wrong with your math; it all appears correct, near as I can tell.

I can only guess where the difference between your times and Rachio’s are (but I think it’s a good guess): It appears to me that when defining inches of water applied (and possibly all values of inches of water, including Crop Evapotranspiration, Rain, etc.), Rachio is using an 2 decimal value, or an amount rounded off to 2 decimals. Depending on what language they use for their code, many times variables are specified, not just as Integers or Floats (variable decimal points), but values with specific decimal points, in this case accurate to 0.01". All the values they /show/ are displayed only to the nearest 0.01". I think their calculations, probably due to the variable definition, rather than a specific function to round them, rounds the value to that. I think that’s common to C+/++, isn’t it? You declare a variable with a value, and that determines the accuracy (decimal places) of the variable? Haven’t done C for quite a while, but that seems familiar to me.

For your Depth of Water, you use 0.44" and 0.38" (the values shown within the program), but you /calculate/ these values as 0.443333333" (displayed as 0.443) and 0.375". Guess what? The differences are the same as you’re reporting with the times!

Zone 5 doesn’t quite turn out that way, but it’s pretty close.

Also realize that no one but you can see the actual Rachio times using the API; we real world people have to look at the displayed values, which is only to the nearest minute, and may even be rounded incorrectly. :wink:

Thanks for checking, I suspected rounding errors but wanted to be certain.

. All values seems to be with a high precision, Java is 6 digits and c is 7 (assuming some form of ansi c ). I process the data in a spreadsheet and I assume they compute in double precision. I do the microseconds to seconds in single precision but that can’t create these types of errors. Under 2% deviation is fine with me.

I really enjoy fetching the data using an app script and populating a sheet with the data. It makes it easy to compare zones and scan for errors. I found an error in a zone config right away at a glance of the page (the soil type was set to clay but water per inch/inch had accidentally been adjusted to 0.2 -probably a fat finger on that app screen).

Again, thanks for checking my math!

I just told you where the error/problem was, didn’t I? It’s not in your spreadsheet, it’s in Rachio’s calculations, I’m certain. Their inches of water are being rounded, after calculation, to the nearest 0.01". Before the next calculation is done. It’s pretty much the only thing it can be, as we know the math.

:smiley: I tried to agree with you and thank you. Intent isn’t always best conveyed via the internet (and frequently I’m not that great at expressing gratitude either).

I am seeing that the API returns some things exactly how I entered it, for example:

“customNozzle”: {
“name”: “ROTARY_NOZZLE”,
“inchesPerHour”: 0.7
},

and some things with much higher precision:

"efficiency": 0.800000011920929,

Are you massaging the data at all from how it comes in from the API? I do not know how Rachio stores the data internally (but would guess it to be float/double), what language(s) they might be using, nor if they change precision on output to JSON (not uncommon to do). I am a software guy and know C/C++/C#/Java were mentioned. Most languages store according to integer, float, double, etc. and if they are rounded for output, that is typically done with a function/method. Fixed point is harder to work with on most languages.

I’m using javascript (google calls it “apps script” but its basically javascript) that i run as an extension to a spreadsheet via the google apps engine.

Once the JSON is in the javascript i don’t really massage it anyway. i output it to cells in the precision it is stored in javascript. Then it becomes limited to whatever precision google spreadsheets has. I’m sure its precision is at least 6 digits.

In sheets i adjusted the visible precision to two or three digits, but you can alter that in the cell to show you whatever precision you want. if you do math using the cell as an input you get the full precision per the usual spreadsheet rules.

I don’t think precision will be an issue. :slight_smile:

I got to do some work today, but tonight i hope to get some time to add the watering schedules to the script and publish it for those who want to see it in a spreadsheet form. Its pretty easy to push configs back to rachio from spreadsheets as well, that is not my goal but it should be super easy to do, maybe i’ll take an unused zone and hack that in so other people at least get a stub.

On the docket tonight is to I need to finish cell formatting from within the script, build an entity table so i can use zone ID’s)as keys into a 2D array for mapping zone configs to schedule configs. Given that it was about 7 hours since i wrote my absolute first line of javascript and i’ve never used google apps engine, i think my productivity should be increased by today. Or at least i hope so. This language is pretty cute.

par

It does sound like precision should not be an issue on your end. It still could be something on the JSON output side of the API. Good work.