Need a solution for my cat litter problem

So here is a situation regarding my cat and the litter box. So I have a small closet with a cat litter box inside. The closet has a regular door and on the door itself there is a little cat door.

The problem I have is the litter I’m using takes a while to clump up the liquid, and more than a few times I’ve tried to scoop up after my cat has just gone #1 when the liquid hasn’t clumped up yet. What I want is to have ST notify me, say 2 hours after my cat has done her business.

I plan on putting a motion sensor inside the closet to sense when the cat has gone in, and a door contact switch on the door to detect when I open the door to clean the litter box.

Can CORE satisfy my use cases below? If it can, then I will spend some time setting it up, or do you think I need a custom SmartApp for it?

Here is use case #1:

  1. Cat goes in to do #1, triggers motion sensor
  2. ST does a count down from 2 hours since the last time motion is detected
  3. Two hours later I get a notification on phone
  4. I open the door to scoop up the litter (by then it’d be all clumped up)

Use case #2:

  1. Cat goes in to do #1, triggers motion sensor
  2. ST does a count down from 2 hours since the last time motion is detected
  3. Two hours later I get a notification on phone, but I’m at work and can’t clean up yet.
  4. Cat goes in again sometime later and do whatever, triggers motion sensor
  5. At this point the timer will be reset, and 2 hours count down start again
  6. Two hours later I get a notification on phone
  7. I open the door to scoop up the litter (by then it’d be all clumped up).

It would also be nice to be notified only between 6 and 11PM when I’m home to clean up.

Do you need a motion sensor at all? Could it not be done just with a contact sensor on the cat flap?

You don’t really need to know when you open the door do you?

I guess I can do with just a contact sensor on the flap. I have to make sure I don’t open or close the door too fast to trigger the sensor on the flap.

With that, is there an app that can notify me after a contact sensor has been open/closed for a specified amount of time?

/**
 *  Litter Box Counter
 *
 *  Copyright 2016 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: "Litter Box Counter",
    namespace: "tslagle13",
    author: "Tim Slagle",
    description: "Count how many times your cat uses the litter box and alert you if they fall under the average.",
    category: "Pets",
    iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
    iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
    iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png")


preferences {
	section("Which contact sensor will detect your cat?") {
		input "catContact", "capability.accelerationSensor", title: "Contact", multiple: false, required: true
	}
    section("How many days should be used to calculate the average?") {
		input "daysAverage", "number", title: "Days", required: true, defaultValue: 3
	} 
    section("How far below the average should you be alerted?") {
		input "underAverage", "number", title: "Defecit", required: true, defaultValue: 2
	}
    section("Where wold you like to be notified?") {
    	input("recipients", "contact", title: "Send notifications to", required: true) {
        	input "push", "bool", title: "Send an push notification?", required:false
    		input "phone", "phone", title: "Send an SMS to this number?", required:false
    	}
    }
    section("Send a message with a daily usage count?") {
		input "sendDailyUsage", "bool", required: false
	}
    section("When should we check if usage is under average and send daily usage count?") {
		input "dailyCheck", "time", title: "Select a time", required: true
	}
    section("What is your cats name?") {
		input "catName", "text", title: "name", required: true
	}
}

def installed() {
	state.averageList = []
	initialize()
}

def updated() {
	unsubscribe()
	initialize()
}

def initialize() {
	state.lastTime = 0
    subscribe(catContact, "acceleration.active", contactEvent)
    schedule(dailyCheck, "checkDailyCount")
}

//handle contact event
def contactEvent(evt) {
    if (((now() - state.lastTime) > 300000) || (state.lastTime == 0)) {
    	usageCounter()
        state.lastTime = now()
        log.debug "Cat is using the litter box"
    }
}

//build list and calculate average
def usageCounter() {
	def removeList = []
	log.debug "calculateAverage()"
    state.averageList.push(now())
    state.averageList.each{ it ->
    	if ((now() - it) > (86400000 * daysAverage)){
        	removeList.push(it)
        }
    }
    def average = state.averageList
    def newAverage = average - removeList
    state.averageList = newAverage
    log.debug state.averageList
    
    state.average = (state.averageList.size().div(daysAverage)).toDouble().round(1)
    log.debug state.average
}


//check if daily count is under average
def checkDailyCount() {
	if (((now() - state.lastTimeDaily) > 60000) || (state.lastTimeDaily == 0)) {
		def dailyCount = 0
		log.debug "checkDailyCount()"
    	state.averageList.each{ it ->
    		if ((now() - it) <= 86400000) {
    	    	dailyCount = dailyCount + 1
    	    }
    	}    
    	def deficit = state.average - dailyCount
    	if (deficit >= underAverage) {
        	state.lastTimeDaily = now()
    		def alertMessage = "${catName} has only used the litter box ${dailyCount} times today. That is ${deficit} times below average"
    		if (recipients) {
    	    		sendNotificationToContacts(alertMessage, recipients)
    	    	}
    	    else if (!recipients) {
    	    	if (push) {
    	    		sendPush(alertMessage)
    	    	}    
    	    	if (phone){
    	    		sendSms(phone, alertMessage)
    	   		}
    	    }
		}
    	if (sendDailyUsage ) {
        	state.lastTimeDaily = now()
    		def dailyMessage = "${catName} has used the litter box ${dailyCount} times today."
    		if (recipients) {
    	    		sendNotificationToContacts(dailyMessage, recipients)
    	    	}
    	    else if (!recipients) {
    	    	if (push) {
    	    		sendPush(dailyMessage)
    	    	}    
    	    	if (phone){
    	    		sendSms(phone, dailyMessage)
    	   		}
    	    }
    	}
    }
}    

Wrote this app a little while back. It uses a multi-sensor to see when the cat is using the door and tells you when it goes below the average.

Looks like a great app and I will try it out. I’m interested in tracking my cat litter box usage as well. However, I am still looking for an app to notify me after a specified amount of time has passed since a contact sensor has been opened then closed so I only go scoop the box when the litter is dried up.

Let’s say I set the time to 2 hours.

1pm: Cat does business
2pm: Cat does business again
4pm: I get notified.

I won’t get notified at 3pm because the 2pm event resets the 2 hour timer.

CoRE can do this. Basic piston.

If
Cat contact sensor changes
Then (cancel on piston state change)
Using location
Wait 2 hours
Send push notification

1 Like