Variable not working

Post your questions and help other users.

Moderator: Martin

Post Reply
Siavash
Posts: 11
Joined: 06 Feb 2017 15:14

Variable not working

Post by Siavash » 07 Apr 2017 09:11

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.

mattd_nf
Posts: 16
Joined: 21 Dec 2016 15:51

Re: Variable not working

Post by mattd_nf » 07 Apr 2017 19:07

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}

Siavash
Posts: 11
Joined: 06 Feb 2017 15:14

Re: Variable not working

Post by Siavash » 09 Apr 2017 22:42

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()

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Variable not working

Post by Martin » 11 Apr 2017 14:12

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

Post Reply