The Laundry is done – SmartThings App

This application sends push notifications and/or a text massages when the laundry is done.

For this project you will need a SmartThings Hub and a SmartSense Multi

I will try to make it as simple as I can but please leave a comment if think that anything needs clarification.

  • Log in to SmartThings IDE
  • Go to “My SmartApps” and click on “+New SmartApps”
  • Create the app with the following values:
    • Author: juano23@gmail.com
    • Name: The Laundry is done!
    • Description: Notifies me when the laundry is done!
    • Category: My Apps
  • In the following page paste the code below
  • Save and Publish
  • Now you should be able to see the new app on your phone 🙂

If you like to collaborate please contact me at juano23@gmail.com

/**
 *  The Laundry is done!
 *
 *  Author: juano23@gmail.com
 *  Date: 2013-08-27
 */

preferences {
    section("If there's movement (device is active)..."){
		input "accelerationSensor", "capability.accelerationSensor", title: "Acceleration Sensor", required: true, multiple: false
	}
	section("And it has been active for..."){
		input "delayMinutes", "number", title: "Minutes?"
	}
    section("Then send this message in a push notification"){
		input "messageText", "text", title: "Message Text", required: false
	}
	section("And as text message to this number (optional)"){
		input "phone", "phone", title: "Phone Number", required: false
	}
}

def installed() {
	log.debug "Installed with settings: ${settings}"
	subscribe(accelerationSensor, "acceleration", accelerationHandler)
}

def updated() {
	unsubscribe()
	log.debug "Updated with settings: ${settings}"
	subscribe(accelerationSensor, "acceleration", accelerationHandler)
}

def accelerationHandler(evt) {
    log.debug "Device: $evt.value"
	if (evt.value == "active") {
		log.debug "Working..."
        state.motionActiveTime = now()
        state.motionStopTime = 0
	} else if (evt.value == "inactive") {
    	state.motionStopTime = now()
		def elapsed = now() - state.motionActiveTime
        log.debug "It have been active for $elapsed"
		if (elapsed >= (delayMinutes ?: 0) * 60000L) {
            state.motionActiveTime = 0            
        	scheduleCheck()
        }
	}
}

def scheduleCheck() {
    def elapsedstop = now() - state.motionStopTime
	log.debug "Schedule check with motionStopTime: $elapsedstop"
    def motionState = accelerationSensor.currentState("acceleration")
    if (motionState.value == "inactive") {
    	if (elapsedstop >= 60000L) {
            log.debug "Motion has stayed inactive long enough since last check: sending message..."
            sendMessage()
        } else {
        	runIn(5,scheduleCheck)
        }
    } else {
    	log.debug "Motion is active, do nothing and wait for inactive"
    }
}

def sendMessage(evt) {
	def messageText = messageText != null ? messageText : "The Laundry is done!"
    log.debug "$messageText"
	sendPush(messageText)
	if (phone) {
		sendSms(phone, messageText)
	}
}

7 thoughts on “The Laundry is done – SmartThings App

  1. Manuel Plascencia

    Great idea. I added this to my ST. I’m just not clear how to physically setup the Multi Sense. Should I attach it to the washer , with the 2 pieces together , or should I be leaving them separate ? Explain the physical process. Thank you

    Reply
    1. juano2310

      Hi Manuel, You can use it either way since you won’t use the open/closer capability in this example but I can see a use case where it keeps remainding you until you open the washer’s door.

      Reply
      1. Manuel Plascencia

        I think I did everything correctly. I am not getting notifications? I tried notifications and text message , what am I missing. I bet it’s something stupid. I set it to 2 minutes, picked my sense multi. I see the s multis active , then inactive.

        Reply
  2. Manuel Plascencia

    Juan , I’m not getting this one to work? Not getting any notifications. what am I doing wrong followed your instructions.

    Reply
    1. juano2310

      The second param indicates how long it has to be active for to consider that is not a false positive. My washing machine moves a lot and the sensor picks this continuously for 1 minute at least. if your machine doesn’t move that much you might not be reaching the activation point. There is an other version of the app in the IDE based on time.

      Reply
      1. Manuel Plascencia

        hmmm my sensor detects movement , I’ve set it to 2 mins. , but once it goes to “inactive” it never sends the notification?

        Reply

Leave a Reply

Your email address will not be published. Required fields are marked *