Monitor water valves w/water meter, Phidgets + AS

Posted on
Mon Sep 04, 2017 2:00 pm
hamw offline
Posts: 1212
Joined: Mar 31, 2008

Monitor water valves w/water meter, Phidgets + AS

My pool has had its level drop in the past due to leaky pipes. Additionally I have a sprinkler branch system that goes off in that direction. The pool used to be auto filled by the house water, which, if it leaked, would kill my water filters. So we had some renovation done, and I split out the pool fill and pool house water. The pool house water is now connected to the house water via a Phidgets controlled Valbia water valve, which is tested for function and line integrity each night (see below). The pool is filled by a simple irrigation valve, controlled via Phidgets as well, with a simple on/off. A big difference in the valves is that the Valbia valve has contact closure monitoring ensuring "on" and "off" positions are attained. Nonetheless we would still want to ensure not only operation but line integrity in both. I have written a couple of scripts which are executed each night and set control page variable values to give a visual representation of success as well as a time stamp taken from an RFX sensor for reference. If a failure occurs, or for instance the irrigation valve continues to flow despite the lines having enough time to fill their dead space, the scripts will send a text via variable substitution to a messaging trigger. I've included the irrigation valve script; if there is further interest I can include the pool water valve action; because it uses the Phidgets device to get the current state of the valve, it cannot be easily stuck in a pure AppleScript (no onOffState function in Phidgets devices that I have found.)

This is a pretty restricted use case, but hopefully some will find it useful.

Pool/Sprinkler monitoring:

Code: Select all
using terms from application "IndigoServer"
   tell application "IndigoServer"
      log "Sprinkler Valve Test running now. 1. Is if there is water running despite valve being off. Measure any flow in initial state. 2. Is valve is opening correctly? Measure zero flow then some flow while open. 3. Are lines tight? See if flow stops once dead space in lines are full. If continued water flow, either lines have a leak or the pool is filling. 4. Is the valve is closing correctly? Observe for any flow following valve closure."
      
      set value of variable "Water_Test_Pool_SprinklerValve_Works" to "false"
      set value of variable "Water_Test_Pool_Sprinkler_Success" to "false"
      set value of variable "Water_Use_Pool_System_Tight" to "false"
      
      set waterFlow0Seconds to value of variable "WaterUsePool_01_Today" as string
      
      
      delay 10
      set waterFlow5seconds to value of variable "WaterUsePool_01_Today" as string
      set waterFlowYes to (waterFlow5seconds - waterFlow0Seconds)
      log "initial flow with valve closed is  " & waterFlowYes
      if waterFlowYes is greater than 0 then
         log "Pool House Sprinkler Valve is not open at all but water flow is detected. Valve may be stuck open, with " & waterFlowYes & " tenths of a gallon measured."
      else
         log "Pool House Sprinkler Valve appears tight with no initial flow."
      end if
      
      delay 1
      set waterFlow0Seconds to value of variable "WaterUsePool_01_Today" as string
      execute group "Water Valve Pool Sprinkler Weekly Valve Test Supply Open"
      delay 5
      set waterFlow5seconds to value of variable "WaterUsePool_01_Today" as string
      set waterFlowYes to (waterFlow5seconds - waterFlow0Seconds)
      log "initial flow is  " & waterFlowYes
      if waterFlowYes is greater than 0 then
         
         log "Pool House Sprinkler Valve is opening correctly and water is flowing, with " & waterFlowYes & " tenths of a gallon measured."
         set value of variable "Water_Test_Pool_SprinklerValve_Works" to "true"
         set value of variable "Water_Test_Pool_SprinklerValve_Works_TimStmp" to value of variable "RFX_Outside_Temp_Obs_Time"
      else
         set value of variable "Water_Test_Pool_Sprinkler_Success" to "false"
         set value of variable "Water_Test_Pool_SprinklerValve_Works" to "false"
         log "The Pool Fill/Sprinkler valve might not be opening as there was zero flow. Turn on pool sprinklers and re-run test to see if flow is active. If not, valve may be malfunctioning."
         execute group "Water Pool Sprinkler Valve Test Failed due to Zero Flow"
      end if
      
      
      if waterFlowYes is greater than 0 then
         delay 10 --this is 10 seconds and should be enough time for the pipes to fill. Note that the stupid pool fill valve does not appear to close fully. Need a different one.
         log "Pool Sprinkler Fill Valve Test Running"
         set Water_Test_Pool_Sprinkler_ON to value of variable "WaterUsePool_01_Today" as string
         
         --log (value of variable "Water_Test_Pool_Sprinkler_ON") as string
         
         delay 10
         
         set Water_Test_Pool_Sprinkler_OFF to value of variable "WaterUsePool_01_Today" as string
         --log (value of variable "Water_Test_Pool_Sprinkler_OFF") as string
         
         
         if ((Water_Test_Pool_Sprinkler_OFF) - (Water_Test_Pool_Sprinkler_ON)) is equal to 0 then
            set value of variable "Water_Test_Pool_Sprinkler_Success" to "true"
            
            set value of variable "Water_Use_Pool_System_Tight" to "true"
            
            set value of variable "Water_Test_Pool_Sprinkler_Success_TimeStamp" to value of variable "RFX_Outside_Temp_Obs_Time"
            
            log "Pool Sprinkler Valve On then Off shows Valve is functioning and lines are tight. Best case achieved." as string
            --This result is our best case.
            
         else
            set value of variable "Water_Test_Pool_Sprinkler_Success" to "false" --continued flow suggests leak
            set value of variable "Water_Use_Pool_System_Tight" to "false"
            log "The Pool Fill/Sprinkler lines may have a leak, or the pool level is low and it is filling. Go check."
            execute group "Water Pool Sprinkler Valve Test Failed"
         end if
      end if
   end tell
