Page 1 of 1
Trigger timer vs. display
Posted: 12 Sep 2017 12:03
by yogi108
Hi,
I have uploaded a countdown flow, works with a widget.
It triggers every minute for updating the widget. Even if the display is off, it triggers, not every minute, but a few minutes. The trigger is shortened to work only from 6am till 10pm and does not wake up the device because not needed.
Now the idea and question:
I created a 2nd flow which activates/deactivates the countdown flow depending on the display state, so the use of resources is less - or is it useless in comparison with all the other events from AM ?
See the flow:
Re: Trigger timer vs. display
Posted: 12 Sep 2017 14:13
by Bluscre
https://gyazo.com/42de18ab1b8226edc8db5585dbf79fd8.png
This script action makes absolutely no sense lol
Also i would suggest giving global variables more unique names. Imagine a second flow having a global count and wanting the same name?
3rd thing is, if you want to show something either send the flows themselves or atleast change your AM language temporarily to english in the settings.
Re: Trigger timer vs. display
Posted: 12 Sep 2017 16:06
by Desmanto
The second flow will save your battery a bit. It is preferred, since anything which can be done to save the battery life is always welcome. Of coz, consider the time needed. For simple toggle flow like this, time is not a problem, so go ahead.
For countdown trigger flow, I see there is only 2 triggers. If the function is just to toggle, you don't need that many conditions. You only need single condition expression to check if the triggers is Display on. True branch enable the countdown, false branch disable the countdown. Total 1 condition, 2 actions. I love to create toggle like this.
For countdown flow, when you have a lot of Action Script and Expression chaining together, you can compact them into single script action only. For example expression
widget_cell_x==0 can be change into single block script
Code: Select all
if(widget_cell_x==0)
{
//paste the script of the true branch
}
else
{
//paste the script of the false branch
}
This is the feature that other similiar automation app don't have, scripting block.
Of course, for first time when creating the flow, you might need to split it as your current flow. Since it is easier to attach debug dialog to the problematic part. But after you have confirmed the script is working fine, it is time to make it more efficient.
Re: Trigger timer vs. display
Posted: 12 Sep 2017 17:50
by yogi108
Hi,
@Bluscre
In this case the focus was on the trigger, so the screenshot was cut by me.
The original flow is at
http://automagic4android.com/forum/view ... 957#p19001
@Desmanto
You got my question answered and more. The countdown flow needs more branches, is not only stop and go. And I need the debug condition very often...
Every day with the help of the community I get more information, thanks a lot for your investigation, both of you.
English is poor on my side, but I think you got the point,
Regards
Re: Trigger timer vs. display
Posted: 13 Sep 2017 12:14
by yogi108
Hi,
@Desmanto
Inspired through your feedback I did some research. The widget should only be updated, if the home screen where it resides is active.
With the trigger UI and some regex it did the trick just entering the page no 6 where the widget resides and leaving from page 6 it stopps and deactivates the flow.
So now no separate resources are used, even no timer trigger.
Nova Launcher is used,
Thanks a lot
Re: Trigger timer vs. display
Posted: 13 Sep 2017 15:12
by Desmanto
Well done. The flow will be much more effective and efficient then. I also frequently revisited my bigger flow to check if i can make it more efficient.