Format response into a multiple device variable


#1

1) Give a description of the problem
I am getting a specific response from an application that is sending multiple selection as a single line text. An example of the response can be “Study Lights Study Fan” - where ‘Study Lights’ and ‘Study Fan’ is an individual device on it’s own in webCoRE.

What i would like to do is then set a ‘device’ variable with both the device in that single variable. Example here could be having a variable called ‘study’ and have it list both the device in there.

That way, i can then set an Action for ‘study’ to Turn On.

Is this possible to achieve and if so, can anybody guide me on how to achieve this?


#2

As far as I know, you cannot set a device variable that way. Because it might look like you’re picking the name, but you’re really not. When picking a device anywhere you’re picking an ID which is displayed as a device name. So, you could do a pattern matching rule, but you would need a separate if clause for every device in your setup. That’s a LOT of clauses. How many devices are we taking about?
Also, they don’t come with any deliniator? Comma? Tab? Colon? Are they all 2 words? Or some 1? Parsing them isn’t going to be easy if they’re just. Big ol string of words.


#3

Yeah. But… you could set up a piston specifically for this that would be callable by other pistons. That way you configure your “array piston” once, and any time the function is needed in another (master) piston you Execute the ‘array’ Piston. It then stores the results as global variables, and the master piston gets the appropriate device(s) from the global variables.

I’ve been using Tasker with AutoNotification for this (and using Sharptools to apply the results in Smartthings), but there’s no reason it couldn’t occur in Webcore. The regex functions in Tasker work very well, with no need for delimiters.


#4

No, you can’t use global variables that way. When you call another piston it specifically says that global variables will not be available in the other piston until execution is complete. You have to pass them with arguments.

But in either case, do you have HE? You can either choose to believe me or not but I’m not going to argue what i’ve seen and experienced. Most people have either given up on webCoRE or given up on HE. There are people who think that webCoRE should be banned from the hub by software and prevented from running because support spends too much time tracking down webCoRE issues. So, do whatever you want…but you’re not going to like what happens.


#5

Yea, the bugger is that there is no delimiter when it comes in. I’m thinking of trying to change the device names to single names, like studyLight and then try doing a pattern matchng rule and a switch function to see if that works.


#6

Can it be ‘modified’ at the source to add the delimiter?


#7

As it is some sort of a form, i checked and was able to put in a delimiter on each device. On the form i would need to put:-

Selection:
Study Lights;
Study Switch;
Study Fan

Tested and i received in webCoRE as text - Study Lights; Study Switch; Study Fan

So in short, looks like it can be somewhat ‘modified’ to include a delimiter.


#8

Ok, this is as far as I got when I played with it earlier… I’m not sure why the curly brackets are getting added on. See if it makes sense.

I had to two device variable as webcore didn’t want to play nice adding the following devices right into the first devices variable.

Here’s the device status output in the log… I didn’t try ‘acting’ on the device itself… like turning it on or off, which would be the real test I guess?
image


Passing device variable to a called piston causes device reference to be lost
401 Error using Authentication: Bearer <token>
#9

Awesome!! That worked like a charm. Tried turning on and off the device worked perfectly!!

Thanks again for that!