Need help with battery charging reminder macro

Bubs

New member
I want to make a notification that repeats every x sec/min when the battery level drops to 20%. If I plug in the power the notification stops. If I click the notification it snoozes for x mins and stops if it detects power before it wakes again. When the battery level reaches 80% I want it to notify me every x secs, no snoozing, and when I unplug the power it stops and resets.

Is this possible to do? Any help would be greatly appreciated.
 

Pseudocyclic

Well-known member
MacroDroid can do what you have described.

If you're new to MacroDroid, try starting by creating a macro to accomplish any one part of what you have described. Then when you've got that working, add another part - and so on.
 

Bubs

New member
I've tried. It's way too complicated for me. don't understand how to add multiple triggers and actions and connect them the way I want.
 

Dm114

Well-known member
I've tried. It's way too complicated for me. don't understand how to add multiple triggers and actions and connect them the way I want.
Don't give up! What you want to do is very simple. Attached is a very simple example of how to begin with...
 

Attachments

  • Screenshot_20210505-053452_MacroDroid.jpg
    Screenshot_20210505-053452_MacroDroid.jpg
    405.3 KB · Views: 72

Bubs

New member
Don't give up! What you want to do is very simple. Attached is a very simple example of how to begin with...

I never would have come up with even that. I have next to no experience with programming. If it's not too much trouble could you share how to do it? I have no clue how to make repeating alerts and a snoozing notification.
 

dsnz

Well-known member
even though you can do it perfectly in macrodroid, just for this application there are ready made apps and you should use them, macrodroid is for customized situations that you can't find an app in play store

almost all of what you want can be done by

"Battery Charge Notifier" by Utopi
(totally free)

but it would be a good tutorial if you did this in macrodroid, step by step

start with a single notification when battery is outside limits
exactly as dm114 gave you example code

then, instead of a timed repeat , the same code will repeat when battery level falls (or rises) 1% (because of the trigger), it's simpler and with same result (saves you from going far over limits), then once you understand better what's happening you can improve it in small steps
 

Dm114

Well-known member
even though you can do it perfectly in macrodroid, just for this application there are ready made apps and you should use them, macrodroid is for customized situations that you can't find an app in play store

almost all of what you want can be done by

"Battery Charge Notifier" by Utopi
(totally free)

but it would be a good tutorial if you did this in macrodroid, step by step

start with a single notification when battery is outside limits
exactly as dm114 gave you example code

then, instead of a timed repeat , the same code will repeat when battery level falls (or rises) 1% (because of the trigger), it's simpler and with same result (saves you from going far over limits), then once you understand better what's happening you can improve it in small steps
You are a good teacher! Hope Bubs will take into account our advices and won't give up.

You are right it's not necessary to repeat alert messages on a time basis but on every change in battery level instead.

According to your advice to load a free app to manage battery alerts, I'd rather say that we all should use MD and write our own routines instead of using 'foreign' apps. MD is so powerful that I think we should use those apps only when it's technically not possible to achieve a specific task. Moreover, it prevents from flooding memory with apps performing a large number of tasks of which only a small part is useful. It's my opinion because I love MD and... I don't want to run short of RAM! 😂
 

Bubs

New member
then, instead of a timed repeat , the same code will repeat when battery level falls (or rises) 1% (because of the trigger), it's simpler and with same result (saves you from going far over limits), then once you understand better what's happening you can improve it in small steps

I want a repeated alert in case I miss the first notification. I don't want to wait until the battery falls or rises another 1%. I also want to be able to snooze the alert notification if I can't charge my phone right away and want to be reminded later.

I also asked for help on reddit and someone responded with general steps on how to do it.

They said:

1. Trigger : Below 20%. Action : Turn on Macro 2

2. Trigger : Stopwatch 1. Action : If Stopwatch 1 reaches 0, display a notification to remind charging then reset the timer, keep the timer enabled. If notification is clicked then activate Macro 3.

