WiFi SSID Trigger Battery Friendliness

I'm trying to make a macro that triggers upon connecting and disconnecting from my work WiFi. Basically the working is this:

  1. When connected to work WiFi SSID, change DNS server from DNS over TLS server (Adguard, NextDNS) to DoH (dns.google or cloudflare). The context is that for whatever reason I've found my work WiFi doesn't like me using any adblocking DNS server and in fact any DNS over TLS server (even Cloudflare). I've experimented and it seems the automatic option/off or a DoH server like Google/Cloudflare seems to work fine. Given how Android seems to only allow 2 pre-programmed DoH server addresses and nothing else, I have no choice but to use either Google/Cloudflare.
  2. If the existing DNS server is not dns.google or cloudflare-dns.com, then change DNS to Cloudflare; store existing DNS server in a variable.
  3. Upon disconnect from WiFi SSID, restore the old DNS server.

I'm coming from the Tasker world where I had a trigger in Tasker upon connecting to work WiFi to execute #3 and then an exit task to execute #4. My understanding is Macrodroid doesn't have exit tasks so in reading some guides, I was told to just have both connect and disconnect triggers in one.

What I've noticed is that in my permissions log, MacroDroid accesses my location a lot--yes I know that it needs location permissions to find out the connected WiFi SSID, but in trying to compare with my old phone which is still using the same Macro/Profile but, a Tasker version of it, MacroDroid is basically checking my location every 5 minutes whereas Tasker only does it pretty sparingly.

Is there a reason why MacroDroid has to ping location so much? Is my Macro horribly written for efficiency?

Let me know if it's more effective for me to just upload my macro here for troubleshooting
 

lusi

New member
I'm trying to make a macro that triggers upon connecting and disconnecting from my work WiFi. Basically the working is this:

  1. When connected to work WiFi SSID, change DNS server from DNS over TLS server (Adguard, NextDNS) to DoH (dns.google or cloudflare). The context is that for whatever reason I've found my work WiFi doesn't like me using any adblocking DNS server and in fact any DNS over TLS server (even Cloudflare). I've experimented and it seems the automatic option/off or a DoH server like Google/Cloudflare seems to work fine. Given how Android seems to only allow 2 pre-programmed DoH server addresses and nothing else, I have no choice but to use either Google/Cloudflare.
  2. If the existing DNS server is not dns.google or cloudflare-dns.com, then change DNS to Cloudflare; store existing DNS server in a variable.
  3. Upon disconnect from WiFi SSID, restore the old DNS server.

I'm coming from the Tasker world where I had a trigger in Tasker upon connecting to work WiFi to execute #3 and then an exit task to execute #4. My understanding is Macrodroid doesn't have exit tasks so in reading some guides, I was told to just have both connect and disconnect triggers in one.

What I've noticed is that in my permissions log, MacroDroid accesses my location a lot--yes I know that it needs location permissions to find out the connected WiFi SSID, but in trying to compare with my old phone which is still using the same Macro/Profile but, a Tasker version of it, MacroDroid is basically checking my location every 5 minutes whereas Tasker only does it pretty sparingly.

Is there a reason why MacroDroid has to ping location so much? Is my Macro horribly written for efficiency?

Let me know if it's more effective for me to just upload my macro here for troubleshooting

Hello,

I am in the exact same boat as you... and I see you didn't get any response.
I want this automation to preserve some battery when being home as my 4G signal is very bad and Wi-Fi alone is fine even for calls and messages. But I don't want to consume more battery when trying to same it because of the location being permanently accessed by macrodroid...
The thing is macrodroid is suuuper intuitive and fun to use whereas tasker is... well you know....
But, is tasker better in terms of battery drain or location access for this Wi-Fi triggered automations? If yes, I'll probably try to migrate my automations to tasker...

Thanks!
 

MacroDroidDev

Administrator
Staff member
In general there is no reason either Tasker or MacroDroid should be better than each other in terms of battery drain and it will entirely depend on what automations you have running and how you have configured them.

It's impossible to say why MacroDroid accessed the location in the OPs setup without all seeing all configured macros. The only significant battery drain would come from MacroDroid requesting to obtain a location fix, and unless you are using the location/geofence trigger or constraint this should be not be happening in any case.
 

lusi

New member
In general there is no reason either Tasker or MacroDroid should be better than each other in terms of battery drain and it will entirely depend on what automations you have running and how you have configured them.

It's impossible to say why MacroDroid accessed the location in the OPs setup without all seeing all configured macros. The only significant battery drain would come from MacroDroid requesting to obtain a location fix, and unless you are using the location/geofence trigger or constraint this should be not be happening in any case.

Hello,

