Switch on/off based on 2 conditions? - Tasker Tips & Tricks

Hi guys, I'm trying to reply something I had done with another task app (llama), but idk why, isn't working properly. Basically, I wanna airplane mode set on or off under not 1 but 2 conditions:
if time is between x and y (first condition)
and
if screen is on (second condition)
then
do nothing
but if screen is off, turn on airplane mode
this imply that when, between x and y, I will turn on the phone (for example during night, to check something), it will turn automatically plane mode off, and again on when screen turns off.
Any ideas to get this working? Thank you!

I think the most reliable way to do this is with three simple profiles.
The first is for the time context. The enter task would set a variable (e.g. %SleepTime) to "true".
The second profile has 2 contexts. The first is to check the previous variable (%SleepTime) is set to "true". The second context is screen off. The task would set a different variable (e.g. %ScreenOff) to true.
The third context checks for (%ScreenOff) is true. The enter task turns on airplane mode. The exit task turns off airplane mode.
The exit task for the first 2 profiles clears the variables.
This could be all handled in one profile using loops and tests for state. IMHO, using 3 profiles is more responsive.

hello,
i use a variable %Night, which is set to "yes" with a profile with the time condition and screen off condition ("if %SCREEN is off") without exit task.
%Night is set to "no" with other profile and all conditions you like. In your case i think it's only the time condition.
The airplane mode profile has as a condition "if %Night is true". Enter task: airplane on. Exit task: airplane off.

ktmom said:
I think the most reliable way to do this is with three simple profiles.
The first is for the time context. The enter task would set a variable (e.g. %SleepTime) to "true".
The second profile has 2 contexts. The first is to check the previous variable (%SleepTime) is set to "true". The second context is screen off. The task would set a different variable (e.g. %ScreenOff) to true.
The third context checks for (%ScreenOff) is true. The enter task turns on airplane mode. The exit task turns off airplane mode.
The exit task for the first 2 profiles clears the variables.
This could be all handled in one profile using loops and tests for state. IMHO, using 3 profiles is more responsive.
Click to expand...
Click to collapse
Hi guys, first thank you in Advance. Im trying this method, every condition seems ok but screen check, which remain black even if I test it on, and so airplane isnt set. I wonder why? Screenshot attached (notice Ive tried screen on just to check and it was still black as I guess means not working properly...)
Ty

There are things to remember.
The non-active state (black as you are saying) for screen off is always going to be the case when the screen is on.
When setting up and testing tasks that include variables, it is very easy to get into a non-defined state with the variables not setting/unsetting correctly. This subtle issue can cause all sorts of headaches because the variable isn't cleared (or set).
Here is the description of a working set of profiles. This variant sets a notification on screen off and screen on to affirm the task ran. The screen off task also vibrates as a tactile assurance the screen off task ran.
Code:
Profile: Airplane Mode Time (86)
Time: From 2:30PM Till 4:30PM
Enter: Airplane Mode Time Variable (87)
A1: Variable Set [
Name:%AirplaneModeSleepTime
To: true
Recurse Variables: Off
Do Maths: Off
Append: Off ]
Exit: Airplane Mode Time Exit (126)
A1: Variable Clear [
Name:%AirplaneModeSleepTime
Pattern Matching:eek:ff
Local Variables Only: Off ]
Profile: Airplane Mode Screen Off (88)
Priority: 1
State: Variable Value [ %AirplaneModeSleepTime ~ true ]
State: Display State [ Is: Off ]
Enter: Airplane Mode Screen Off (94)
A1: Variable Set [
Name: %AirplaneModeScreenOff
To: true
Recurse Variables: Off
Do Maths: Off
Append: Off ]
Exit: Airplane Mode Display On (11)
A1: Variable Clear [
Name:%AirplaneModeScreenOff
Pattern Matching:eek:ff
Local Variables Only: Off ]
Profile: Airplane Mode Set (118)
Priority: 1
State: Variable Value [ %AirplaneModeScreenOff ~ true ]
Enter: Airplane Mode Action (120)
A1: Notify [
Title:Airplane Mode On
Text:
Icon:
Number: 0
Permanent: Off
Priority: 3 ]
A2: Airplane Mode [ Set: On ]
A3: Vibrate Pattern [
Pattern: 0,500,100,500,100,500,100,500,100,500,100,500,100,500 ]
Exit: Airplane Mode Exit (125)
A1: Notify [
Title:Airplane Mode Off
Text:
Icon:
Number: 0
Permanent: Off
Priority: 3 ]
A2: Airplane Mode [
Set: Off ]
A3: Variable Clear [
Name:%AirplaneModeScreenOff
Pattern Matching: Off
Local Variables Only: Off ]

