[OBSOLETE] Sharing my implementation of grey water pumping

Hi there,

I am living in an area where water is rare so I reuse my washing machine to water my garden.
This is known as grey water.
Basically, you store the water in a tank, and pump it out with enough pressure to use your sprinklers.

While I initially did things manually, I ended-up to write a smartapp in order to manager the pump shut-down once there is no more water to pump. I only use a smartplug for that.
I noticed that the electrical pump wattage differs when it sucks water (A level on the chart above) or air (= no more water, which is the B level on the chart), so the smart app simply triggers a shut-down if the power goes up the sucking water value and then go down to the sucking air value.
I don’t need anymore to be close to the switch.

The values I use for A and B with this pump are: A: 730W and B: 550W.

Hope you like it. Code of the smartapp is below:

 *  Turn Grey Water pump off
 *  Copyright 2017 Philippe Portes. Adapted from the Energy Save SmartThings SmartApp
 *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the License at:
 *      http://www.apache.org/licenses/LICENSE-2.0
 *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
 *  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 *  for the specific language governing permissions and limitations under the License.
    name: "Turn Grey Water pump off",
    namespace: "philippeportesppo",
    author: "Philippe Portes",
	description: "Turn pump off once it sucked everything it could",
    category: "Green Living",
    iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet.png",
    iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet@2x.png",
    iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet@2x.png"

preferences {
	section {
		input(name: "meter", type: "capability.powerMeter", title: "When This Power Meter...", required: true, multiple: false, description: null)
        input(name: "thresholdhigh", type: "number", title: "Consumes above pump sucking power (water sucked)...", required: true, description: "in either watts or kw.")
        input(name: "thresholdlow", type: "number", title: "Then goes below pump sucking power (air sucked)...", required: true, description: "in either watts or kw.")
    section {
    	input(name: "switches", type: "capability.switch", title: "Turn Off These Switches", required: true, multiple: false, description: null)

def installed() {
	log.debug "Installed with settings: ${settings}"

def updated() {
	log.debug "Updated with settings: ${settings}"

def initialize() {
	subscribe(meter, "power", meterHandler)
    state.upperThresholdPassed = 0
    subscribe(switches, "switch.on", switchOnHandler)

def meterHandler(evt) {
    def meterValue = evt.value as double
    def thresholdValueHigh = thresholdhigh as int
    def thresholdValueLow = thresholdlow as int

	// Check if pump is sucking i.e. wattage is above the threshold high measured while sucking liquid
    if (meterValue > thresholdValueHigh) {
    	state.upperThresholdPassed =1
        log.debug "${meter} reported energy consumption above threshold ${threshold}. Pump is sucking."
    // Check if pump is no longer sucking i.e. wattage is below the threshold low measured while pump is sucking air
    if (meterValue < thresholdValueLow && state.upperThresholdPassed == 1) {
	    log.debug "${meter} reported energy consumption below min threshold ${threshold}. Turning off pump."
        state.upperThresholdPassed =0

// Set to 0 the parameter in order to avoid false detection after 1st usage or if user stops the pump while still sucking water.
def switchOnHandler(evt) {
	state.upperThresholdPassed =0 


Depending on your country, you may refer to the list of recommended products. Basically you have to use Nature friendly soap. Examples on http://ecologycenter.org/factsheets/greywater-cleaning-products/.
There is also a constraint to use the water within the 24h to avoid bacterial issues and finally, not using this water to spread onto plants leaves aimed to be eaten (vegies, fruits, aromatic plants etc…).
This is not to be confused with brown.and black water that can’t be used at all, so forget about reusing kitchen or bathroom water except this cold water water you currently throw away till it’s warm. I personally put it in a bucket and drop it in the barrel to reuse it too.