/**
* Copyright 2014 SmartThings
*
* 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.
*
*/
metadata {
// Automatically generated. Make future change here.
definition (name: "Simulated Contact Sensor", namespace: "smartthings/testing", author: "bob") {
capability "Contact Sensor"
command "open"
command "close"
}
simulator {
status "open": "contact:open"
status "closed": "contact:closed"
}
tiles {
standardTile("contact", "device.contact", width: 2, height: 2) {
state("closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821", action: "open")
state("open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e", action: "close")
}
main "contact"
details "contact"
}
}
def parse(String description) {
def pair = description.split(":")
createEvent(name: pair[0].trim(), value: pair[1].trim())
}
def open() {
log.trace "open()"
sendEvent(name: "contact", value: "open")
}
def close() {
log.trace "close()"
sendEvent(name: "contact", value: "closed")
}
I am using a ZEN17 to monitor a relay… the relay is open when the status is closed, so the simulated device handler shows it as open. Was hoping to modify this handler, but seems to have no effect when I do.
I am wondering if creating a virtual device using Edge and using Routines to sync it with your ZEN17 might be a better option at this point. I’ll let the experts give you a better answer to your question if you prefer the groovy DTH option
Use any virtual contact device, and create routines, when real device is open then close virtual and opposite, when real device is closed, then open virtual device
Depending on how you setup the device, it creates virtual devices to read the input sensors separate from the trigger relays. I am using once input as an input open close sensor and it set it to use this simulated sensor device.
They have added the ability in newer firmware to invert the status, but I am on an old firmware and SmartThings doesn’t support OTA. So modifying the device handler would be a quick fix if possible
Ah, I’ve just found what appears to be an official DTH and it is a Kevin LaFramboise. When he writes a DTH it stays written. I’d be looking at line 56 of that where it says:
I’d be very surprised if flipping the active and inactive values over doesn’t do the job for you, providing you need all your contact sensors to behave the same. You could munge the Simulated Contact Sensor but you’d probably need to edit that line to make sure your version is picked up, so you might as well not bother.
Thanks! That did the trick, didn’t think to look in the Zooz device handler. That will hold me over until I have a change to update the firmware on the actual device.