23

Let's say I want to create a context where the SSID of a WiFi connection is either 'ABC' or 'XYZ'.

I can see where I am able to create 2 contexts, but it seems to enforce AND logic between the two, so in order words I must be in proximity to both 'ABC' and 'XYZ'.

How to make the context to be either, not both?

6 Answers 6

12

Specify SSID in the WiFi Connected context to be ABC/XYZ This will activate the context if you connect to ABC or XYZ,

Reference: http://tasker.dinglisch.net/userguide/en/matching.html

1
  • 2
    solves this particular problem, but not what the question actually asked
    – endolith
    Commented Nov 10, 2014 at 20:25
21

Or probably you can use "Inverted" conditions to do an opposite task?, e.g.

If you want to run a task when WiFi is connected OR when the profile:A is inactive, you can instead setup contexts for "WiFi is disconnected" AND "Profile: A is active" both with "inverted" checkbox selected, and setup a task that does the opposite, if that is possible.

This basically works because of:

(A OR B) = NOT((NOT A) AND (NOT B))

1
  • 4
    This answer nice because it's more general. That is, it works with context types other than "Wifi Connected". For example, I wanted to create a profile to put my phone in silent mode whenever it's either docked or connected to my Pebble watch. The easiest way to do this was to make a "not connected to Pebble and not docked" profile that disables silent mode on enter, and enables silent mode on exit. DeMorgan's Laws FTW. Commented Apr 22, 2013 at 19:40
5

just posting my solution to this problem if anybody ever comes here:

create a profile for each condition in the or statement on enter %Reasons += 1 on exit %Reasons -=1

create a profile with condition %Reasons>0 and the required enter and exit tasks

cheers!

4

You could make your action depend on a variable "%condition=true" and then make two different profiles:

  • profile a: set condition to "true"
  • profile b: set condition to "true"

your profile: if variable "condition"=true then ... and there goes your exit task

But would be nice if the authors would enhance tasker for that... :)

1
  • 3
    This method causes problems when the condition may be set true or false by both profile a and b at the same time. For example, I wanted to turn bluetooth on when in a call or in Contacts app. I set %BluetoothNeeded=1 in either case and clear when either case exits. While I'm in a call the Contacts app becomes background and usually gets suspended to save memory, which clears %BluetoothNeeded so bluetooth turns off, cutting my bluetooth headset during the call. Commented Aug 9, 2014 at 15:10
2

You will need to make a single profile for each context and pair it to the action individually.

1
  • 3
    Hm, this means I won't really be able to have an exit task?
    – Zombies
    Commented Mar 11, 2011 at 17:07
2

To support my bluetooth headset, my desire was to turn bluetooth on when I'm in the Contacts app OR in a call. I could do it only while in a call but then I can't make sure my headset is connected before the other party picks up.

None of the solutions already posted would work. Setting %BluetoothNeeded on when in Contacts or in call means that when a call starts, it sets %BlueToothNeeded on but then when Contacts becomes background to being in call, it sets %BlueToothNeeded off and bluetooth turns off. Using the inverse operation, turn bluetooth off when NOT in Contacts AND NOT in call but turn bluetooth on as an exit task almost works, but apparently Tasker notices the brief period when Contacts loses foreground status and the call hasn't started yet and turns bluetooth off.

So here's what worked for me, based on this blog:

  1. Create a Task called Dummy with an Action of Tasks > Wait > 1ms
  2. Create a Profile called stateInCall with a condition of State > Phone > Call > Type: Any. Link it to the Dummy task.
  3. Create a Profile called stateInContacts with a condition of State > Application > Contacts. Link it to the Dummy task.
  4. Create a Profile called Bluetooth Needed with a condition of State > Variable > Variable Value. Set Name to %PACTIVE, Op to Matches, and Value to *,stateInCall,*|*,stateInContacts,*. According to the Tasker docs, %PACTIVE contains a comma-separated list of active Profiles where the list also begins and ends with a comma to make matching easier. Link this Profile to a Task called Bluetooth On that turns bluetooth on using the Net > Bluetooth > Set: On Action.
  5. Create a Task called Conditional Bluetooth Off with the following Actions:
    1. Task > Wait > 10 seconds
    2. Task > If > %PACTIVE doesn't match *,stateInCall,*|*,stateInContacts,*
    3. Net > Bluetooth > Set: Off
    4. Task > End If
  6. Long press on the Bluetooth Needed Profile then choose Properties. Uncheck Restore Settings.
  7. Quick press the Bluetooth Needed Profile till the Bluetooth On Task appears below it, in the right column. Long press Bluetooth On and choose Add Exit Task, then choose Conditional Bluetooth Off.

Conditional Bluetooth Off will wait 10 seconds before double checking that neither stateInCall nor stateInContacts are true, at which point it will turn bluetooth off. Otherwise, it leaves bluetooth on and when both stateInCall and stateInContacts exit later, it will do its 10 second wait and check again.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .