Water leakage warning script

Moderator: leecollings

Post Reply
User avatar
Keptenkurk
Posts: 103
Joined: Wednesday 21 August 2013 17:24
Target OS: -
Domoticz version:
Location: Waalre, The Netherlands
Contact:

Water leakage warning script

Post by Keptenkurk »

My toilet fawcett sometimes gets stuck. If it does it will keep on flushing, wasting lots of water. Having my water meter interfaced i wrote a small warning script which starts yelling at me if there is water usage of at least 1 litre/minute each minute for the past 10 minutes.
As long as water is still being used it resends the notification every minute.
The parameters will enable me to shower and water the garden without warning but will trigger when the fawcett gets stuck.

Okay, it's no rocket science but still would like to share.
Save the script below into script_time_waterwarning.lua and store into the domoticz/scripts/lua directory.
Don't forget to create the user variables first.

Code: Select all

-- Water leakage warning script
-- 
-- Send notification when there is water consumption of at least 1 litre per minute
-- for more then 10 minutes (this indicates a leakage or stuck toilet fawcett) 
-- A notification will be sent every minute as long as the condition remains
-- Create user variables below before using this script
-- Uncomment print for debugging
--
-- Sensor:
--   Watermeter: 'Water' returning current total usage in liters
-- User variables:
--   LastWaterUsage (int): stores the total amount of water used uptil the previous minute
--   WaterUsageDuration (int): increments each consecutive minute of water usage 

commandArray = {}

if ( tonumber(uservariables["LastWaterUsage"]) < tonumber(otherdevices_svalues['Water'])) then
   commandArray['Variable:LastWaterUsage']= otherdevices_svalues['Water']
   commandArray['Variable:WaterUsageDuration']= tostring(uservariables['WaterUsageDuration'] + 1)
   if tonumber(uservariables['WaterUsageDuration']) > 10 then
      commandArray['SendNotification']='Er is gedurende minstens 10 minuten water verbruikt!'
   end
else
   commandArray['Variable:WaterUsageDuration']= '0'
end

-- print(uservariables['WaterUsageDuration'],uservariables['LastWaterUsage'] )

return commandArray
/paul
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest