Limit which devices can be selected?


(Chrisb) #1

I have a Kwikset door lock that I’ve setup on the Kwikset side to automatically relock after 30 seconds. That’s not a SmartThings app, it’s built into Kwikset.

Unfortunately SmartThings doesn’t, right now, update status due to manual changes at the lock. That is, if someone physically unlocks the door, or punches in a code and unlocks the door, or if Kwikset does it’s auto re-lock after 30 seconds, SmartThings is unaware of any of these changes.

So wrote a simply little program that watches for my door sensor to open. If it opens the program does a refresh on the lock, then 35 seconds later, does another refresh (this is to capture when the lock should auto re-lock after 30 seconds if unlocked).

The program works, but there is a problem in the selection process:

If I indicate that I want a door lock by saying: “capability.lock”, then I’m presented only with door locks when I select my device, but when the program tries to run it fails because “.refresh” isn’t a capability of the “.lock” device.

However, If I indicate that I want a device by saying: “capability.refresh”, then I’m presented with any device that can refresh when I only want to see a list of my locks.

Okay, not sure… this isn’t a huge problem. I just make sure I pick my lock when I install the program and I’m fine. The program works, everyone’s happy. But ideally I’d like the program to only offer my door locks as options I can select. Is there a way to do this and till access the ability to refresh the lock?


(C Chen) #2

I don’t own a smart lock, so I can only test it with Presence, which also has two capabilities.

The three inputs work equally well when I test from IDE using a physical presence tag (not the virtual ‘devices’). It can always get the presence state and also beep the device.

preferences {
	section("Select ...") {
        input "x", "capability.presenceSensor", title: "sensor", multiple: false, required: true
        // input "x", "capability.tone", title: "tone", multiple: false, required: true
        // input "x", "device.smartSensePresence", title : "device", multiple: false, required: true

    }
}

def installed() {
	initialize()
}

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

def initialize() {
	subscribe( app )
}

def appTouch( evt ) {
    def val = x.latestValue( "presence" )
    log.debug "$x.presence $val"
    x.beep()
}

(Ronny Carr) #3

Not totally related, but why not create an app that locks the door after it closes (based on contact sensor). Instead of the 30 sec thing, which I don’t like because sometimes I want to leave my door open for more than 30 seconds.

I also set the app to check the status when the door opens and then 3 seconds after it closes.


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #4

I think you need to limit selection to specific device types, instead of capabilities, in this case.

input "x", "device.kwiksetLock", title : "device", multiple: false, required: true


(Chrisb) #5

Thanks CP. I’ll take a look at that when I get a chance.

@ronnycarr

I missed this when you replied early:

Not totally related, but why not create an app that locks the door after it closes (based on contact sensor). Instead of the 30 sec thing, which I don’t like because sometimes I want to leave my door open for more than 30 seconds.

I also set the app to check the status when the door opens and then 3 seconds after it closes.


There’s a couple of reasons I use the Kwikset lock method rather than running an app:

First, I installed the lock before I got my SmartThings and so enabled this function as extra security.

Next I want to limit the times in might unlock from a false presence leave-return. This isn’t a huge deal as the only app that I run to unlock automatically has a 10 minute fail safe, but it’s still a possible issue.

Also, I want to make sure that if the door does auto-unlock and then ST crashes it doesn’t leave my door unlocked all night

Finally, I don’t always use this door to enter the house. It’s the primary door, but sometimes when I come home I come in the back door instead of side door. In those instances I don’t want to have the side door left unlocked until someone opens and closes that door.


(Ronny Carr) #6

That makes sense. I live in an apartment so I have never had a problem with a false positive for presence, plus I only have the one entrance.