How to Build Context-Aware Macros That Check Battery and Location Together Before Acting

Introduction

A macro that checks only one condition is often too eager. A low-battery routine that dims the screen and pauses sync is helpful at home, but it is unhelpful if it fires while you are navigating in an unfamiliar city and need full brightness and live maps. A location routine that silences the phone at the office is sensible, unless your battery is critically low and you are expecting an important call that you cannot afford to miss. Real life is rarely decided by a single fact. It is decided by combinations: where you are, how much power you have, what time it is, and what you are doing. Context-aware macros capture that combination, so automation acts only when the whole situation, not just one signal, says it should.

This guide shows how to build a macro that checks battery level and location together before acting, using MacroDroid’s triggers and constraints in combination. You will learn the two main designs for combined conditions, when to use each, and how to test a macro whose behaviour depends on two variables at once. The example used throughout is a practical one: a power-saving profile that applies only when you are at a known location, such as home or the office, and the battery is below a threshold. The same pattern generalises to almost any pair of conditions, and once you understand it, you will start designing all of your important macros this way, because single-condition macros are the ones that most often surprise you.

Context awareness is also a matter of trust. A user who is surprised twice by an automation will disable it, even if it worked correctly the other ninety-eight times. Checking two conditions does not make a macro perfect, but it removes the largest class of surprises: actions that were correct for one signal and wrong for the situation as a whole. That reduction in surprises is what turns automation from a clever trick into a reliable part of daily life.

Prerequisites

You need MacroDroid with location permission granted, since location constraints require it, and battery optimisation excluded for MacroDroid so its checks run reliably in the background. Choose the two conditions you want to combine, and define each precisely before building. For location, decide whether you mean a specific place, such as home, defined by a geofence or a connected Wi-Fi network, or a broader state, such as away from home. Wi-Fi-based location is often more battery-friendly and more reliable indoors than GPS alone, so consider using a Wi-Fi-connected condition as a proxy for being at home or at the office, and reserve GPS geofences for places without a known Wi-Fi network. For battery, choose a threshold that matters: twenty percent is a common low-battery line, while fifty percent suits a gentler power-saving profile that should start earlier.

Write down the desired behaviour in a single sentence before opening the editor, for example: when the battery falls below twenty percent and I am at home, enable power saving and reduce brightness. That sentence contains your trigger, your constraint, and your actions, and it prevents the common mistake of building a macro that checks the right things in the wrong roles. Also decide what should happen when the combined condition stops being true. Should power saving switch off when you leave home, when the phone charges, or both? A context-aware macro needs an exit as well as an entry, or it will leave the phone in a power-saving state long after the situation has changed.

Step-by-Step Setup

There are two clean designs for checking battery and location together, and choosing between them is the key decision in this guide. In the first design, battery is the trigger and location is the constraint. The macro triggers when the battery falls below your threshold, and it only continues if the location constraint is also true. This design is right when the battery event is the moment that matters, and location merely qualifies it. In the second design, location is the trigger and battery is the constraint: the macro triggers when you arrive at a location, and only continues if the battery is already low. This design is right when arrival is the moment that matters. Both designs check the same two facts, but they fire at different moments, and the wrong choice means the macro misses the situation entirely. For the home power-saving example, the battery-as-trigger design is usually better, because the battery crossing the threshold while you are already home is the event you care about.

Build the battery-as-trigger version first. Create a macro named Home Low Battery Saver. Set its trigger to Battery Level, configured to fire when the level drops below twenty percent, or falls to a range you choose. Add a constraint for location: either a geofence for home, or Wi-Fi connected to your home network. Then add the actions: enable power-saving behaviour through allowed settings, reduce brightness, pause non-essential sync, and show a quiet notification explaining what changed and why. Save the macro. Then build its counterpart, the exit macro, which reverses the changes when either condition stops being true: for example, a macro triggered by battery charging or by leaving the home geofence, which restores normal brightness and sync. Name the pair consistently, so they are easy to find together.

If you also need the location-as-trigger version, build it as a separate macro rather than cramming both designs into one. A macro that triggers on arrival at home, constrained by battery below twenty percent, covers the case where you arrive home already low on power, which the battery-as-trigger macro would miss, because the battery crossed the threshold earlier while you were elsewhere. Together, the two macros cover both orders of events: battery falling while at home, and arriving home already low. That completeness is the essence of context awareness: the macro does not care which condition became true last, only that both are true now.

