several AS; help needed. will buy BEER!!! #6 Pool Water Use

Posted on
Tue Oct 29, 2019 8:36 pm
hamw offline
Posts: 1212
Joined: Mar 31, 2008

several AS; help needed. will buy BEER!!! #6 Pool Water Use

Keeping track of how much water the pool uses....

Code: Select all
set {year:y, month:m, day:d, weekday:w} to (current date)

tell application "IndigoServer"
   log w
   log d
   log m
   log y
   
   
   log (("today = " & value of variable "WaterUsePool_01_Today") & ", " & ("yesterday = " & value of variable "WaterUsePool_02_Yesterday") & ", " & ("this week = " & value of variable "WaterUsePool_03_ThisWeek") & ", " & ("last week = " & value of variable "WaterUsePool_04_LastWeek"))
   
   
   
   --Today and Yesterday. Second line in each sequence resets the current variable to ""
   set value of variable "WaterUsePool_02_Yesterday" to value of variable "WaterUsePool_01_Today"
   
   set value of variable "WaterUsePool_01_Today" to "0"
   
   
   --This week and last week
   if w is Monday then
      set (value of variable "WaterUsePool_04_LastWeek") to (value of variable "WaterUsePool_03_ThisWeek")
      set value of variable "WaterUsePool_03_ThisWeek" to "0"
   end if
   
   
   --This month and last month, and convert to hundred cubic feet, ccf, as on water bill.
   if d is 1 then
      --set value of variable "WaterUsePool_06_LastMonth" to value of variable "WaterUsePool_05_ThisMonth"
      set WaterUsePoolThisMonth_Raw to ((value of variable "WaterUsePool_05_ThisMonth") / 7481)
      set WaterUsePoolThisMonth to (round (WaterUsePoolThisMonth_Raw * 100)) / 10 
      --set value of variable "WaterUsePool_06_LastMonth" to value of variable "WaterUsePool_05_ThisMonth"
      set value of variable "WaterUsePool_06_LastMonth" to WaterUsePoolThisMonth
      set value of variable "WaterUsePool_05_ThisMonth" to "0"
   end if
   
   
   --Prior Month historical data. Will work if variables such as "WaterUsePool_18_Dec" are created
   if d is 1 then
      if m is January then
         set value of variable "WaterUsePool_18_Dec" to WaterUsePoolThisMonth
      end if
      
      if m is February then
         set value of variable "WaterUsePool_07_Jan" to WaterUsePoolThisMonth
      end if
      
      if m is March then
         set value of variable "WaterUsePool_08_Feb" to WaterUsePoolThisMonth
      end if
      
      if m is April then
         set value of variable "WaterUsePool_09_Mar" to WaterUsePoolThisMonth
      end if
      
      if m is May then
         set value of variable "WaterUsePool_10_Apr" to WaterUsePoolThisMonth
      end if
      
      if m is June then
         set value of variable "WaterUsePool_11_May" to WaterUsePoolThisMonth
      end if
      
      if m is July then
         set value of variable "WaterUsePool_12_Jun" to WaterUsePoolThisMonth
      end if
      
      if m is August then
         set value of variable "WaterUsePool_13_Jul" to WaterUsePoolThisMonth
      end if
      
      if m is September then
         set value of variable "WaterUsePool_14_Aug" to WaterUsePoolThisMonth
      end if
      
      if m is October then
         set value of variable "WaterUsePool_15_Sep" to WaterUsePoolThisMonth
      end if
      
      if m is November then
         set value of variable "WaterUsePool_16_Oct" to WaterUsePoolThisMonth
      end if
      
      if m is December then
         set value of variable "WaterUsePool_17_Nov" to WaterUsePoolThisMonth
      end if
      
   end if

end tell

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest