Several AS; help needed. will buy BEER!!! #5 night leak det

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

Several AS; help needed. will buy BEER!!! #5 night leak det

water night leak detection using a water meter and phidgets box. hopefully would catch a runny toilet, faucet etc.

Code: Select all
using terms from application "IndigoServer"
   tell application "IndigoServer"
      set Water_0 to value of variable "WaterUse_01_Today"
      --log Water_0
      
      delay 600 --this is 10 minutes
      
      set Water_10min to value of variable "WaterUse_01_Today"
      --log Water_10
      
      set Water_Compare to (Water_10min - Water_0)
      log "Total measured water leak is " & Water_Compare
      set value of variable "WaterHouseNightLeak" to Water_Compare
      
      --try to sort out a toilet flush (about a gallon to 1.6 gallons) vs a slow or large leak
      if ((Water_Compare is greater than or equal to 1) and (Water_Compare is less than or equal to 10)) or (Water_Compare is greater than 20) then
         log "possible leak"
         
         execute group "Water Measure Night Leak Detected?"
      end if
   end tell
end using terms from

Posted on
Sat Nov 09, 2019 2:21 pm
matt (support) offline
Site Admin
User avatar
Posts: 20086
Joined: Jan 27, 2003
Location: Texas

Re: Several AS; help needed. will buy BEER!!! #5 night leak

Below is untested, but probably works. Note because of the 10 minute delay/sleep in the script this one has to be saved as an external .py script file. Indigo requires that embedded scripts finish their execution within a few seconds or it kills them, but external file scripts can run indefinitely.

Code: Select all
varWaterToday = indigo.variables["WaterUse_01_Today"]
varWaterHouseNightLeak = indigo.variables["WaterHouseNightLeak"]

water0 = varWaterToday.getValue(float)
indigo.activePlugin.sleep(600)      # sleep for 10 minutes
varWaterToday.refreshFromServer()   # have to refresh our copy with the server's version since 10 minutes have passed
water10min = varWaterToday.getValue(float)
waterDelta = water10min - water0

indigo.server.log(u"Total measured water leak is " + str(waterDelta))
indigo.variable.updateValue(varWaterHouseNightLeak, str(waterDelta))

# try to sort out a toilet flush (about a gallon to 1.6 gallons) vs a slow or large leak
if (waterDelta >= 1 and waterDelta <= 10) or waterDelta > 20:
   indigo.server.log(u"possible leak")
   indigo.actionGroups.execute("Water Measure Night Leak Detected?")

Image

Posted on
Sun Mar 22, 2020 10:59 am
hamw offline
Posts: 1201
Joined: Mar 31, 2008

Re: Several AS; help needed. will buy BEER!!! #5 night leak

Matt, thank you very much! I am trying to work through these and your examples are very helpful.

Ham

PS: did not have "notify" ticked.. hence the late reply.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest