SSID Variable

1,046 views
Skip to first unread message

Ritchie Joe

unread,
Nov 13, 2013, 7:46:00 PM11/13/13
to tas...@googlegroups.com
Hey everyone,

I am trying to set up a variable using an SSID.

I tried this method posted by brandall at XDA http://forum.xda-developers.com/showthread.php?t=1110775

#1 Variable Set %SSIDD to %WIFII
#2 Variable Split %SSIDD - Splitter <<<. (with delete base ticked)
#3 Variable Clear - %SSIDD1
#4 Variable Split %SSIDD2 – Splitter Mac: (with delete base ticked)
#5 Variable Set %SSID to %SSIDD21
#6 Variable Clear %SSIDD21
#7 Stop
#8 Variable List


But when I use it it in a variable I get the red line next to my SSID saying it doesn't match.

Any suggestions?
Message has been deleted

Bob Hansen

unread,
Nov 13, 2013, 9:18:46 PM11/13/13
to tas...@googlegroups.com
I forgot to mention, it is best to use local variables (all lower case letters) for variable names when they are only used within the task. This speeds up execution. I often debug with global variables (at least one uppercase character in the variable name) and then change to local variables once everything is working.

On Wednesday, November 13, 2013 6:15:10 PM UTC-8, Bob Hansen wrote:
The way you were splitting the %WIFII was not correct. Below is a working example.

The data in the WIFII result is done in 6 lines each ending in a carraige return. So the best splitter for this is to use the carriage return. Tasker doesn't let you directly enter a return (carriage return) character directly, so you need to set a variable to a return character and reference that variable as the splitter in the Variable Split command in A3. The results of that split are flashed in A4, so you can see what it did. As you can see, the Mac address is in %ssidd5. To get the Mac address value only we can use a Variable Section action which allows us to define the beginning and ending of the characters we want to extract from the string. In this case we want to ignore the "Mac: ". Notice that I included the space, that's important. So "Mac: " is 5 characters, then we want to start our variable section with the 6th character. Since we want the rest of the string we can make the ending character value larger than the length of the string and set the Adapt to Fit option On as shown in A5. The variable section result is stored in %SSID. Finally, the SSID value is flashed in A6.

The flashes exist only to show what is happening. Hope this helps :>)

SSID (336)
A1: Variable Set [ Name:%return To:
Do Maths:Off Append:Off ] 
A2: Variable Set [ Name:%ssidd To:%WIFII Do Maths:Off Append:Off ] 
A3: Variable Split [ Name:%ssidd Splitter:%return Delete Base:Off ] 
A4: Flash [ Text:%ssidd1
%ssidd2
%ssidd3
%ssidd4
%ssidd5
%ssidd6 Long:On ] 
A5: Variable Section [ Name:%ssidd5 From:6 Length:24 Adapt To Fit:On Store Result In:%SSID ] 
A6: Flash [ Text:%SSID Long:Off ] 

Mike L

unread,
Nov 13, 2013, 10:22:15 PM11/13/13
to tas...@googlegroups.com
Could also use a Variable Search Replace to get at the ssid.
The following pattern should work:    (?<=")[^"]+(?=")

Bob Hansen

unread,
Nov 13, 2013, 10:44:12 PM11/13/13
to tas...@googlegroups.com
Yea. I thought about that, but I figured it would be better to keep it simple. Kind of time consuming to try to explain how regex statements work. ;>)
Message has been deleted

Bob Hansen

unread,
Nov 14, 2013, 12:19:38 AM11/14/13
to tas...@googlegroups.com
I don't know what I was thinking, I set the %SSID to the Mac: address. I deleted my original post in order to avoid confusion.

It should be:

The way you were splitting the %WIFII was not correct. Below is a working example.

The data in the WIFII result is done in 6 lines each ending in a carraige return. So the best splitter for this is to use the carriage return. Tasker doesn't let you directly enter a return (carriage return) character directly, so you need to set a variable to a return character and reference that variable as the splitter in the Variable Split command in A3. The results of that split are flashed in A4, so you can see what it did. As you can see, the Mac address is in %ssidd5. The SSID value is contained in %ssidd3 so we can use Variable Set %SSID to %ssidd3 in A5. If you want to get the Mac address value only we can use a Variable Section action which allows us to define the beginning and ending of the characters we want to extract from the string. In this case we want to ignore the "Mac: ". Notice that I included the space, that's important. So "Mac: " is 5 characters, then we want to start our variable section with the 6th character. Since we want the rest of the string we can make the ending character value larger than the length of the string and set the Adapt to Fit option On as shown in A6. The variable section result is stored in %MAC. Finally, the SSID and MAC values is flashed in A7.

