Ringer status

Post your questions and help other users.

Moderator: Martin

Post Reply
DataCrypt
Posts: 8
Joined: 21 Mar 2013 00:46

Ringer status

Post by DataCrypt » 31 Mar 2013 19:20

UPDATE: I figured this out. I didn't know I had to declare global_ variables under the "manage" part of the application. Once I created it there, I could easily get and set it in my flow. That resolved my issue perfectly. However, I do have a question regarding global variables - do their values get retained when the phone is restarted and/or the flows applications is restarted?


I have written a flow that checks the time range so that my phone ringer is silenced during the night. It triggers every 15m and checks the time range between 12am and 6am. If true, it sets the ringer to silence. Otherwise, it sets the ringer to normal. It works great, but the other day I had to turn my ringer off manually (set it to vibrate). Later, went I went to turn my ringer back on I realized that the flow had already turned it back on because I was not within that time range of my flow.

I'm not sure how to resolve this issue. I need to know if I turned the ringer off manually or via the flow. Basically if I set the ringer to vibrate or silent manually I want it to remain in that state and not have the flow change it on me (unless the time range condition is true).

My initial trials have been to set/use a variable in my flow when I silence the ringer (something like silent=1 or global_silent=1). Then when the flow triggers again, I could check that variable in other another condition/expression. Problem is that I can't see that variable I set (in a script) using either global_silence=1 or just simply n=1. It's not showing up for me to use in my condition check. If I force the flow to go back up to the condition after setting the variable, it causes a loop condition and the flow is automatically terminated.

How can I achieve what I want? Any information would be greatly appreciated.


Best Regards,

DataCrypt

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Ringer status

Post by Martin » 02 Apr 2013 13:43

Global variables are saved in a file (/sdcard/Automagic/variables.bin) and are reloaded when you stop/restart the Automagic service or the phone.

Another option to change the ringer mode is to use two flows, one flow to turn the ringer to silent and one flow to turn the ringer back to normal.
Something like this:
Flow 1
-Trigger "Time: 12am"
-Trigger "Set Ringer Mode: Silent"

Flow 2
-Trigger "Time: 6am"
-Trigger "Set Ringer Mode: Normal"

This has the advantage that it does not change the ringer setting every 15m when you manually change the ringer mode and the flows use slightly less battery since it does not wake your device from sleep every 15 minutes.

Regards,
Martin

Post Reply