It’s straight forward:
Allow selection of the disable switch:
input("disabled", "capability.switch", title: "Select switch to disable motion", required: false, multiple: false
Subscribe to the disable switch in initialize()
:
subscribe(disabled, "switch", disabledHandler)
disabledHandler(evt)
does this:
state.motionDisabled = evt.value == "on"
Then, in all of the methods that handle motion events, simply add this at the beginning of each:
if(state.motionDisabled) return
And, be sure to initialize state.motionDisabled
in initialize()
:
state.motionDisabled = (disabled) ? disabled.currentSwitch == "on" : false
This assumes you are handling all of the motion events in the app.