Multiple Jawbones with Sleepy Time SmartApp?

I was wondering if it was possible to have multiple jawbones associated with the Sleepy Time SmartApp? I currently have one and was considering purchasing one for my wife.

I would hope that it would work exactly like Hello Home, i.e. don’t trigger the good night action until all have been triggered but wake up on first one. Is this possible?

Thanks!
Jeff

P.S. The Sleepy Time app desperately needs to be able to be set to only work in certain modes. It’s not helpful when I am away on vacation to have to house reacting.

Can’t you change the modes when you install the app (usually all the way at the end)? I don’t use it so I don’t know if that’s true or not.

Thanks Brian. It’s not available for the Sleepy Time app which is be big gripe since it appears to be standard on all the others.

Is the code available in the IDE? If yes, you can modify it by adding a few lines at the end of one of the preference pages. See this for details:

Thanks for pointing out the obvious, George. :smiley: I needed it.

Looks like it is there, I will take a look.

Jeff

It’s not quite that obvious. It took me quite some time to figure out how to do it.

You might need more than just the simple Mode condition - if so, find my Sleepy Time Too app (shared in the IDE) - it only responds to UP24 button if you are actually “present” in the house.

As to the all-in/first up, haven’t seen that one done yet.

Thanks Barry. I am going to start with the Sleepy Time Too app. It seems to be a better solution than worrying about the modes.

I’ve brought this up to the team so that we can look into fixing it. I originally thought you could limit the Hello, Home phrase to a certain mode but that won’t work in this case since the mode limitations in Hello, Home are for when it’s automatically performed.

Stay tuned.

Since there is no “global” state variables for a location, it’s going to be hard to track that ALL of a group of UP24’s have gone to sleep. Might have to leverage the UP24 “groups”, but I’m not sure their API exposes that kind of personal detail.

Also, note that the UP24 button press reporting to ST is not guaranteed (I’ve seen MANY misses), nor are they filtered (I accidentally turned mine to “awake” in the middle of the night, and sure enough, my whole house “woke up”). After a couple of weeks, I decided that it was no more than a novelty.

In the end, I adopted the minimote solution - last person to bed pushes the Goodnight! button. Much more reliable…

I wrote an app that takes care of a few of these problems. It deals with presence, modes, and multiple jawbones.

/**
 *  Sleepy Time with Presence
 *
 *  Copyright 2014 Eric Roberts
 *
 *  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: "Sleepy Time with Presence",
    namespace: "baldeagle072",
    author: "Eric Roberts",
    description: "Will only trigger the hello home phrase on the jawbone if the person is at home. If both people are home, both people have to be in sleep mode.",
    category: "Mode Magic",
    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 {
	page(name: "selectPhrases")
}

def selectPhrases() {
    dynamicPage(name: "selectPhrases", title: "Configure Your Jawbone Phrases.", install: true, uninstall: true) {		
		section("Select user 1's Jawbone UP24 and presence sensor") {
			input "jawbone1", "device.jawboneUser", title: "Jawbone UP24", required: true, multiple: false
            input "presence1", "capability.presenceSensor", title: "Presence", required:true, multiple: false
		}
    
    section("Select user 2's Jawbone UP24 and presence sensor") {
		input "jawbone2", "device.jawboneUser", title: "Jawbone UP24", required: true, multiple: false
        input "presence2", "capability.presenceSensor", title: "Presence", required:true, multiple: false
	}
    
	def phrases = location.helloHome?.getPhrases()*.label
	if (phrases) {
    	phrases.sort()
		section("Hello Home Actions") {
			log.trace phrases
			input "sleepPhrase", "enum", title: "Enter Sleep Mode (Bedtime) Phrase", required: true, options: phrases
			input "wakePhrase", "enum", title: "Exit Sleep Mode (Waking Up) Phrase", required: false, options: phrases
		}
	}
    section("Turn on - waking") {
        input "wakeOnSwitches", "capability.switch", multiple: true, required: false
    }
    section([mobileOnly:true]) {
        label title: "Assign a name", required: false
        mode title: "Set for specific mode(s)", required: false
    }
}

}

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

	initialize()

log.debug "Subscribing to sleeping events."

subscribe (jawbone, "sleeping", jawboneHandler)

}

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

unsubscribe()

log.debug "Subscribing to sleeping events."
    
subscribe (jawbone1, "sleeping", jawboneHandler1)
subscribe (jawbone2, "sleeping", jawboneHandler2)

initialize()
}

def initialize() {
	// TODO: subscribe to attributes, devices, locations, etc.
}

def jawboneHandler1(evt) {
	jawboneHandler(presence1, presence2, jawbone2, evt)
}

def jawboneHandler2(evt) {
	jawboneHandler(presence2, presence1, jawbone1, evt)
}

def jawboneHandler(primaryPresence, secondaryPresence, secondaryJawbone, evt) {

def primaryPresenceValue = primaryPresence.latestValue("presence")
def secondaryPresenceValue = secondaryPresence.latestValue("presence")

log.debug "In Jawbone Event Handler, Event Name = ${evt.name}, Value = ${evt.value}"

if (primaryPresenceValue == "present") {
	log.debug "User Present"
    
    if (evt.value == "sleeping") {
    	if (secondaryPresenceValue == "present") {
    		if (evt.value == secondaryJawbone.latestValue("sleeping")) {
            	sendNotificationEvent("Sleepy Time performing \"${sleepPhrase}\" for you as requested.")
                log.debug "Sleepy Time performing \"${sleepPhrase}\" for you as requested."
        		location.helloHome.execute(settings.sleepPhrase)
            } else {
            	log.debug "Second person not asleep"
            }
    	} else {
        	sendNotificationEvent("Sleepy Time performing \"${sleepPhrase}\" for you as requested.")
            log.debug "Sleepy Time performing \"${sleepPhrase}\" for you as requested."
        	location.helloHome.execute(settings.sleepPhrase)
        }
    }
    else {
    	if (wakePhrase) {
            sendNotificationEvent("Sleepy Time performing \"${wakePhrase}\" for you as requested.")
            log.debug "Sleepy Time performing \"${wakePhrase}\" for you as requested."
            location.helloHome.execute(settings.wakePhrase)
        }
        wakeOnSwitches?.on()
    }
} else {
	log.debug "User Not Present"
}   
}
2 Likes

Nice app!

One tiny thing though… I’ve currently got only one up24… though I’m thinking of getting the missus one for her birthday…

The thing is that the app needs the 2 up24’s snd presence sensors to work correctly…

Can you make the second user optional?