[OBSOLETE] Sump Pump Monitor

Title says it all. Monitors your sump pump within a specific time frame to alert you if it is running too often. Put a multi sensor on your outlet pipe to detect when the pump is running. Pretty simple but very informative.

Thanks @greg for helping me test!!! Please let me know if there are any issues with the app.

/**
 *  Sump Pump Check
 *
 *  Copyright 2014 Tim Slagle
 *
 *  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.
 *
 */
definition(
    name: "Sump Pump Monitor",
    namespace: "tslagle13",
    author: "Tim Slagle",
    description: "Checks to see whether your sump pump is running more than usual.  Connect a multi-sensor to the sump pump outlet pipe and it will alert you if it detects vibration more than twice in X amount of minutes.",
    category: "Safety & Security",
    iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
    iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png")


preferences {
	section("Which multisensor should I monitor?") {
		input "multi", "capability.accelerationSensor", title: "Which?", multiple: false, required: true
	}
    section("Danger Zone?") {
		input "frequency", "decimal", title: "What time frame should I monitor?", description: "Minutes", required: true
	}
    section("Send this message (default is ... Alert: Sump pump has ran in twice in the last X minutes.)"){
		input "messageText", "text", title: "Message Text", required: false
	}
    section("Via a push notification and/or an SMS message"){
		input "phone", "phone", title: "Phone Number (for SMS, optional)", required: false
		input "pushAndPhone", "enum", title: "Both Push and SMS?", required: false, options: ["Yes","No"]
	}

}

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

	initialize()
}

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

	unsubscribe()
	initialize()
}

def initialize() {
	subscribe(multi, "acceleration.active", checkFrequency)
}

def checkFrequency(evt){
log.debug("running check sump")
def lastTime = state[frequencyKeyAccelration(evt)]

if (lastTime == null) {
	state[frequencyKeyAccelration(evt)] = now()
}

else if (now() - lastTime >= frequency * 60000) {
	state[frequencyKeyAccelration(evt)] = now()
}


else if (now() - lastTime <= frequency * 60000) {
log.debug("Last time valid")
def timePassed = now() - lastTime
def timePassedFix = timePassed / 60000
def timePassedRound = Math.round(timePassedFix.toDouble()) + (unit ?: "")
state[frequencyKeyAccelration(evt)] = now()
def msg = messageText ?: "Alert: Sump pump has ran in twice in the last ${timePassedRound} minutes."

	if (!phone || pushAndPhone != "No") {
		log.debug "sending push"
		sendPush(msg)
	}
	if (phone) {
		log.debug "sending SMS"
		sendSms(phone, msg)
	}
}
}


private frequencyKeyAccelration(evt) {
	"lastActionTimeStamp"
}
3 Likes

Thanks to Tim for writing an awesome app!

Hey @tslagle13, three years later I shamelessly ripped off your code and modified it to add a couple of features. Namely, to not get a lot of alerts since my pump tends to run for days after it starts running. Anyhow, your old code was exactly the start I was looking for. That and I have two of them to monitor

I used the Zooz Power Switch / Zooz Smart Plug (ZEN15). The DTH is here: Zooz DTH. This allows for “acceleration” to be the inrush of current / watts instead of physical vibration.

I can’t promise there aren’t any bugs but it seems to alert when wanted.

Thanks Tim!

4 Likes

Nice work both of you.

With all respect, as this is useful for me as well, but you may want to update the text to: “Warning: ${multi} has run twice in the last ${timePassedRound} minutes.”

Fair point. Incorrect present perfect form. I updated it.

1 Like

I should also add another couple notes.

Timestamp in App:
Part of what this does is let you know when the pump last run and also when the last alert was, just in case you missed a push or txt or are just curious. As of v2.2, this is the time based on your hub’s timezone which is captured when you install or change settings.
Zooz Sensor settings:
For the Zooz Smart Plug, what makes this work is that it is set up to behave like an accelerometer. That’s great but you do have to make sure that you tweak the settings to avoid false positives and you monitor power consumption over V or A. Why? Because the electricity usage will vary slightly due to transient voltages and other similar items. For instance, what I found was that the pumps would consume about 0.78W while not running but that would vary up to around 1W (the power that the switch uses when it has the pump off - I use Ion brand switches FWIW ). In the on state, however, the pump will blow the roof off and consume like 600-800W or more depending on the size and design of the pump. So, you just have to ensure that little variations at the low end don’t trip the alarm. Here are the Zooz DTH settings I have been using for anyone interested (the critical ones are inactivePower and powerValueChange):

