How to make relay not work when i am not home?


(Darryl Chambers) #1

I would like to make sure that my relay that I have opening a hidden door when i hit my panic button does not function when it does not see present devices like my cell phone. i want to make sure that if my wife and i are not home and the kids find the button the door will not open. Is there anyway to include this right into my custom code that i am using?
Thanks.

metadata {

definition (name: “Z-Wave Relay Push”, namespace: “smartthings”, author: “SmartThings”) {
capability "Actuator"
capability "Switch"
capability "Polling"
capability "Refresh"
capability "Sensor"
capability “Relay Switch”

fingerprint deviceId: "0x1001", inClusters: "0x20,0x25,0x27,0x72,0x86,0x70,0x85"
fingerprint deviceId: "0x1003", inClusters: "0x25,0x2B,0x2C,0x27,0x75,0x73,0x70,0x86,0x72"

}

// simulator metadata
simulator {
status “on”: "command: 2003, payload: FF"
status “off”: “command: 2003, payload: 00”

// reply messages
reply "2001FF,delay 100,2502": "command: 2503, payload: FF"
reply "200100,delay 100,2502": "command: 2503, payload: 00"

}

// tile definitions
tiles {
standardTile(“switch”, “device.switch”, width: 2, height: 2, canChangeIcon: true) {
state “on”, label: ‘${name}’, action: “switch.off”, icon: “st.switches.switch.on”, backgroundColor: "#79b821"
state “off”, label: ‘${name}’, action: “switch.on”, icon: “st.switches.switch.off”, backgroundColor: “#ffffff
}
standardTile(“refresh”, “device.switch”, inactiveLabel: false, decoration: “flat”) {
state “default”, label:’’, action:“refresh.refresh”, icon:“st.secondary.refresh”
}

main "switch"
details(["switch","refresh"])

}
}

def installed() {
zwave.manufacturerSpecificV1.manufacturerSpecificGet().format()
}

def parse(String description) {
def result = null
def cmd = zwave.parse(description, [0x20: 1, 0x70: 1])
if (cmd) {
result = createEvent(zwaveEvent(cmd))
}
if (result?.name == ‘hail’ && hubFirmwareLessThan(“000.011.00602”)) {
result = [result, response(zwave.basicV1.basicGet())]
log.debug “Was hailed: requesting state update”
} else {
log.debug “Parse returned ${result?.descriptionText}”
}
return result
}

def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) {
[name: “switch”, value: cmd.value ? “on” : “off”, type: “physical”]
}

def zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd) {
[name: “switch”, value: cmd.value ? “on” : “off”, type: “digital”]
}

def zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {
def value = "when off"
if (cmd.configurationValue[0] == 1) {value = “when on”}
if (cmd.configurationValue[0] == 2) {value = “never”}
[name: “indicatorStatus”, value: value, display: false]
}

def zwaveEvent(physicalgraph.zwave.commands.hailv1.Hail cmd) {
[name: “hail”, value: “hail”, descriptionText: “Switch button was pressed”, displayed: false]
}

def zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.ManufacturerSpecificReport cmd) {
if (state.manufacturer != cmd.manufacturerName) {
updateDataValue(“manufacturer”, cmd.manufacturerName)
}

final relays = [
[manufacturerId:0x0113, productTypeId: 0x5246, productId: 0x3133, productName: “Evolve LFM-20”],
[manufacturerId:0x0113, productTypeId: 0x5246, productId: 0x3133, productName: “Linear FS20Z-1”],
[manufacturerId:0x5254, productTypeId: 0x8000, productId: 0x0002, productName: “Remotec ZFM-80”]
]

def productName = null
for (it in relays) {
if (it.manufacturerId == cmd.manufacturerId && it.productTypeId == cmd.productTypeId && it.productId == cmd.productId) {
productName = it.productName
break
}
}

if (productName) {
log.debug "Relay found: $productName"
updateDataValue(“productName”, productName)
}
else {
log.debug "Not a relay, retyping to Z-Wave Switch"
setDeviceType(“Z-Wave Switch”)
}
[name: “manufacturer”, value: cmd.manufacturerName]
}

def zwaveEvent(physicalgraph.zwave.Command cmd) {
// Handles all Z-Wave commands we aren’t interested in
[:]
}

def on () {
[
zwave.basicV1.basicSet(value: 0xFF).format(),
zwave.basicV1.basicGet().format(),
“delay 8000”,
zwave.basicV1.basicSet(value: 0xFF).format(),
“delay 200”,
zwave.basicV1.basicSet(value: 0x00).format(),
zwave.basicV1.basicGet().format()
]
}

def off() {
sendEvent( name: “switch”, value: “off”)
return zwave.basicV1.basicSet(value: 0x00).format()
}

def poll() {
zwave.switchBinaryV1.switchBinaryGet().format()
}


(Mike Maxwell) #2

You need to subscribe to presence events, only smart apps can subscribe to events, so you won’t be able to do this directly in your handler. You could create a custom command in your handler that disables it, then use core or the like to track the presence then call your device disable function.


(Darryl Chambers) #3

Mike thank you for taking your time to answer my question. I have some google searching to do i am really new at this. Thanks again!


#4

Is the panic button the only way to activate the door now? And what specific device is the panic button (brand and model).

For example, if the panic button is a key fob, you can just take the key fob with you or put it in a lockbox when you’re gone.

If the panic button is permanently installed, how is it triggering the relay? Is it just through a smartapp/automation? Is there a physical traveler wire to the relay? Is it using zwave direct association?


(Darryl Chambers) #5

It is iris Model # 3460-L push button that is mounted in a perm location. it is wireless working through smartapp. it is using zwave


#6

That’s a zigbee device, so it’s not using zwave, but in that this case that’s good. :sunglasses:

https://www.lowes.com/pd/Iris-Next-Gen-White-Wireless-Home-Automation-Button/999925306

What automation are you using to have the button trigger the relay? The official smart lighting feature? Button Controller? Or did you write your own?

If you are using core, everything is easy, as you can specify that The rule for having the button turn on the relay only operate when specific presence indicators are at Home.


(Darryl Chambers) #7

i am using a stock automation to trigger the relay and that code from my origanl post to keep it turned of for 8 seconds then it turns back off.


(Barry) #8

CoRE is probably your best option, but a simple SmartApp that replaces the “stock automation” you are using could be written.

Basically, all you need to do is

if (button pressed), and if (one of these presence sensors are present) then (turn on the relay)

That’s pretty simple with CoRE.

In a SmartApp you would subscribe to (button.contact), then check (people.currentValue('presence")) before (relay.on()).


(Darryl Chambers) #9

Everyone Thank you for your input!!! I installed core and that was the ticket!