Hello Home, I'm Back - Set different modes based on time?

@tamaracks No problem! Make sure you “publish” the app when you grab the new code just saving it won’t push the changes to the smart app

I think maybe I didn’t save the new code last time. I could have sworn that I did, but apparently not. I just tried updating the code again (and published again, which I know I did before) and this time it worked.

Just curious, do you know if the push notifications are still down? It seems that it is to me, because if I try to change the push setting in Magic Home to yes, I get the unexpected error again. I guess I keep fearing it’s just me.

Looks to be broken still. I’ll see if I can get an update from support

Good to know, thanks.

Seems good. I updated the code and I was then able to go into the settings and turn push notifications on without error. I’ll keep an eye on it next time I leave the house to see if it notifies.

Glad to hear about the other change too! It’ll be nice not to get two notifications in a row when my husband and I arrive home together. Of course he’s traveling and then I’m traveling, so we won’t both be home together for a little while, but I’ll let you know if I see any issues once we are.

Thanks again!

@tslagle13 I have a quick question here. I noticed you’re asking for the modes explicitly.

When I write an app, even if I don’t ask for a mode input the app presents with me an option to select the mode(s). I was under the impression that the app only works during the scheduled mode. However while testing I noted that the apps works (e.g. scheduling and changing temp) no matter what what mode I select.

Do I need to handle the modes myself? If so what’s the purpose of the default modes? Also - how does one get the default modes that the user selected ?

@minollo would like your thoughts also on your experience.


Okay I’m going to try to answer my own question, apparently it does work but ONLY when not a Installed or Update command. IE it will run when installed or updated but subsequent schedules and notifications only happen when it is within the user select mode (default options). So one doesn’t really need to handle the modes unless you need to address it in install or update.

Which still bring me to the question - how does one programatically access those default user selections?

Im not sure I understand the question here. What default selections are you talking about?

Maybe a little background would help, what exactly are you trying to do?

Are you talking about the “Only when mode is” setting, which is used for all apps? My understanding that’s something that the framework itself handles, and it will prevent the application from receiving/processing events unless the mode is what is set in that configuration. I rarely use it, other than for temporarily disabling an app (for which I use a “Never” mode which I created ad-hoc, and never set).

That’s correct @minollo, the Only when mode is settings is something all the apps have. That’s what I was commenting about. Apparently it always invokes install and update but doesn’t seem to invoke schedules and subscriptions if the modes don’t match.

But my question is how do I access that setting/variable?

I’m not aware of any way to access it; and, considering your app won’t fire anyway when not in the right more, I’m not sure I understand the reason for trying to access it; it’s a “framework level” setting.

Reason being like I had said the Install and Update methods, check the mode before setting the temperature for example.

if you wanted an app to change a temp on install you’d have to write that logic into the code.

Sorry let me clarify, I just published 2 apps, one that changes temperature based on the 5-2 day week and one that changes temperature based on motion sensors.

Now if the user configures teh apps to only work in say night mode, I want to be able to catch that in teh install/update sections so that the app doesn’t end up modifying the temperatures on install/modify (those routines do initiate a change at load) if the current mode doesn’t match what the user selected. But how do I access that variable that which I don’t ask the user but the platform by default allows the user to set (mode)?

Ok I think I understand now. You want to not have to ask the use for the mode but not run it on install during a certain mode?

If this is what you are meaning then then there is no default “home” mode or something like that. You’d have to ask the user which mode to restrict the logic during.

Does this help? Would a code example help?

Yes and No.

Yes as in I want to know what modes the users selected.

No as in I don’t have a variable, the platform by default includes the options to select modes with ALL apps. I want to be able to access those modes the user selected (which the platform presented)

No way to access those. That’s why I ask for them in another field.

darn, was pretty sure it might exist as a hidden feature

@tslagle13: This is exactly what I’ve been looking for - thank you. One question I have, however… how does this interact with other modes / phrases that aren’t included in your code? For example, when I go to bed, “night” mode is set when there is no motion for [x] minutes. Then, I have a “middle of the night” mode, that is activated by a motion sensor in my bedroom - it sets lighting and kills the alarm if I get up in the middle of the night between certain times.

Will your app overtake these modes based on presence awareness? I think the answer to this is no, but I wanted to be sure.

Also, how difficult would it be to add the “[x] minutes before/after sunrise/sunset” logic here?

Thanks again. This is (potentially) perfect.

Will only affect the phrases you select in the app.

Really, exponentially difficult. I’d have to re work the entire logic for the code. I’m assuming you are asking because you want your house to start turning on lights when it gets dar outside a little earlier. You can add that to your “Home Night” phrase by adding a sunset trigger in there and offsetting it, but restricting it to run only when in “Home Day” mode.

1 Like