Name Type Value
debugOutput bool FALSE
displayCurrent bool TRUE
displayEnergy bool TRUE
displayPower bool TRUE
displayVoltage bool TRUE
electricityReportingInterval enum No Reports (Default)
energyPrice decimal 0.247574
energyReportingInterval enum 2 Hours
inactivePower number 2
ledIndicator enum Show for 5 seconds when turned on or off
overloadProtection enum Enabled (Default)
powerFailureRecovery enum Turn On
powerPercentageChange enum No Reports
powerReportingInterval enum 2 Hours
powerValueChange enum 25 Watts
voltageReportingInterval enum No Reports (Default)

Another side benefit I expect is that this might tell you if your switch fries. Before switching to Ion, I had tons of failures with the Ridgid brand switches randomly frying themselves but not always blowing the GFCI, leaving me unprotected. In those cases, the Ridgid switches got hot and warped so they should have been pulling lots of watts. On that same note, if your pump switch is old or sucks and gives readings all over the place, you might want to consider replacing it because my guess is that is an early indicator of failure due to corrosion or water seepage. Regardless, I think that monitoring the juice is a better way of detecting vs. vibration.

Hi In the setting yo show what setting is for the accelerometer. also cold it be a email and not sms?

Sorry, I did not see your response somehow. I would say that the only two “required” settings are the:
inactivePower 2
powerValueChange 25 Watts

These are what basically sets up the threshold to determine if the pump is running or not vs. just idle. The “acceleration” is the current/power acceleration from the idle state to the running state.

As for the notification, you can alter the code to do whatever you want. Push+SMS seemed more than enough to me but honestly it’s just a matter of taking the e-mail address in the settings window and calling the function to send an e-mail.

For anyone interested in this thread, I finally got around to uploading the code into GitHub so I deleted the quoted code and subbed in a link to GitHub.

Updated to v2.2 after I figured out a way to display the last run / last alert times (found on the settings page of the app) in the local timezone of the hub instead of UTC.

2 Likes

Hi @LLwarrenP,

I Try install on manual way so I got this “Java.lang.NullPointerException: Cannot get property ‘lastActionTimeStamp’ on null object”

What line number? Maybe you can post the full stack trace.

I follow this
1.Open SmartThings IDE in your web browser and log into your account.
2.Click on the “My Device Handlers” section in the navigation bar.
3.On your Device Handlers page, click on the “+ Create New Device Handler” button on the right.
4.On the “New Device Handler” page, Select the Tab “From Code” , Copy the “sump-pump-monitor.groovy” source code from GitHub and paste it into the IDE editor window.
5.Click the blue “Create” button at the bottom of the page. An IDE editor window containing device handler template should now open.

When I click “Create” I got this

Oh. This is a SmartApp, not a DTH. My guess is that you might be new to either ST or at least the customization? If you want to load an app then you go under My SmartApps. There is a lot of help here in the forums about this but in short the steps would be something like this:

  1. Using the brower, copy the code from GitHub
  2. Go into the ST IDE but make SURE you are using the right shard - the same shard your hub is on
  3. In the IDE, under My SmartApps, clicked +New Smartapp
  4. Selected “From Code”
  5. Pasted in the copied code
  6. Clicked Create
  7. Clicked Publish…For me
  8. On the phone app, under Automations, add a new app and select from My Apps where you find the app name
  9. Select the initial options

Alternatively, instead of manually loading the code, you can add my GitHub to your list of Repositories in the IDE and then you can easily install and update it (if there are changes).

Thank you very much, now works, please update your README.md file because call for “Device Handlers” instead “Smartapp”

Good catch, classic cut and paste error.

I made a few minor updates to the code to clean it up, should be up on GitHub shortly.

1 Like

Basically the v2.3 updates (now on GitHub) are just cleaning up some poor coding and ensuring that variables are set appropriately. If anyone has any issues with the newer version please let me know!

Hi @LLwarrenP would you add one thing on you app, Get Notified if Devices Stop Reporting?

So you’re trying to solve the issue of if the plug (as in a Zooz or other) is unplugged or if the breaker to the entire circuit is off? Just wanted to see what you were envisioning as the full use case.

I added the feature to check for a “heartbeat” from the sump pump device. I use the Zooz which is configurable as to how often it reports in so you have to be careful to select a window that will be larger than the worst possible reporting window. Each device is different though so you’ll just have to observe your device via the Live Logging to see what is routine and also accounting for the off chance of a missed message.

But, it works nicely once you get that figured out. I ended up going with 4 hours but might move it to 6 hours. The v2.4 code is up on GitHub.

2 Likes