Hmm thx but Im confused a little, is possible to past this text somewhere?

No. But it sounds like you are really new to tasker. Maybe you should work through some tutorials to get some practice.

I used tasker long time ago, but what Im trying to do is quite simple, yet it doesnt work....for example Ive tried this simpler way:
Profile 1) Display on -> var set %Screenon to true
Profile 2) Display off -> var set %Screenon to false
Profile 3) from x to y -> 2 conditions) airplane mode set on if %Screenon is false; 2nd condition: airplane mode set off if %Screen on is true
I wanted to try like this to see but it works only when I press the play button under the actions. Otherwise if i turn on or off the screen nothing change...

takui said:
I used tasker long time ago, but what Im trying to do is quite simple, yet it doesnt work....for example Ive tried this simpler way:
Profile 1) Display on -> var set %Screenon to true
Profile 2) Display off -> var set %Screenon to false
Profile 3) from x to y -> 2 conditions) airplane mode set on if %Screenon is false; 2nd condition: airplane mode set off if %Screen on is true
I wanted to try like this to see but it works only when I press the play button under the actions. Otherwise if i turn on or off the screen nothing change...
Click to expand...
Click to collapse
I would suggest trying to turn screen on and off, check the Tasker log to see if the variable is set properly.
- If it does, trying manually set it to false, and then true in your time range x-y to see if 2nd profile reacts to that.
- If it does not, check 1st profile again, maybe you are using screen on and unlocked? or whatever... anyways, that should narrow down the possibilities at least

Ty, Reading the log Ive noticed that the variable is set correctly (see attach) but the 3rd profile doesnt set airplane...hmm

takui said:
Ty, Reading the log Ive noticed that the variable is set correctly (see attach) but the 3rd profile doesnt set airplane...hmm
Click to expand...
Click to collapse
so what does the log say when you manually run 3rd profile? just so we know the profile does not correctly start or not correctly run...

If I run it manually it works in both ways (on and off) otherwise no. Logs attacched. Its just that it doesnt check alone the variable and doesnt start alone

ok to clear things up:
- your display profiles can be combined into 1 with exit task
- have you tried to manually set %ScreenOn to each value to see if the profiles reacts to that - I doubt it would
- try using equal instead of match for the variable
- maybe post your profiles and tasks

Hello. I had them combined before, ive tried splitting but mothing changed... Log show that the variable is set correctly, what doesnt change is the airplane mode, as it doesnt care the variables at all (time frame condition btw works, as it is showed green...)

takui said:
Hello. I had them combined before, ive tried splitting but mothing changed... Log show that the variable is set correctly, what doesnt change is the airplane mode, as it doesnt care the variables at all (time frame condition btw works, as it is showed green...)
Click to expand...
Click to collapse
ok I think I know what the problem is: your timed profile is triggered by state and not event, which means during the time frame, profile is triggered and finishes, it will test your variable during this time only, and will not recheck if this variable changes, when task is finished.
I hope I made it somehow clear....
anyways, try this, put the variable in the condition part as well.

Hm ok maybe Ive understood what you mean but so, what kind of profile Ive to make? Everyone is triggered from something, state, event, app, UI...isnt "free", so Ive choosed time...

add condition variable set

Hmm Im closer to a solution, still I cant get the timeframe works. In this new adapation, airplane is set correctly on and off when I turn on and off the screem but, it doesnt consider the timeframe so, if I turn off the screen in the morning, it sets airplane mode on anyway. In attach the new setup...
Edit: if Im not wrong, the red bar on the right means that the conditions are not reached, right? So why even if the bar is red in the airplane on mode, it turns on when the display turns off? ....

here you go, try this on your device at night time. if you have a heart attack, I'm not responsible...

ktmom said:
I think the most reliable way to do this is with three simple profiles.
The first is for the time context. The enter task would set a variable (e.g. %SleepTime) to "true".
The second profile has 2 contexts. The first is to check the previous variable (%SleepTime) is set to "true". The second context is screen off. The task would set a different variable (e.g. %ScreenOff) to true.
The third context checks for (%ScreenOff) is true. The enter task turns on airplane mode. The exit task turns off airplane mode.
The exit task for the first 2 profiles clears the variables.
This could be all handled in one profile using loops and tests for state. IMHO, using 3 profiles is more responsive.
Click to expand...
Click to collapse
alienyd said:
here you go, try this on your device at night time. if you have a heart attack, I'm not responsible...
Click to expand...
Click to collapse
? This just speech... I dont need it Im confused