Testing and Verification

Testing a two-condition macro requires testing all four combinations, not just the one where it should fire. Test battery low and at home, where it should run; battery low and away from home, where it should not; battery high and at home, where it should not; and battery high and away, where it should not. The three should-not cases are as important as the one should case, because they prove the macro is genuinely checking both conditions rather than accidentally firing on one. Use MacroDroid’s log to confirm each test: it should show the trigger firing and then either proceeding or being blocked by the constraint, and those log entries are the evidence that the gate works.

For practical testing, you do not need to drain your battery to twenty percent repeatedly. Temporarily set the threshold higher, such as eighty percent, for testing, so your normal battery level satisfies the low condition, then restore the real threshold afterwards. Similarly, test the location condition by toggling Wi-Fi or by using a test geofence near your actual location, rather than travelling to a distant place. Test the exit macro as well: charge the phone or leave the geofence, and confirm the phone returns to normal settings. Test the pair together over a day of normal use, and check the log in the evening for any unexpected firings or missed firings.

Troubleshooting

If the macro never fires, determine which half is failing. Check the log: if the trigger never appears, the battery trigger is misconfigured or the threshold has not been crossed. If the trigger appears but the macro is blocked, the location constraint is failing, which usually means location permission, a geofence that is too small, or a Wi-Fi network name that does not match exactly. Geofences drawn too tightly around a house often fail indoors, because GPS accuracy indoors is poor; widen the geofence or switch to a Wi-Fi-based condition for home and office locations. If the macro fires when it should not, one of the conditions is broader than you intended: a Wi-Fi condition matching any network with a similar name, or a battery range that includes your normal level during testing.

If the entry macro works but the phone stays in power-saving mode afterwards, the exit macro is missing or its trigger does not match the change you made. Every context-aware entry needs a tested exit, and the exit should trigger on either condition changing, not just one. If two macros fight, for example a home power saver and a separate brightness macro, check their constraints for overlap and give one of them priority by narrowing its conditions or adding a variable that records which profile is active. Finally, if location checks drain the battery, prefer Wi-Fi-based location over continuous GPS, and avoid very small geofences that force frequent location updates.

Tips for Better Context-Aware Design

Start with two conditions, not four. A macro that checks battery and location is already far smarter than a single-condition macro, and adding time, day, and activity conditions too early makes testing exponentially harder. Once the two-condition macro is reliable, add a third condition only if a real surprise justifies it, and test all combinations again. Use variables to record context explicitly: a variable that stores Home, Away, or Unknown, updated by dedicated location macros, lets other macros check location by reading a variable instead of querying location directly, which is faster and easier to debug.

Name context macros after the situation, not the mechanism, so Home Low Battery Saver is better than Battery Trigger Location Constraint One. Situation names make the macro list readable as a description of your life, not as a technical inventory. Consider adding a gentle notification the first time a context macro fires in a new situation, then silencing it once you trust it, so you learn what the macro does without being notified forever. And review context macros when your routine changes: a new job, a move, or a new phone can change what home means, what low battery means, and which combinations still make sense.

Frequently Asked Questions

Should battery be the trigger or the constraint?

It depends on which event matters most. If the battery crossing a threshold while you are already in a place is the key moment, make battery the trigger and location the constraint. If arriving somewhere while already low is the key moment, reverse them. For full coverage, build both macros.

Is Wi-Fi or GPS better for the location condition?

Wi-Fi is usually better for home and office, because it is reliable indoors and uses less power. GPS geofences suit places without a known Wi-Fi network, but they need a generously sized radius to work indoors.

Why does my macro fire at home but not at the office?

The location condition likely matches only your home network or geofence. Add the office network or geofence as an additional allowed location, or build a parallel macro for the office with the same battery threshold.

How do I test a low-battery macro without draining my phone?

Temporarily raise the threshold during testing, so your current battery level satisfies it, then restore the real threshold afterwards. Always re-check the threshold after testing, since a forgotten test value is a common cause of strange behaviour.

What if both conditions are true but the macro still does not run?

Check the log for a constraint block, verify location permission and battery optimisation exemptions, and confirm no third constraint, such as a time window, is silently blocking the macro. Test each condition separately to isolate the failing half.

Leave a Comment