3. Trigger : None. Action : Runs Stopwatch 2 and pauses Stopwatch 1. If Stopwatch 2 reaches 0, add another if / else to check if the phone is connected to a power source or not, if yes then reset the Stopwatches, turn all Macros related to charging notification off, else continue Stopwatch 1 and repeat.

With disconnecting charger notification, it should be the same but only with 1 timer.

I'm not sure if he made a mistake on #3 and I was supposed to add Stopwatch 2 to Trigger. This is what I've come up with but I have no way to test if it's correct because I have to wait until the battery level drops to 20%.
 

Attachments

  • macro 1.png
    macro 1.png
    113.3 KB · Views: 18
  • macro 2.png
    macro 2.png
    166.3 KB · Views: 22
  • macro 2 notification.png
    macro 2 notification.png
    161.8 KB · Views: 15
  • macro 3.png
    macro 3.png
    260.5 KB · Views: 12
  • battery 80.png
    battery 80.png
    195.2 KB · Views: 13

Bubs

New member
You can test with any value, doesn't have to be 20%. Then switch to 20% when you've finished testing.
oh right thx

Edit: didn't work. nothing happened when changed macro 1's battery level to higher than my current. I think I'll just download the app dsnz recommended. I'm not trying to start a new hobby in programming. I just want something right away.
 
Last edited:

Bubs

New member
almost all of what you want can be done by

"Battery Charge Notifier" by Utopi
(totally free)

I tried this and it seems to work well and do almost everything I want. It doesn't have the snoozing notifications but I can live without that. I like that I can have separate notification sounds for the low and high battery level. Thanks a lot for the recommendation. It's too bad I couldn't get Macrodroid to work. I know you all wanted me to figure it out myself but not all of us have the patience or know-how to do this. Thx for all the tips.
 

dsnz

Well-known member
I must repeat, it can definitely be done with macrodroid, but it's just not simplistic (an if then else),
it needs some loops, 1-2 variables, perhaps 2+ macros would be better, careful thought and planning etc.
so it's kinda medium-advanced project

you said you "are not trying to start a new hobby in programming" :D and macrodroid (and all other automation software) needs programming in the end (but macrodroid is by far the easiest one to use !)
[ and unfortunately I don't feel the need to do this project for myself because I already use the app I recommended to you :D ]
 

Bubs

New member
Medium-advanced project. So I have no chance to do it anytime soon lol. I was open to some basic programming but not something that would take me days or weeks. It's fine though. I'm happy with Battery Charge Notifier. Thx again!
 

XRT

New member
I want to make a notification that repeats every x sec/min when the battery level drops to 20%. If I plug in the power the notification stops. If I click the notification it snoozes for x mins and stops if it detects power before it wakes again. When the battery level reaches 80% I want it to notify me every x secs, no snoozing, and when I unplug the power it stops and resets.

Is this possible to do? Any help would be greatly appreciated.
This should get you started.
In the Triggers section:

Battery Level Trigger:
Battery <= 20%

In the Actions section:

IF Action
If Battery < 21%

Display Notification Action
Battery is [battery] % at [hour]:[minute]
End IF

When the battery gets to 20% or below it will "trigger" the macro.
The IF action says if the battery is < 21% then display this notification for example "Battery is 20% at 10:15.
When you plug in the charger and the % goes up the trigger and If Notification won't be true and will stop.

Think about a change in battery level inside the IF action and a Wait Action and a Loop.
See if that is a start. Let me know.
 

Bubs

New member
This should get you started.

Thx for the tip but I've already downloaded a separate app that I like that does most of what I want. Like I said in my last reply I wasn't looking to spend days/weeks trying to learn this.

When you plug in the charger and the % goes up the trigger and If Notification won't be true and will stop.

Isn't it better to use the If Power Connected condition so it detects it right away instead of waiting for the % to go up?
 
Top