(Enhanced) Z-Wave Schlage Touchscreen Lock

When i cut and paste the code from github and hit save I get an error saying the following:
groovy.lang.MissingMethodException: No signature of method: script142455792424650679129.metadata() is applicable for argument types: (script142455792424650679129$_run_closure1) values: [script142455792424650679129$_run_closure1@1671954e]
Possible solutions: getMetadata(), getState(), setState(java.lang.Object), metaClass(groovy.lang.Closure)

Anyone know how to fix this problem?

Thanks!
Al

Beaming support will be YES or NO in the official conformance statement for each certified device. These are published on the Z Wave Alliance site.

http://products.z-wavealliance.org

Nevermind, I am a dufus. I was adding a smart app not a device. Got it figured out now :smile:

code has been updated. Breaking with the existing non-standard ST standard, I’m now using the lock/unlock event’s “userCode” to indicate a manual (“manual”), automatic (“auto”) or keypad (without code)(0) event. When the lock command is performed via a z-wave operation (such as using the ST mobile app to lock the door), there’s no userCode at all.

This app is great! Thanks so much. I’m trying to add a couple functionalities to this app but it seems my programming skills are a bit rusty.
In short, my concept is if I unlock with a certain code, it will update the mode and turn on a particular song on sonos.

I’ve added components from the Sonos Mood Music template to attempt to achieve this.
Here’s the Sonos Mood Music code:
https://searchcode.com/codesearch/view/89517660/

I’ve been receiving this error:
java.lang.NullPointerException: Cannot get property ‘selectedSong’ on null object @ line 69
Highlighted below

Any help of course would be greatly appreciated.

