Order of actions in automations / scenes

After migration of routines into automations and scenes, I have been having an issue with a smartapp that I wrote years ago.

I call the app “Thermostat Nanny” and it keeps an eye on our thermostats during Night mode. This was a workaround after SmartThings support could not figure out why my Centralite thermostats would sometimes randomly change their heating / cooling setpoints. If this happens during the night, it gets too hot in the house and really affects our sleep.

The app basically only runs when mode is Night and will not allow the thermostats to go above a set value.

We have a good morning scene that is triggered by an automation. The scene does a number of things, amongst others setting the thermostats back to day mode and also changing the mode to day mode. However, it seems that it does the day mode last. So when the scene sets the thermostats while the mode is still night, then the nanny immediately sets it back. So then the thermostats are stuck in night mode.

I’ve never had issues with this in the past.

Is it possible to order the sequence of what happens during a scene? I could not see an obvious way of doing this.

Plan B is to change the smart app.

It sounds like the hub mode isn’t changing? You can’t “reorder” the action manually but you can it while recreating the automation, it’s basically ordered by what you add first. So you can try that.

If the mode still isn’t changing I would recommend report it to support@smartthings.com (I’ve seen this happen a few times typically when the platform is undergoing maintenance or having an outage).

If the mode is changing (you can verify this from the new ST app under Manage Location), then the SmartApp may be having an issue. You can try looking at other SmartApps with which offer similar functionality to “hold” the temperature setpoints for the duration of a schedule or hub mode, here are two examples:

Thanks for the reply. The hub is changing modes ok. The nanny smartapp subscribes to the setpoint changes of the thermostats and changes them back to a minimum cooling or heating (set in preferences), if they change above the set levels. Before executing, the event handler checks if the mode == night.

What is happening now, is that when the scene sets the setpoints back to day temperatures, the nanny’s event handler gets called. When it checks if the mode == night (which should not be true, because the scene also changes the mode to day), the mode is still night, and the nanny changes the setpoints back.

If I run the morning scene again manually, then this time the hub is now properly in day mode, so the nanny won’t interfere. It’s a pretty common race condition and I am assuming it is because the scene first changes the thermostat set points and then changes the mode. So this is probably an issue with any app that uses modes to restrict things and subscribes to device events that may be set in different scenes that also changes modes.

I don’t want to have to set my temps in multiple places so I don’t really want to have the nanny subscribe to mode changes to work around this. The simple code fix is to change the app to not run after, say, 4AM, since we rarely get up that early. But I was hoping there’s a no-code fix :slight_smile:

Ah that’s tricky, yeah I see your issue with the race condition. You can try the steps I outlined above but there’s no guarantee that it’ll work the exact order due to timing issues. Ideally your SmartApp would have to handle that (or you can see the apps linked above which are designed to handle these and other issues like mesh failures with retries etc).