Hi,
I am trying to create a virtual device for a motion sensor using the template for the Z-wave motion sensor. However, when publishing it, in my phone I am not able to change the state of the motion sensor as we can do for a switch.
Is there something I am missing? Do I need to add a switch capability to the motion sensor device handler to change its state to active or inactive?
I will really appreciate the help.
or better yet, add an action to both the active and inactive tiles, like this:
attributeState "active", label: 'motion', action: "changetoinactive", icon: "st.motion.motion.active", backgroundColor: "#00A0DC"
attributeState "inactive", label: 'no motion', action: "changetoactive", icon: "st.motion.motion.inactive", backgroundColor: "#cccccc"
You’ll want to add custom commands, like this:
command "changetoinactive"
command "changetoactive"
and then define the code to send device state changes:
def changetoinactive() {
sendEvent("name":"motion", "value":"inactive")
}
def changetoactive() {
sendEvent("name":"motion", "value":"active")
}
When you tap on the main tile it will change it’s state (or it should)!
1 Like