/**

  • Door Unlock Triggers
  • Copyright 2015 Gary D
  • 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: “Door Unlock Triggers with music selection”,
namespace: “garyd9”,
author: “Gary D”,
description: “Triggers switches, door controls, etc based on lock events”,
category: “Convenience”,
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(“When a door unlocks
”) {
input “lock1”, “capability.lock”, title: “Door Lock?”, required: true
input “mySwitch”, “capability.switch”, title: “Switch? (for debugging)”, required: false
}
section(“And this user code opened the door:”) {
input “User1”, “enum”, title: “User Code”, metadata:[values:[“1”,“2”,“3”,“4”,“5”]]
}
section(“Then
”){
input “doors”, “capability.doorControl”, title: “Close these doors”, multiple: true, required: false
input “switches”, “capability.switch”, title: “Turn on these switches”, multiple: true, required: false
input “newMode”, “mode”, title: “Change to this mode”, multiple: false, required: false
input name: “sendPush”, type: “bool”, title: “Push notification to mobile devices?”, defaultValue: false
input “sonos”, “capability.musicPlayer”, title: “On this Sonos player”, required: false
input “song”, “enum”, title:“Play this track”, required:false, multiple: false, options: songOptions()
label title: “Assign a name”, required: false
}
}
def installed() {
log.debug "Installed with settings: ${settings}"
initialize()
}
def updated() {
log.debug "Updated with settings: ${settings}"
unsubscribe()
initialize()
}
def initialize() {
// TODO: subscribe to attributes, devices, locations, etc.
subscribe(lock1, “lock.unlocked”, lockHandler)
subscribe(mySwitch, “switch”, switchHandler, [filterEvents: false])
log.debug "about to subscribe to command
"
subscribeToCommand(mySwitch, “on”, switchOnHandler)
saveSelectedSong()

}

private songOptions() {

// Make sure current selection is in the set

def options = new LinkedHashSet()

if (state.selectedSong?.station) { // THIS IS WHERE THE ERROR OCCCURS
options << state.selectedSong.station
}
else if (state.selectedSong?.description) {
// TODO - Remove eventually? ‘description’ for backward compatibility
options << state.selectedSong.description
}

// Query for recent tracks
def states = sonos.statesSince("trackData", new Date(0), [max:30])
def dataMaps = states.collect{it.jsonValue}
options.addAll(dataMaps.collect{it.station})

log.trace "${options.size()} songs in list"
options.take(20) as List

}

private saveSelectedSong() {
try {
def thisSong = song
log.info "Looking for $thisSong"
def songs = sonos.statesSince(“trackData”, new Date(0), [max:30]).collect{it.jsonValue}
log.info “Searching ${songs.size()} records”

	def data = songs.find {s -> s.station == thisSong}
	log.info "Found ${data?.station}"
	if (data) {
		state.selectedSong = data
		log.debug "Selected song = $state.selectedSong"
	}
	else if (song == state.selectedSong?.station) {
		log.debug "Selected existing entry '$song', which is no longer in the last 20 list"
	}
	else {
		log.warn "Selected song '$song' not found"
	}
}
catch (Throwable t) {
	log.error t
}

}

def performActions(evt)
{
doors.eachWithIndex {s, i ->
def state = s.latestValue(“door”)
if (state == “open”)
{
log.debug "$s is currently $state. Closing it."
s.close();
}
else
{
log.debug “$s is currently $state. (can’t close it)”
}
}
switches.eachWithIndex {s, i ->
def state = s.latestValue(“switch”)
if (state == “off”)
{
log.debug "$s is currently $state. Turning it on."
s.on()
}
else
{
log.debug “$s is already $state.”
}
}
log.debug "We made it this far!!!“
setLocationMode(newMode)
sonos.playTrack(state.selectedSong)
if (sendPush)
{
sendPushMessage(evt.descriptionText)
}
}
def lockHandler(evt)
{
if (evt.data == null)
{
log.debug “evData is null”
}
else
{
def evData = parseJson(evt.data)
log.debug “evData.usedCode: ${evData.usedCode}. Attempting to find user $User1"
if (”${evData.usedCode}” == “$User1”)
{
log.debug User1 + " unlocked the door!"
performActions(evt)
}
}
}
def switchHandler(evt)
{
// performActions(evt)
log.debug “switchHandler ${evt.value}”
}
def switchOnHandler(evt)
{
log.debug “switchOnHandler ${evt.inspect()}”
}

(Sorry for taking so long to reply - been on vacation.) I don’t think there’s anything I can do to help here. Perhaps trying to ask folks more familiar with sonos would help?

This is great! Is there a way to get the app to send me an SMS when a user code is entered, rather than a mobile notification? My wife is logged in on her phone as well, so I’d prefer just an SMS to my phone if possible. Thanks!

Hello! I am super new here. I have been super let down by how confusing the SmartThings app is. I went all in bought all the stuff, got the Schlage Deadbolt, and now 6 months later, SmartThings still doesn’t even think its a “door” Anyways, today I discover that all the functionality is here made by a community member. And there is a website for SmartThings its just a “Developer” site? Alright thats all to say I am trying to figure this all out.

So I was able to find the code on github, I went to the developer portal, but then when I go looking where to add this new device’s code I cannot find it at all?!

Maybe I am diving too deep too quickly. Is there a way to set up rules on a webpage?

Yeah, it can get very confusing.

There are two rules engines that have been created by community members that you could give a try. One is only available for iOS, Obyrules, and the other is web-based by JoeC. Neither are officially supported by smartthings, but they’re worth a look.

For an overview of all the various scheduling options that are available, including where you can usually find custom code, take a look at this:

1 Like

Ok, so what I realized is I had the account on the graph.api.smartthings.com but I didn’t have the account approved for a developer account, so adding the smart apps wasn’t possible.

But still its amazing that the process is this bonkers. I get they don’t want people to mess up their smart homes, and thus make it a little hard to get this level of access. But once I found the steps, in 2 mins I had an updated thermostat, and a updated front door lock. Seems like they need an “appstore” where people can share these and allow people to try them out, and then rate them. Doing it all through a forum seems really lazy.

But I am soo soo happy for the community, and I love that people are even writing apps! So here is to that!

Glen.

2 Likes

Nice work Gary. Fun playing with this versus my zigbee yale touchscreen (until it died
) These are pretty good for the price point.

1 Like

Thank you for your work, Gary, however when I try this code on my BE469NX - Century style, lock only responds to open command and no longer responds to anything after that. Lock works great with generic driver “Z-Wave Lock” that is comes up when I pair it under this model in “things”. Any help would be greatly appreciated. Btw, I noticed that same exact behavior happens in the simulator, it only unlocks there and stop responding.

Hi,
Thanks for this great app. I would like to suggest an enhancement. It would be interesting to change the delay for auto lock to be triggered. But I not very familiar with this type of code. Can you tell me how to change this parameter in your code? Also, it would probably be interesting to add this as a end user parameter for futur versions.

Thanks again

Denis

[quote=“petruha98, post:32, topic:10034”]
however when I try this code on my BE469NX - Century style, lock only responds to open command and no longer responds to anything after that.
[/quote]Did it fully work at any time? What shows up in the live logging page on the IDE? Please describe, in detail, what you are doing to “open” it, and what else you’re trying to do. Please don’t make assumptions in your descriptions - assume you’re describing it to a 2 year old and go step by step.

I’m not worried about the simulator - I never really used that to develop against, so might have not bothered to fully support it.

Auto-lock delay isn’t user configurable. It’s just an “on/off” toggle in the lock itself.

  1. Open “New Device Type” in dev page
  2. Copy code from github
  3. Pasted to New Device Type
  4. Saved -> that created new device type “Z-Wave Schlage Touchscreen Lock”.
  5. Published -> For Me 
 successfully
  6. Removed lock from Things, re-added it as new “Z-Wave Schlage Touchscreen Lock” type. so far so good

  7. App shows green “Locked”
 pushed the green “Locked” button, lock responds almost immediately, opens, and icon (tile) changes to grey “Unlocking”
 thats it
 it would not change state to “Unlocked” or respond to any other commands.

Sorry, i do not have live log, as I actually need it working, so I moved it back to default Z-Wave Lock driver that finds this lock by default. Lock responds almost immediately to that driver, open/close/battery
 though unfortunately no other fancy details. I am ok for testing though, if you need that live log I would be able to re-create device driver and test next week. If you want to take it off-line, may be that would be easier to communicate
 and again thank you so much for your work and support.

I’ve tried, but I’m unable to repeat your issue. I’m not even sure how things could have gone wrong, as the basic code for lock/unlock is nearly identical to the ST device type. If you can capture live logging of some breakage, I’ll be happy to look into it.

Take care
Gary

@garyd9, is this something you can add to your device type to enable communication with the Smart Alarm app when the lock senses tampering or forced entry?

I can, but I probably won’t. It’s a hack that I’m uncomfortable with.

I’ve been trying to get ST to add a standard mechanism to “alert” for critical events for more months than I can count. There’s been several discussions, suggestions, and everything seems to get completely ignored by ST in the end.

To be quite honest, I’m tired of banging my head against a brick wall.

Unless ST takes an interest in their own product (and visibly demonstrates that interest), I’m pretty much done trying to work around and force their system to do sensible things.

Oh, and adding @April. Perhaps she can get someone to look into this again.

3 Likes

@garyd9 I’m also fedup with ST, their platform is going from bad to worse. Not to jump the topic but when basic features don’t work (last few days the event filtering is no longer working, see this thread below) I don’t see how they can devote time to any new stuff.