Related

Making a Tasker profile overrule another

I have a profile that when the screen turns on it enables location to battery saving mode for 1 minute the turns off completely. I then have a 2nd profile that turns location to high accuracy when I open Google maps. The problem is my first profile overrides the maps profile and disables location after 1 minute even if maps is open and location changes to high accuracy.
So how can I make my 2nd profile override the first? I feel like it can't be too difficult to do but I can't figure it out.
farquea said:
I have a profile that when the screen turns on it enables location to battery saving mode for 1 minute the turns off completely. I then have a 2nd profile that turns location to high accuracy when I open Google maps. The problem is my first profile overrides the maps profile and disables location after 1 minute even if maps is open and location changes to high accuracy.
So how can I make my 2nd profile override the first? I feel like it can't be too difficult to do but I can't figure it out.
Click to expand...
Click to collapse
Hello my friend.. You need something like in the first profile long press in the name and add second condition to trigger profile... Add Google maps and in selection of app press the invert button... I thing this setup does your work.. Try and tell me!!
Sent from my SM-G900F using XDA Labs
I thought that would work but it didnt Here's my profile.
When Display is On, Location = Battery Saving, Wait 1 Min, Location = Off
If i use the invert, it just turns off the Display On profile but i think the 1 minute timeout is already triggered as its still turning off location 1 minute after even with Maps open even though in Tasker the Display profile doesnt show as active.
I need something to say Wait 1 min unless Maps is open but then what happens when Maps closes, the 1 minute begins? Doing that may not be easy. Is there no way to add weight or priorities to tasks to say the maps profile.
! REALLY horrible way i suppose i could do it is in my maps profile say wait 61 seconds and then set location mode to GPS, so that it reenables if the Display profile has disabled, i just could end up with a small gap of time where location is off.
Here's what you do.
Add an action to both location profiles that (and every profile or task that turns on loc services) sets a timer
set variable LOCATIONtimer=%TIMES+60
Then create a profile with a time context and set the time to activate as %LOCATIONtimer
The task will disable location services.
Now set your maps profile to clear the %LOCATIONtimer variable
(this will prevent the disabling of loc… since the variable has no time, it can't fire)
Then when your battery saving profile activates it will set the timer for 60 secs… but when you activate maps… it will clear the variable, so it won't adjust your loc srvices
Btw… it's a huge battery impact when you do the "app" context as it checks for open apps every two secs.
It's much better to get rid of all app context profils and launch those apps via a tasker shortcut that
1 launches the app
2 then sets a variable eg. isopenMAPS=true
Then set a. If variable value context of isopenMAPS=true then every time that variable is true, you'll know the app was opened, so you can then clear that variable to show you've closed three app

How can I set alarm clock few minutes after profile active?

I set in profile task what At a specific time enable wifi and internet radio - that should wake me up.
But if radio don't wake me up I want that few minutes later set/on oryginal alarm clock (where i can set my ring tone or ex. set snooze for 5min/10min or off alarm if I wake up).
I randomly wake up so when i whant that radio wake me up i set time to ON only on tasker profile.
How i can add/what task add to this if I want Get the effect when radio will ON , 5min later clock alarm will ON
try this:
- in profile task, do math on current time, plus x min times 60,
- than convert the result back to normal time format
- do a variable split, splitter empty, to split it by space, to get time only
- you will have to trim possible preceding zero in hour
- than set alarm with the result time
Sorry but You write too complicated for me :|
Can You write this same but maybe on the example and write step by step what to do
Thank so much
Yeah that's far too complicated. Try this.
In your first profile, that turns on your alarm, set a variable %ALARMTIMERCOUNTDOWN =%TIMES+120 (%TIMES is the current time in seconds, and + 120 is two minutes after the current time
Then create a time context profile and click the little tag you change it from time, to variable, and enter %ALARMTIMERCOUNTDOWN as the time.
Then, when the current time=ALARMTIMERCOUNTDOWN the profile will trigger.
Now remember to clear the variable in both exit tasks so if you wake up, the variable will be empty and thus will never trigger
Can You write this step by step. Like this: Go to your profile that turns on your alarm -> in task what enable radio add new variable -> action ("+") -> variables -> add variable - here in "........." write "....... " -> then go to action variable and "set variable" -> ........
In profile I can add new time context and to start time set %ALARMTIMERCOUNTDOWN but i bust add task to this context - what task i should add?
"Now remember to clear the variable in both exit tasks" - I had add variable only on one task "In your first profile, that turns on your alarm, set a variable.... "
someone can help?
gonzolex said:
someone can help?
Click to expand...
Click to collapse
ok, here goes:
new profile1
- trigger: event/date-time/alarm clock: alarm info
- action: set variable %Trigger to %TIMES+120, do math
btw profile2
- trigger: state/variables/values: %TIMES eq %Trigger
- action: do your task

Very new to Tasker, need help

I have a shake left right task to change my brightness on my phone. I have a BT Connected profile that is set up for connection to my car's Bluetooth that turns off wifi, sets brightness, etc. Problem is if I hit a bump, my brightness changes due to the shaker profile. I've tried multiple ways of setting in my BT Connected profile to toggle the shake left right profile off when connected to my car. Is there a way to do this? If not I have to turn it on and off manually. I apologize if this has been covered somewhere else.
Thanks in advance
Make an "if" condition in your brightness task using %pactive. It should be: if %pactive doesn't match *,yourbtprofilename,*
Good luck
shaggydiamond said:
Make an "if" condition in your brightness task using %pactive. It should be: if %pactive doesn't match *,yourbtprofilename,*
Good luck
Click to expand...
Click to collapse
So this does not seem to be working correctly. I have made a "if" condition, but it either doesn't work or just breaks the shaker all together. I have moved the "if" (line 9) to any and all lines, but it still is not working correctly. For some reason I cannot submit a screen shot, even though I have been on this forum for years...
1. If V
%BRIGHT ~ 255
2. Display Brightness
Level 35
3. Display Timeout
Secs 0 Mins 1 Hours 0
4. Else
5. Variable Set
Name %Bright To %Bright
6. Display Brightness
Level 255
7. Display Timeout
Secs 0 Mins 1 Hours 0
8. End If
9. If V
%pactive !~ BT Connected Bose AE2 Soundlink
Am I missing something?
Thanks again
masked_hacker said:
So this does not seem to be working correctly. I have made a "if" condition, but it either doesn't work or just breaks the shaker all together. I have moved the "if" (line 9) to any and all lines, but it still is not working correctly. For some reason I cannot submit a screen shot, even though I have been on this forum for years...
1. If V
%BRIGHT ~ 255
2. Display Brightness
Level 35
3. Display Timeout
Secs 0 Mins 1 Hours 0
4. Else
5. Variable Set
Name %Bright To %Bright
6. Display Brightness
Level 255
7. Display Timeout
Secs 0 Mins 1 Hours 0
8. End If
9. If V
%pactive !~ BT Connected Bose AE2 Soundlink
Am I missing something?
Thanks again
Click to expand...
Click to collapse
Much better to post the actual profile when it's not working as expected. Make sure it's named - not a default name assigned by tasker. Then long press on the name to highlight the profile. Go to the 3-dot menu and select export -> Description to Clipboard.
Then you'll be able to paste it. Be aware, it easier to use pastebin.com then link to a post here. If you paste in a post here, the forum software will convert all semicolons with characters after, typically "on" and "off" to emoticons making it very hard to read.
"Good judgment comes from experience, and a lot of that comes from bad judgment." - Will Rogers
masked_hacker said:
So this does not seem to be working correctly. I have made a "if" condition, but it either doesn't work or just breaks the shaker all together. I have moved the "if" (line 9) to any and all lines, but it still is not working correctly. For some reason I cannot submit a screen shot, even though I have been on this forum for years...
1. If V
%BRIGHT ~ 255
2. Display Brightness
Level 35
3. Display Timeout
Secs 0 Mins 1 Hours 0
4. Else
5. Variable Set
Name %Bright To %Bright
6. Display Brightness
Level 255
7. Display Timeout
Secs 0 Mins 1 Hours 0
8. End If
9. If V
%pactive !~ BT Connected Bose AE2 Soundlink
Am I missing something?
Thanks again
Click to expand...
Click to collapse
Below 9 is where you want your task! With 9 you're saying 'if'. Task #10 and up is your consequence of that. Try a more simpler task to get to know 'if' and 'else'. Then try again with this task. Basically: 'if condition' - task - task - 'end if'. You can put more 'if conditions in between if you want.
masked_hacker said:
I have a shake left right task to change my brightness on my phone. I have a BT Connected profile that is set up for connection to my car's Bluetooth that turns off wifi, sets brightness, etc. Problem is if I hit a bump, my brightness changes due to the shaker profile. I've tried multiple ways of setting in my BT Connected profile to toggle the shake left right profile off when connected to my car. Is there a way to do this? If not I have to turn it on and off manually. I apologize if this has been covered somewhere else.
Thanks in advance
Click to expand...
Click to collapse
In your shaker profile if you have an entry task, add an if statement. In here on the variable side put %PACTIVE and use the matches symbol. Then on the right side put *name of bt profile*
Then after that task add a stop task, then end if task.
What this will do is first check if your using you bt connected profile and stop or go depending on if it's active. I hope this makes sense. If not I'll try to write it out more clearly when I get home. You may not need an entry\exit task for your profile if you only have just a group of tasks just add the if part inside one of those tasks

Set a variable when bluetooth is enabled manually

Hi,
lets say i want that every time my smartphone connects with the wlan at home bluetooth should be enabled and disabled when i leave the wlan. this is easy to do with tasker.
but when i enable bt manually when i'm not at home, then tasker has nothing to do when i connect to the wlan. but whe i leave it bluetooth will be disabled.
is there any way to prevent bluetooth disable when i've enabled it manually? maybe there is a solution using variables? set a variable from 0 to 1 when bluetooth is enabled manually and not when it enabled automatically via tasker?
Restore settings being enabled in your profile will automatically restore the configuration based on the entry task. Deselect restore settings (long press profile, with it selected tap the cog/gear icon) and expressly restore the settings in your exit task.
In the entry task add a variable set %BTon to "true". Include an "if statement" in the variable set action "if %BLUE does not match on".
Then in the exit task, when you expressly turn off Bluetooth, add an "if statement" to the BT off action so it only runs if the variable "%BTon matches true".
Make sure to add a variable clear for the %BTon variable at the end of your exit task.
Tips
Thanks

Increments in Tasker volume control

I'm on a Galaxy S10 Plus and have over 15 increments in all my sound controls. Tasker only has 15 increments. I've got Tasker set to lower my notification volume at work but Tasker's "1" step isn't low enough. My phone sound has the ability to go many steps lower than Tasker's "1".
How can I address this in Tasker to get the volume lower than 1 or to increase the sound increments in Tasker? Thank you!
A couple of thoughts...
If you use a variable entry set to 0, does it go lower? If you're not yet aware, tap the double arrow button to get to an input field.
Or, see if a custom settings action will give you fine grained control.
I'm not sure how to use a variable entry to adjust the sound. Can you please elaborate?
Thank you!
ktmom said:
A couple of thoughts...
If you use a variable entry set to 0, does it go lower? If you're not yet aware, tap the double arrow button to get to an input field.
Or, see if a custom settings action will give you fine grained control.
Click to expand...
Click to collapse
https://www.pocketables.com/2012/08/beginners-guide-to-tasker-part-2-variables.html
I'm sorry but I don't see how to use a variable to set sound increments. Can you help? Thank you!
ktmom said:
https://www.pocketables.com/2012/08/beginners-guide-to-tasker-part-2-variables.html
Click to expand...
Click to collapse
I don't know what more to tell you. Create a variable, set it to a value (see the link that was posted) and use that variable in the action you are using to control the notification volume (tapping the crossed arrows to get the input field as mentioned in my first reply)
Hi - I tried using a variable with settings of 0.5 and it just takes the volume down to zero. I also tried setting the media volume to the lowest setting and recording what value that was in a variable and it just came up as "1" despite a value of 1 not getting me the lowest volume level. Has anyone figured out how to do this?
I have not figured out how to do this through Tasker.
It's clanky, but what I've done for the moment is to use Tasker to set Media Volume to zero, then in a simple loop I mimic pressing the "Volume Up" hardware button as many times as requested.
Task: Adjust Volume
A1: Media Volume [
Level: 0 ]
A2: Variable Set [
Name: %max
To: 17
Max Rounding Digits: 3
Structure Output (JSON, etc): On ]
A3: Variable Set [
Name: %num
To: 1
Max Rounding Digits: 3
Structure Output (JSON, etc): On ]
<loop>
A4: If [ %num < %max | %num = %max ]
A5: Button [
Button: Volume Up ]
A6: Variable Set [
Name: %num
To: %num + 1
Do Maths: On
Max Rounding Digits: 3
Structure Output (JSON, etc): On ]
A7: Goto [
Type: Action Label
Label: loop ]
A8: End If
A9: Flash [
Text: %VOLM
Continue Task Immediately: On
Dismiss On Click: On ]
I have the final Flash in there just to check out what Tasker is calling my required volume; I'll clearly be taking it out when I put the task into implementation, if I decide it works at least well enough for me.
For the record, I have a Samsung Galaxy S10e, on which I have used Sound Assistant to increase my volume rocker steps to 30.

Categories

Resources