So here you have mine. Please, let me know what I am doing wrong....
As you see, I use two macros:
One in case I am home and get connected to my home SSID and then activate airplane mode and the other in case I go out and then when being disconnected from home SSID, airplane mode is turned off so I can switch to data/gsm.

As you also see, I've forced in the "trigger options" of macrodroid the "never" update in background, but still...in privacy panel you can see location requests every 5 min (last screenshot).

I've also tested to use the "IP address change" trigger, it works when coming from 4G to Wi-Fi but not the other way around as when Wi-Fi gets disconnected, as being in airplane mode, I get no IP and even when trying to match the empty field it doesn't match the trigger.

Any help is more than welcome.

photo_2024-03-11 16.24.33.jpeg

photo_2024-03-11 16.24.36.jpeg

--> Here I just disable the first macro during 20seconds to avoid loops meanwhile WiFi gets connected, otherwise the first macro thinks I am disconnected from Wi-Fi and triggers. With this it's fine.




photo_2024-03-11 16.22.13.jpeg


photo_2024-03-11 16.22.14.jpeg
 
Last edited:

MacroDroidDev

Administrator
Staff member
So just to be clear do you have a problem with the macro not working or are you just concerned about the location usage access? I will need to do some experimentation to see if I can recreate this with a similar macro to try and figure out what is going on.
 

lusi

New member
So just to be clear do you have a problem with the macro not working or are you just concerned about the location usage access? I will need to do some experimentation to see if I can recreate this with a similar macro to try and figure out what is going on.

Macros works fine, it's about the constant location checking and due to this location being constantly checked I am not using the macros... :-(

I've come up with an alternative approach, which is having a script pinging an internal IP in my LAN every 2min and doing the actions depending on the results (see below).
Would you please tell me what would be the most battery efficient approach? The SSID triggered based which is checking location every 5min (see above) or the script doing a ping every 2 min (below)?

Thanks in advance for your help, I'll be waiting for your feedback.

photo_2024-03-11 22.01.25.jpeg

photo_2024-03-11 22.01.27.jpeg
 
Last edited:

lusi

New member
@MacroDroidDev , any update?

It appears macrodroid does not specifically requires localtion to use Wi-Fi connects/disconnects trigger. It requires location ONLY to match the specific SSID. I discovered this in a tasker forum as it operates the same way. However, as per my tests, you need to grant location access to "macrodroid" even if the "location" is completely disabled at phone level, it will work. If you do not provide location permissions to macrodroid, it won't.
 

MacroDroidDev

Administrator
Staff member
@lusi Apologies, I did setup a phone with this setup with the intention of review the location requests made over an extended period and then forgot about cleaned the installation and got on with other stuff.

I'm going to try again to see if I can see this level of location requests happening.
 

lusi

New member
@lusi Apologies, I did setup a phone with this setup with the intention of review the location requests made over an extended period and then forgot about cleaned the installation and got on with other stuff.

I'm going to try again to see if I can see this level of location requests happening.

Ok, I'll wait for your feedback please.
You will see that as soon as you have a macro matching an SSID, this will cause location to be checked every 5mik for some reason.
 

MacroDroidDev

Administrator
Staff member
@lusi This may seems like a dumb question but how do I get to that location usage history screen you have screenshot. I've searched through the settings on a couple of different phones and all I can seem to find is the last time it was accessed by MacroDroid. I guess it might be specific to a specific manufacturer so could you let me know what device and OS version this is as well please?
 

lusi

New member
@lusi This may seems like a dumb question but how do I get to that location usage history screen you have screenshot. I've searched through the settings on a couple of different phones and all I can seem to find is the last time it was accessed by MacroDroid. I guess it might be specific to a specific manufacturer so could you let me know what device and OS version this is as well please?

@MacroDroidDev
Well, on pixel at least you have something called "privacy panel".
Security & Privacy -- Privacy - Privacy Panel - Location. There you have the last 24h access.
 

MacroDroidDev

Administrator
Staff member
@lusi Thanks for that, found it now. I always find it astonishing how bad the search feature in the Android settings app is, such that you can search for a title of a screen within the settings and it doesn't actually give you anything related to that screen or any means to get there.
 

MacroDroidDev

Administrator
Staff member
Sorry for the delay again. I have looked into what could be causing the location to be obtained by MacroDroid. I'm not seeing the kind of regular updates that you are seeing coming from MacroDroid, but I do note that on startup I see the location obtained and this appears to be coming from my crash reporting library so it can report the location of the user should a crash occur. I've been absolutely hammered with emails and other issues in the last week so I'm finding it very difficult to get a large chunk of time to look further at this but I will aim to keep testing over the long term to try and recreate the kind of regular location updates you are noticing.
 
Top