Rich-o-matic
RICH PESKE
16h
btcompute, any way you could share the code you used to do this? I’ve been trying to figure out the same thing … making a door/window sensor show as Locked/Unlocked instead … but I’m a complete beginner to all of this and I’m having the same problems you did with the Metadata error messages. Thanks!
Rich,
Here is what I did with limited success (more on that later).
- I copied the full code from GiHub for the Z-wave Door/Window Sensor Device Handler (DH):
https://github.com/SmartThingsCommunity/SmartThingsPublic/blob/5f85cd287342e5a5ad11b2da69049bfc8a1afcb4/devicetypes/smartthings/zwave-door-window-sensor.src/zwave-door-window-sensor.groovy
This should be the same DH you are using for your door/window switches.
Get a copy and save it to your “My Device Handlers”.
Save it under a name you will understand, maybe “Z-wave door sensor Lock/Unlock”.
- I edited only the lines that had any reference to Open or Closed. They are lines 34,35, 41, 42, 100 and 106 (
unless I missed something).
Here are the edited lines 34 & 35:
status “unlocked”: "command: 2001, payload: FF"
status “locked”: "command: 2001, payload: 00"
I suggest you edit the lines yourself rather than cut/paste my code. Just use my code as an example.
Lines 41, 42:
state “unlocked”, label: ‘${name}’, icon: “st.locks.lock.unlocked”, backgroundColor: “#ffa81e"
state “locked”, label: ‘${name}’, icon: “st.locks.lock.locked”, backgroundColor:”#79b821"
Note: Here I changed the icons that appear in ST app. I got those icon names from the DH for z-wave locks.
Lines 102, 104:
createEvent(name: “contact”, value: “unlocked”, descriptionText: “$device.displayName is unlocked”)
} else {
createEvent(name: “contact”, value: “locked”, descriptionText: “$device.displayName is locked”)
Make the changes and save the DH and publish “For Me”.
NOTE: this should make this sensor appear in ST as Locked or Unlock, but with one problem.
When you try to create rules for this device, most smartapps (I have been using Rule Machine) expect to see Open & Closed as status options. Therefore the rules don’t work properly.
If you don’t like this behavior, you can alwas switch back to the original DH.
I suspect that I changed too many references to Open/Closed. I need to work on the edits a bit to determine the cause of the problem.
Perhaps someone here can tell us what needs to be done to get the device to show up in ST as Locked/unlocked rather than Open/Closed.
Good luck. I hope this helps you.