How to save/restore state?
Posted: 10 Mar 2020 14:56
I'm coming from Tasker and currently try to switch over to Automagic. In Tasker when you change stuff inside of a profile, by default when the profile is deactivated the state is restored automatically to the state it had when activating a profile.
For example I want to automatically activate do not disturb mode (DND) when a specific app is opened and I want to set it back to the state it was once the app is deactivated or closed. So if my phone was already in DND mode when I activate the app, it will stay in DND mode when I deactivate the app. But if my phone was not in DND mode before i activated the APP, it goes into DND mode when I activate the app and once i close the APP it goes back to normal mode. In Tasker this state restoration is automatically built into the tasks.
Since there are no profiles in Automagic, I figured I would need two flows for this, one to be triggered when the app is activated which activates DND mode and a second one to be triggered when the app is deactivated which would restore the sound profile to how it was. However I don't know how I would restore the correct setting of the DND state in the second flow. I know that I can set variables but I didn't find any action to actually read the current sound profile so I could store it into some variable and later restore it from there.
Saving and restoring state seems to be a common thing with automation so there is probably a nice and easy way of doing this with Automagic, but it would seem I have not yet found it. Would someone please enlighten me about how to do this properly with Automagic?
For example I want to automatically activate do not disturb mode (DND) when a specific app is opened and I want to set it back to the state it was once the app is deactivated or closed. So if my phone was already in DND mode when I activate the app, it will stay in DND mode when I deactivate the app. But if my phone was not in DND mode before i activated the APP, it goes into DND mode when I activate the app and once i close the APP it goes back to normal mode. In Tasker this state restoration is automatically built into the tasks.
Since there are no profiles in Automagic, I figured I would need two flows for this, one to be triggered when the app is activated which activates DND mode and a second one to be triggered when the app is deactivated which would restore the sound profile to how it was. However I don't know how I would restore the correct setting of the DND state in the second flow. I know that I can set variables but I didn't find any action to actually read the current sound profile so I could store it into some variable and later restore it from there.
Saving and restoring state seems to be a common thing with automation so there is probably a nice and easy way of doing this with Automagic, but it would seem I have not yet found it. Would someone please enlighten me about how to do this properly with Automagic?