First, your water meter trigger should be incrementing a water usage variable already. This script references "WaterHouse_Leak_Volume" and sets it to "0" once the script begins. This is a cumulative tally, and, during the loop, is referenced to set an "initial"value and then 10 sec later for the comparison value to determine if flow has occurred. It continues counting, and if its value exceeds the user's predefined maximum volume, the water house shut off action group is executed.
The script itself requires two more triggers. The first detects flowing water, in my case via the Phidgets interface, and sets the "WaterHouse_is_Flowing" variable to "true" when the "Phidgets Water Meter" "on/off state" becomes "on". The trigger's condition list only allows it to fire if the variables "WaterHouse_is_Flowing" and "WaterHouse_Leak_Script_INHIBITED" are both false. The former prevents it from constantly firing in and of itself, and the latter checks it from within the script. While it seems "WaterHouse_is_Flowing" is redundant, the slow response rate of the meter - - needs 1/10 gallon, 12.8 oz - - requires this trigger to be inhibited immediately.
The second trigger is called "Water House Fast or Large Volume Leak Detection Script" and is executed when the "WaterHouse_is_Flowing" variable becomes "true". It will only fire if "WaterHouse_Leak_Script_INHIBITED" is "false", to prevent multiple executions of the script. Note that the variable value for "WaterHouse_Leak_Script_INHIBITED" is set from within the script. The action is simply to launch the applescript. I have another condition in this trigger to prevent its execution if, for instance, I am filling the pool.
Here is the control page and variable list (ignore "WaterHouse_Leak_Slow_Detected"). House water flowing icons are RG BiColor 32 PNGs. The left, labeled icon, shows whether water is flowing at all. When the water starts flowing, it fires trigger the "water house is flowing" trigger, whose action sets the variable "WaterHouse_is_Flowing" to "true" and turns the left icon green. The one on the right represents "WaterHouse_is_Flowing_STILL", and it is set to true from within the script if the interval comparison indicates a difference between the time 0 value and time 10 value.
- Water Detection Control Page Image.tiff (35.63 KiB) Viewed 2070 times
- Water House Flowing Variable List Image.tiff (38.1 KiB) Viewed 2070 times
Max allowed is the value of the variable "WaterHouse_is_Flowing_MAX_ALLOWED" and is set by control page scripts below. The "max allowed" can be set as a user interface item on the control page, so if you press it you can change the value directly. Otherwise, the arrows, when pressed execute the following control page applescripts to increment the value by "50" up or down. Note that "50" = 5 gallons, as each phidgets pulse represents 1/10th of a gallon.
- Code: Select all
using terms from application "IndigoServer"
tell application "IndigoServer"
set value of variable "WaterHouse_is_Flowing_MAX_ALLOWED" to ((value of variable "WaterHouse_is_Flowing_MAX_ALLOWED") + 50)
end tell
end using terms from
and:
using terms from application "IndigoServer"
tell application "IndigoServer"
set value of variable "WaterHouse_is_Flowing_MAX_ALLOWED" to ((value of variable "WaterHouse_is_Flowing_MAX_ALLOWED") - 50)
end tell
end using terms from
Current Flow is the value of "WaterHouse_Leak_Volume"
"Leak Detection ENABLED? ", when pressed, executes "toggle variable: WaterHouse_Leak_Script_LoggingEnabled" and "set variable "WaterHouse_is_Flowing" to false". This last action is needed in case for some reason the script is interrupted and WaterHouse_is_Flowing is stuck on, despite no water flowing. If this is on, the script won't fire. So, if it is stuck, toggle this and it will reset, allowing the trigger to fire.
"Logging ENABLED" simply toggles the variable "WaterHouse_Leak_Script_LoggingEnabled". This will log entries like this if maximum volume is enabled:
Trigger Water House is Flowing
Trigger Water House Fast or Large Volume Leak Detection Script
Script Water is flowing. Leak Volume and Max allowed are: 1, and 650
Script Water is flowing. Leak Volume and Max allowed are: 3, and 650
Script total measured water use by Water House Max Flow Volume Script is 3
Script Water is flowing. Leak Volume and Max allowed are: 4, and 650
Script total measured water use by Water House Max Flow Volume Script is 4
Script Water is flowing. Leak Volume and Max allowed are: 4, and 650
Script Water has stopped running. Total volume is 4
Script total measured water use by Water House Max Flow Volume Script is 4
and this if water shutoff is disabled:
Trigger Water House is Flowing
Trigger Water House Fast or Large Volume Leak Detection Script
Script Water is flowing. Leak Volume and Max allowed are: 1, and NO MAXIMUM. DETECTION TURNED OFF
Script Water is flowing. Leak Volume and Max allowed are: 3, and NO MAXIMUM. DETECTION TURNED OFF
Script Water is flowing. Leak Volume and Max allowed are: 4, and NO MAXIMUM. DETECTION TURNED OFF
Script Water is flowing. Leak Volume and Max allowed are: 5, and NO MAXIMUM. DETECTION TURNED OFF
Script Water is flowing. Leak Volume and Max allowed are: 5, and NO MAXIMUM. DETECTION TURNED OFF
Script Water has stopped running. Total volume is 5
Hope this is useful. Any comments to make it better would be appreciated.