The flashes exist only to show what is happening. Hope this helps :>)

SSID (336)
A1: Variable Set [ Name:%return To:
Do Maths:Off Append:Off ] 
A2: Variable Set [ Name:%ssidd To:%WIFII Do Maths:Off Append:Off ] 
A3: Variable Split [ Name:%ssidd Splitter:%return Delete Base:Off ] 
A4: Flash [ Text:%ssidd1
%ssidd2
%ssidd3
%ssidd4
%ssidd5
%ssidd6 Long:On ]
A5:Variable Set [%SSID To: %ssidd3 Do Maths:Off Append:Off ]
A6: Variable Section [ Name:%ssidd5 From:6 Length:24 Adapt To Fit:On Store Result In:%MAC ] 
A7: Flash [ Text:%SSID
%MAC Long:Off ] 

Ritchie Joe

unread,
Nov 14, 2013, 7:58:58 AM11/14/13
to tas...@googlegroups.com

The only part of that which is confusing me at the moment is the black statement In A1, the Name and return to are blank. I do apologise for my lack of knowledge on the subject and your patience

Bob Hansen

unread,
Nov 14, 2013, 8:54:04 AM11/14/13
to tas...@googlegroups.com
No need to apologize, we were all in the same boat at some point.

Line A1 is setting the variable %return to a return character - as in setting the value to the "enter" key on a keyboad. That's why it looks blank. You have to do this because Tasker's Search and Replace action doesn't allow the enter character to be directly input. Notice that the search/replace in A3 is splitting using the %return variable which causes the to occur at the return characters. 

Ritchie Joe

unread,
Nov 14, 2013, 9:24:59 AM11/14/13
to tas...@googlegroups.com
I have followed your instructions, left the mac out because it wasn't needed.

I have included the screen shots, when I try to use the variable to set %Home to 2 if SSID matches .............

it has the red line against it. I have included 3 screen shots to help show what I mean


Screenshot_2013-11-14-13-50-15.png
Screenshot_2013-11-14-13-50-41.png
Screenshot_2013-11-14-13-50-55.png

Bob Hansen

unread,
Nov 14, 2013, 9:38:49 AM11/14/13
to tas...@googlegroups.com
The reason that it doesn't work is the quotation marks at the start and end of the SSID. I have no idea where they came from as I have never seen that before. In any case, since you are comparing to a fixed value, the easiest solution is to add the quotation marks to the value you are comparing to. Like this:

If %SSID ~ "virginmedia4699708"

Bob Hansen

unread,
Nov 14, 2013, 9:48:48 AM11/14/13
to tas...@googlegroups.com
After thinking about it... the quotation marks must be part of the actual SSID.

RudeboyX

unread,
Nov 14, 2013, 12:31:23 PM11/14/13
to tas...@googlegroups.com
No need for any of the splitting or custom variables.

a simple
If %WIFII matches *virginmedia4699708*
should work

Ritchie Joe

unread,
Nov 14, 2013, 5:07:19 PM11/14/13
to tas...@googlegroups.com
I got it working bob thanks to your help, thank you for your patience and help. I'm sure I will have more questions at some point :)


Your method also worked Rudeboy, I have been trying to learn variables for this particular variable for quite a few hours and you have just torn that to shreds with a simple solution. So at the moment I don't know if I want to hit you or shake your hand :D

I guess it was worth it as I learnt a little from it.

Thank you all

Mykel Douglas

unread,
Nov 14, 2013, 11:20:35 PM11/14/13
to tas...@googlegroups.com
Can any of you help me set up my Tasker so that it can connect to the Wi-Fi by entering SSIDD or WPA password THEN launch an app?

Help

Michael E Fracher

unread,
Feb 11, 2016, 9:11:42 AM2/11/16
to Tasker
Thank you ,  %WIFI matches  is Great and and I learned  *?????*  technique
Mike F
Reply all
Reply to author
Forward
Message has been deleted
0 new messages