I wrote my custom app (PID duty-cycle thermostat controller) and I don't want it to run in Away mode. But even though I have "set for specific mode(s)" set to exclude Away mode, it keeps running in Away mode.
What is this setting supposed to do?
It's running its control loop every 1 minute, using the code runEvery1Minute(controlLoop , perhaps scheduled events aren't in "set for specific mode(s)"? But, then, what is in "set for specific mode(s)"?
Perhaps I am supposed to do something in my code to check for this setting?
Follow-up: if this setting isn't useful, what's the best option?
Anyone? I just want to know if “set for specific mode(s)” is supposed to actually do anything, and, if it doesn’t do anything by default, how to hide it, replace it, or access its setting from my app.
The built-in mode selector prevents the app from waking in response to device event subscriptions if not in the specified mode. I just created a small app to test this, and it works. It appears you are using a scheduled job. Those are apparently not affected (also something I tested), and while I wouldn't have guessed this before, I could see why this could be intentional.
It does to something by default, as above, but it can be hidden or replaced by following one of the methods in the documentation, specifically, by defining at least one explicit page in your app instead of relying on the implicit single-page behavior. (This can be used even if your app only needs a single page.)
The value of the built-in setting is not accessible, but any input you create in your own app (which I'd suggest only if doing the above to avoid confusion) would, of course, be. As an added advantage, you can present such a setting (or multiple settings) however it makes sense for your app and use it (or them) however you see fit. I think the defaults are pretty rarely used for this reason (no built-in apps, and I don't think I've see it in any popular community apps), though for very simple uses they could be convenient.
After adding a page for my settings (to hide the default page), and adding, a modes settings of my own, this seems to work in my scheduled control loop:
try {
def allowedModes = settings.modes
if (allowedModes && !allowedModes.contains(location.mode)) {
log.info "App paused: current mode '${location.mode}' not in allowed modes: ${allowedModes}"
return
} else {
log.debug "App running: current mode '${location.mode}' is in allowed modes: ${allowedModes}"
}
} catch (Throwable e) {
log.warn "Mode check failed: ${e.message}"
}
My page settings is just this:
input(name: "modes", type: "mode", title: "Set for specific Mode(s)", multiple: true, required: false)