ISY-99i Generic Calendar Using Programs and Variables: Difference between revisions
No edit summary
No edit summary
|Line 10:||Line 10:|
== The Variables ==
== The Variables ==
There are variables that by the user.
* ''' ''' for
* ''' ''' -
for the of .
* ''' ''' -
of water the
to the .
* ''' ''' is to the the .
'variables the . used the program the .
* of the a of and .
* ''' ''' to the day .
* of that the .
Revision as of 16:56, 20 September 2011
The Basic Idea of this Series of Programs
ISY’s date function is a bit limited. As the firmware currently supports, there is no direct way to use it for recurring events except related to day of the week. For example, you can have something happen every Monday, or every Monday and Tuesday, but you can’t set up something to run on the third Tuesday of every month, or every 3 rd day, or on even days of the month, or every July 4th, I think you get the idea.
Working outside the built-in firmware, a series of programs using the variable function can solve this problem. The following series of programs starts off with a single program that triggers at midnight and then cascades through a series of additional programs using “run if”, “run then”, and “run else” commands to update a set of variables each day at midnight to report the current day, day of month, day of year, month, year, and week of month. In addition, there are counters which follow an every other, every third, every fourth, and every fifth schedule. Also, there is a program that sets a variable according to whether it is an even day or an odd day. Finally, a series of programs sets a variable to 1 on several US holidays. Some of these programs can be expanded upon such as the holiday series or the ever x number of days or weeks programs to suit your needs.
There are a number of variables that need to be created by the user. By convention, variables that have an “i” to start the name are integer variables and an “s” indicates a state variable.
- iDay.of.Year starts with 1 on Jan1 and counts to 365 (or 366 on leap year). This variable is a less used variable that is mostly included for completeness as it is rare that someone needs to know what day of the year it is.
- iDay.of.Month is how many days into the month we are (i.e. the 5th of the month).
- iYear is simply the current year.
- iLeap.Year counts 0,1,2,3,0,1,2,3,etc where 3 means that we are in a leap year. This is primarily a variable used to keep the other variables in check since rarely do people have cause to include this directly in a program.
- iDay.of.Week starts with 1 on Monday and counts through to 7 on Sunday. This variable is used to cross check the status of the variables against ISY’s internal day of week function so as to alert you if it gets out of sync. You do not need this variable since ISY has this function built-in but you can choose to use it instead of the ISY’s built-in day function and get the same result.
- iMonth is simply the current month starting with 1 for Jan.
- iDay.Counter gets one number higher everyday without regard to the start of a new month or year. The primary purpose of this variable is to serve as a basis for the every x number of days/weeks programs since those programs require a reference that always increases by one each day. I have arbitrarily used MS Excel’s system of setting Jan 1, 1900 equal to day one and then counting from there. This offered an opportunity to test these programs well into the future and have a reference to check the values against.
- iEver.xxx.Counter starts with 0 and counts up to x-1. For example, iEvery.Fourth.Day.Counter cycles through 0,1,2,3,0,1,2,3,etc. If today the variable was equal to 1 and you wanted to start watering your lawn tomorrow continuing every 4th day after that, set your program to water when the variable is 2.
- iWeek.of.Month starts with 1 on the first day of the month and increases by 1 every 7 days until the next month starts. So if you wanted something to happen on the second Tuesday of each month, set it to occur on Tuesdays when iWeek.of.Month is equal to 2.
- iWeek.Counter counts the number of weeks since Jan 1, 1900. The purpose of this variable is to calculate the every x weeks programs as there is likely no value in knowing how many weeks have passed since Jan 1, 1900. This value is produced by dividing iDay.Counter by 7.
- i.Every.xxx.Week programs start at 0 and count to x-1. This works the same as the iEvery.xxx.Day.Counter programs except it is for weeks.
- iOdd.Even.Day sets to 0 on even days and 1 on odd days of the month. This is useful in communities with watering restrictions limit certain addresses to water on even or odd days of the month. This differs from iEvery.Other.Day.Counter when a month with an odd number of days comes to a close.
- iHoliday sets to 1 on the listed holidays and 0 on all other days. Feel free to add your own holidays. I use this value to shut down wake-up alarms.
- iSync is a variable whose purpose is to test the status of this set of programs against the ISY’s internal day of week function. An email is triggered if the two are out of sync.
- The sVariables are simply the same value of the corresponding iVariables copied over to the state variable side. The purpose of this is so that you can use them as program “triggers”. You can certainly add more to the list as you see fit. The difference between a “state” variable and an “integer” variable is discussed elsewhere in the wiki.
Setting Up The Programs
- Setup the variables. This is not automatic. You must enter the listed variables into ISY AT THE SAME ID LOCATION AS SHOWN. ISY programs refrence the id location NUMBER, not the name. The name you enter in the name column is shown in the program for convenience only. Because I wrote these programs and then worked on some other programs, and then came back to these programs, there are some intervening variables which you need not concern yourself with, except to know that they must be skipped over until you get back to the correct ID number location. If you have already used some of the variable locations for other programs, you must either redirect you current program to another ID location or redirect the appropriate programs from these programs to new ID locations. You are free to change the names if you like so long as you understand what it represents.
- Import the programs or undertake the task of manually entering the programs. Please observe the screen captures to see how I set up the folder architecture. You are certainly free to do it differently, but keeping the programs organized this way is helpful.
- Set the start values. You must set the current date including day of month, day of year, month, day of week, year, and leap year (3 for a leap year, 0 for the year after a leap year, etc.) variables to the correct values. If you would like to stay true to the day counter starting with 1 on Jan 1, 1900 then you need to cross reference that number to MS Excel. This is an arbitrary decision on your part as any number would actually work. All of the other variables are calculated from those values and will settle in when the programs run at midnight. The “init” values need not be set as they will automatically populate at the midnight run time (unless you reboot your ISY prior to that time in which case all of the values will be lost). Please look elsewhere in the wiki to learn about how the “init” value works.
- Go to the Configuration Tab, System sub tab, System box and Uncheck the box next to “Catch up Schedules at Restart”. Not doing so will cause your ISY to run these programs every time the ISY is rebooted pushing it one day into the future which in most cases will be an error. Missed schedule grace period should be left at 15 minutes.
- Setup the email at ID location number 1 to whom you want the email to be sent and what you would like the content to be in the event that the ISY’s day of week becomes out of sync with the day of week calculated by these programs. It is assumed that if this variable is accurate, all of the others will be as well. Furthermore, it is the only thing that is possible for ISY to test on its own.
Irrigation Module's Commands
These are commands that can be used in ISY programs.
- Irrigation - Cycle Complete - triggers the module's calculations for after water has been applied.
- Irrigation - Reset Variables - triggers a reset of the module's Irrigation Requirement variable.
Program Example: Irrigate If Needed
The IF condition decides whether to water by comparing the Irrigation Requirement balance to a constant. The user is responsible for setting this constant equal to Water Applied per Irrigation Cycle, and updating it if they change the value of water that they apply per irrigation in their own programs.
If Time is 11:00:00PM And Module 'Climate' Irrigation Requirement >= 0.50 Then Set 'Front Yard' On Wait 10 minutes Set 'Back Yard' On Wait 5 minutes Set 'Back Yard' Off Irrigation - Cycle Complete
Please note: If you are using an EZFlora device you only have to turn off the last station. When you turn on the next station the EZFlora first turns off the current station then turns on the next one. If you use an EZio device you will have to turn off each station before turning on the next one.
Calculating the Station Run Time
In order to replace the water that is lost from the soil your station run times will need to be properly calculated. Each type of emitter/sprinkler has a different amount of water that is being delivered per minute/hour. The calculator linked below can be used to calculate the appropriate run time for each station.
Initialize the Module
After you have installed the Irrigation Module the Irrigation Requirement variable will most likely display zero. You will have to trigger a reset of the module variables to get things going correctly. Below is a walk-thru of the steps to perform this reset. Please note: If its the rainy season it may be difficult to tell if Irrigation Requirement is having an issue, so its recommended this be performed anyways just after the first install of the module.
- In the ISY Admin Console go to the Programs tab.
- Create the temporary program shown in the example below.
- Right click on the program in the folder tree and select "Run Then" to reset the module.
- Go back to the Weatherbug tab.
- Check again Irrigation Requirement and you should now see a number instead of a zero.
- Once you have done this initialization process you can delete the temporary program.
If - No Conditions - (To add one, press 'Schedule' or 'Condition') Then Irrigation - Reset Variables
Forum thread: Proposed Evapotranspiration Algorithm in 3.1.4 Beta