Page 1 of 1

Variable not working

Posted: 07 Apr 2017 09:11
by Siavash
Hi

I found a bug today, which maybe can be looked at later:

Condition WiFi connected: help says variables are supported. However I fed it with a global list variable of SSIDs and it just didn't care about it.

I think I'll be able to work around it if I check the SSID manually in a scrip or something. Just wanted to let you know about the bug.

Re: Variable not working

Posted: 07 Apr 2017 19:07
by mattd_nf
Hi Siavash,

I think you need to convert your list of SSID's into a comma separated string of them. For example, if you currently have a list like:

ssidlist[0] = "wlan1";
ssidlist[1] = "wlan2";
ssidlist[2] = "wlan3";

You would need to convert it to:

ssidstring = "wlan1,wlan2,wlan3";

You can do this with the script command "join" like:

ssidstring = join(ssidlist, ",");

and then set the variable in "Wifi Connect" as {ssidstring}

Re: Variable not working

Posted: 09 Apr 2017 22:42
by Siavash
Thanks.

I thought I can pass a list to it as it usually works fine with lists.

Anyway my global variable is kinda manual here. So I guess I can use a single comma sep. string as you hinted, or just stick to my workaround of checking ssid with the list using contains()

Re: Variable not working

Posted: 11 Apr 2017 14:12
by Martin
Hi Siavash,

The condition WiFi Connected supports variables but it's important to ensure that the variable replacement produces the correct text. For a regular string variable, you can just write the variable as {variable_xyz}. When you want to provide a complete list, you can use {ssidlist,listformat,comma}. In this case Automagic will ensure that the list is correctly formatted and that special characters are escaped properly when required.

Regards,
Martin