Trigger timer vs. display

Post your questions and help other users.

Moderator: Martin

Post Reply
User avatar
yogi108
Posts: 100
Joined: 09 Nov 2016 08:00
Contact:

Trigger timer vs. display

Post by yogi108 » 12 Sep 2017 12:03

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:
Attachments
trigger_20170912-135855.png
trigger_20170912-135855.png (56.5 KiB) Viewed 17119 times
flow_20170912-133941~01.png
flow_20170912-133941~01.png (64.23 KiB) Viewed 17119 times
"You cannot know the meaning of your life until you are connected to the power that created you.”
Shri Mataji Nirmala Devi, founder of Sahaja Yoga

User avatar
Bluscre
Posts: 145
Joined: 31 Aug 2017 13:58
Location: Germany
Contact:

Re: Trigger timer vs. display

Post by Bluscre » 12 Sep 2017 14:13

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.
Unofficial AutoMagic Telegram Group: https://t.me/automagicforandroid
Check out my other flows here: https://github.com/Bluscream/AutoMagicFlows or here.

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Trigger timer vs. display

Post by Desmanto » 12 Sep 2017 16:06

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.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
yogi108
Posts: 100
Joined: 09 Nov 2016 08:00
Contact:

Re: Trigger timer vs. display

Post by yogi108 » 12 Sep 2017 17:50

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
"You cannot know the meaning of your life until you are connected to the power that created you.”
Shri Mataji Nirmala Devi, founder of Sahaja Yoga

User avatar
yogi108
Posts: 100
Joined: 09 Nov 2016 08:00
Contact:

Re: Trigger timer vs. display

Post by yogi108 » 13 Sep 2017 12:14

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
Attachments
trigger_20170913-140139.png
trigger_20170913-140139.png (41.29 KiB) Viewed 17055 times
"You cannot know the meaning of your life until you are connected to the power that created you.”
Shri Mataji Nirmala Devi, founder of Sahaja Yoga

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Trigger timer vs. display

Post by Desmanto » 13 Sep 2017 15:12

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.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Post Reply