Does runin complete even if mode changes and app not set to run in that mode?

smartapp

(Tuffcalc) #1

@slagle and @jody.albritton - support suggested I contact you two about my question:

… if I have a smart app that only runs inside certain modes (let’s call them home and sunset). If a runin command is sent to turn lights off in 1 hour while in home mode, then mode changes to sleeping (and the app is not set to run in sleeping mode) will the lights still turn off when the runin timer hits 1 hour even though the app is only set to run in home mode?

Also, what happens to the states (eg state = lightison set as true). Do they sit with the app only and die when a new mode is set for which the app isn’t schedule to run?

I ask because I have created an app which I run in different modes to adjust the brightness of my dimmers.

Many thanks in advance.


Rule machine - as per the app developer, this app is no longer available for new installs, distribution, or support
(Jason) #2

I changed category to developers writing smartapps.

Unfortunately my thoughts on what happens are would be pure guesses so i’ll leave it up to one of these guys to answer.


(Tim Slagle) #3

Depends, are you using the built in mode restriction or building your own mode restriction into the app with dynamic pages?


(Tuffcalc) #4

@slagle … using the built in mode restriction. I have multiple instances of the app automating for different modes (e.g., so dimmer intensity is different during the day as opposed to night).


(Tim Slagle) #5

Then no :frowning:

You could build your own mode restriction by changing your app to dynamic pages and then you could build some logic into the mode restriction to allow runIns to run.


(Tuffcalc) #6

@slagle thanks. Might be able to workaround this a different way.

When the mode changes, do the apps all set to the new mode all initialize? Respond to modechange?


(Tim Slagle) #7

You can subscribe to a mode change:

subscribe(location, "mode", eventHandler)


(Tuffcalc) #8

@slagle doing that. So if I’m using the built in mode restriction, the dormant app in the current mode (let’s call it home) if subscribed to the mode change will run as soon as the mode is activated where it is selected to run, correct?

If that’s the case I can engineer a workaround for my case.


(Tim Slagle) #9

yep :slight_smile:


(Tuffcalc) #11

@slagle thanks for your help!