Wifi switch and Mobile Data toggle problem

Discussion in 'Tasker' started by Lange_666, Oct 21, 2016.

  1. Lange_666

    Lange_666 New Member

    Joined:
    Oct 21, 2016
    Messages:
    10
    Likes Received:
    1
    Android Marshmellow + rooted.

    I'm using (like so many) a few profiles/taks to switch from Mobile Data to Wifi when i get home and back when i leave home. Works pretty nice but... not all the time.

    The reason behind this is the difference on how Wifi and Mobile Data are activated. If changed both manually (via the drop down menu) both act as a toggle. But within tasker this behaviour changes. Wifi has an On / Off option, Mobile Data has to but that doesn't work anymore since Google changed the activation for Mobile Data which means that you can only set it with the help of Active Input and that turns it into a toggle. And this creates a syncronisation problem between Wifi and Mobile Data.

    I'll explain the difference:

    If i set Wifi to ON Wifi goes ON. If i set Wifi again to ON, Wifi stays ON. It will only go OFF when i set it to OFF. It behaves as a physical switch.

    Mobile Data however does not. If i activate Mobile Data through Active Input and it's OFF, it will go ON. And when it's ON it will go OFF. It behaves a toggle.

    Now this works OK as long as everything is in sync. If Mobile Data is ON and i reach home, Wifi is turned ON, i get the connected signal and Mobile Data is turned OFF. Same goes the other way, if i leave home, Wifi connection is lost and Wifi is turned Off. When the connection is lost Mobile Data is turned On again. Works nice. But this can get out of sync because of the switch/toggle behaviour.

    Example: If i'm home, Wifi is ON and Mobile Data is OFF. If i turn Wifi OFF manually , the connection is lost and Mobile Data comes ON. If i turn Wifi back ON, Mobile Data goes OFF again. But the other way there is a problem. If i'm not home and turn Mobile Data OFF somewhere and reach at home, tasker sees this, turns on Wifi and "toggles" Mobile Data to be OFF but since it's a toggle action, Mobile Data will come ON instead and both are then ON. And from then on the nice syncronisation between Wifi and Mobile Data is gone.

    This manual override (like i like to call it) also doesn't update the variable i use which is logical since the Mobile Data wasn't "toggled" through Tasker.

    I tried to solve this with a double variable check together with a variable i set when Mobile Data is connected (2G,3G,or 4G) and then toggle Mobile Data according to this and set/reset the variables but while this should work better in theory, it still doesn't work all the time because indoors, Mobile Data connection can be lost and then the Mobile Data toggles again to a state i don't want again setting a desyncronisation between Wifi and Mobile Data. In fact, due to this the syncronisation has become more unstable. So i removed the Mobile Data connected part again.

    Questions: - Is there a way to make Mobile Data work as a switch instead of a toggle? - If not, is there a way to detect is the Mobile Data button has been touched (and that i could use as a variable)?

    rbrtryn over at Subreddits to use AutoInput Query but:

    I'm afraid that's a bit above my head. Since he/she posted this i'm searching on how to get the Query thingy from AutoInput to work (or how it works at all. Period...LOL) and i'm still not one step further. I did not find a decent guide to AutoInput UI Quiry (all links almost point to the joaoapps pages but once there i don't find what i'm looking for. There's a video (and on youtube a few more) but they don't make me much wiser. I also downloaded an example task (to get the value of the brightness setting of the display and set it accordingly) and imported it into tasker but i have no clue how it exactly works and more, certainly no clue where to look or how to read/set the needed variables. I can make it run, i can look into the task and into AutoInput setup but for there on it's all Chinese. I have no clue what each thing does or is supposed to do.

    If i try to use AI Query for my own problem i don't get further then the configuration screen and then Manuel Setup (for the Variable setup). If i tap that i get a Screen Capture notification screen that tells me it goes "Opening notification tray now". If i press the Close button it open the notification screen for half a second and closes it again. And that's where i'm stuck. Since then i'm searching the net on a how to or a decent guide but... nothing.... :-(


    Another answer i got was to use shell commands but they even more way out of my league
     
  2. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    Just to clarify, you want a task to turn on mobile data independently of the state it's in?
     
  3. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
  4. Lange_666

    Lange_666 New Member

    Joined:
    Oct 21, 2016
    Messages:
    10
    Likes Received:
    1
    I want to turn mobile data on/off depending the state that it is in. Since it's a toggle i have to check the state before i decide if i have to toggle yes or no.
    The example above with the brightness i already found and installed to see how it it's done or works but i still have a problem how to do this myself for my own mobile data setup. Isn't there a tutorial on all options of AutoInput UI Query so i can read and learn a bit on how to set it up, what the variables do, where to find them later etc.... Now it's trial and error and for now i'm still stuck on the error part.

    Like:
    In the example provided in line 2 i see Variables: setting()
    Where does that come from? If i add the Query there is never a variable
     
    Last edited: Oct 22, 2016
  5. Lange_666

    Lange_666 New Member

    Joined:
    Oct 21, 2016
    Messages:
    10
    Likes Received:
    1
    Been trying all morning since 0:7:30 (and last night until 02:30) to get the AutoInput UI Query to work but i'm still stuck.
    Been watching the how to Google Maps video's but i'm stuck on step 5, part 4.
    It says: In AutoInput, select the text that contains the autoroute info.
    Now instead of using Google Maps i'm going into the notication screen, toggle Mobile Data ON or OFF and then back into tasker.
    But then i never get the "Select fields that should create variables" screen.
    Instead i'm back at the main AutoInput UI Query screen. And then i'm stuck.

    I also looked into your Adaptive Brightness example where i see a variable named: setting()
    But i can't get it to do the same. I have no clue on how this UI Query needs to work and present me the variables i'm looking (or better expecting).
    Also, how does UI Query defines the state of the Adaptive Brightness switch and put it into the variable setting?

    Another question: Can UI Quiry be used to check a button state if the phone is locked?
     
    Last edited: Oct 22, 2016
  6. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
  7. Lange_666

    Lange_666 New Member

    Joined:
    Oct 21, 2016
    Messages:
    10
    Likes Received:
    1
    Tried again this morning (after a bit of sleep).
    Removed everyting and started from scratch following the video's, pausing everywhere to not skip a step.
    But it doesn't work, after step 2, it only returns the ON state when the Flash is executed.
    If i manually set the MD to OFF and then run the task again it returns %status instead of OFF.
    Unlike yours where it returns the correct state either if it's ON or OFF.
    I tried the other way around and started out with the MD in OFF status so selecting OFF in the AutoInput.
    It then flashes an OFF when MD is OFF but again a %status when it's ON.
     
  8. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    Can you please export your Task as a XML file and send it to me so I can import it and check if it's the same as mine? Also, what does your mobile data screen look like? Can you show me a screenshot?
     

Share This Page