end using terms from


This is a reply message set from the script:

Code: Select all
tell application "IndigoServer"
   log "Sprinkler Valve Test running now. 1. Is if there is water running despite valve being off. Measure any flow in initial state. 2. Is valve is opening correctly? Measure zero flow then some flow while open. 3. Are lines tight? See if flow stops once dead space in lines are full. If continued water flow, either lines have a leak or the pool is filling. 4. Is the valve is closing correctly? Observe for any flow following valve closure."
   set value of variable "Water_Test_Pool_SprinklerValve_Works" to "false"
   set value of variable "Water_Test_Pool_Sprinkler_Success" to "false"
   set value of variable "Water_Use_Pool_System_Tight" to "false"
   get value of variable "WaterUsePool_01_Today"
      --> "682"
   get value of variable "WaterUsePool_01_Today"
      --> "682"
   log "initial flow with valve closed is  0"
   log "Pool House Sprinkler Valve appears tight with no initial flow."
   get value of variable "WaterUsePool_01_Today"
      --> "682"
   execute group "Water Valve Pool Sprinkler Weekly Valve Test Supply Open"
   get value of variable "WaterUsePool_01_Today"
      --> "683"
   log "initial flow is  1"
   log "Pool House Sprinkler Valve is opening correctly and water is flowing, with 1 tenths of a gallon measured."
   set value of variable "Water_Test_Pool_SprinklerValve_Works" to "true"
   set value of variable "Water_Test_Pool_SprinklerValve_Works_TimStmp" to value of variable "RFX_Outside_Temp_Obs_Time"
   log "Pool Sprinkler Fill Valve Test Running"
   get value of variable "WaterUsePool_01_Today"
      --> "683"
   get value of variable "WaterUsePool_01_Today"
      --> "683"
   set value of variable "Water_Test_Pool_Sprinkler_Success" to "true"
   set value of variable "Water_Use_Pool_System_Tight" to "true"
   set value of variable "Water_Test_Pool_Sprinkler_Success_TimeStamp" to value of variable "RFX_Outside_Temp_Obs_Time"
   log "Pool Sprinkler Valve On then Off shows Valve is functioning and lines are tight. Best case achieved."
end tell

Posted on
Mon Sep 04, 2017 9:12 pm
Korey offline
User avatar
Posts: 813
Joined: Jun 04, 2008
Location: Henderson, NV

Re: Monitor water valves w/water meter, Phidgets + AS

Great!

Thanks for sharing!!

--
Korey

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 35 guests

cron