Cant figure out how to use device variable in a for each device loop

I see examples like this...I just cant figure out how to enter
image

I create a for each $device in Vacuums which has an attribute called runs_since_emptied but in the conditional i put in $device but for selections it has all kinds of unassociated attributes but not the one I'm looking for... Any pro-tips?

I thought this was already addressed before but as workaround, try adding the real device with $device in the for each statement with the correct attribute you're looking for, the attribute should show up. Once done, you can remove the real device from the statement.

Thank you for the suggestion...not sure what I'm doing wrong...but I added a vacuum device (Alice) to the foreach but when I try and do the conditional I do not get the custom attributes

See if this makes sense.

ok, so not in the foreach but add both to the conditional ..if I do that I see what i want
image

but when I go back and take out the Alice, the total_minutes_vacuuming attribute disappears... In can't leave in the Alice vacuum with the $device as the logic would be wrong : )

Yeah, I haven't done this in a while. I remove the original device after I build the statement with the correct attribute I am after.

@eibyer really appreciate you trying to help!

Anyone else have suggestions ?

I have also used eibyer's method, and I just tested it and it still works still for me.

I see you have Alice vacuum1 OR $device. You just want to replace $device with Alice only, and then you will be able to choose the attribute from the Alice vac. Then don't save anything, just replace Alice back to device after picking the vac attribute, then save, and the vac attribute will stay there.

well i think i tried what you said to no avail... can you see this very short clip and confirm or tell what I'm doing wrong...thanks in advance!

You are right, I had tested selecting another attribute that was actually in the $device list. I think this method works for Do, but not for IF.

I just tested using an expression, and it worked. So try this as an expression:

[$device : total_minutes_vaccuming]

I think i did what you suggested...correct me if I'm wrong but got error see below.
You mentioned Do ...is that a different way to accomplish what I want?

Well, you are using an IF statement in this case, but in a Do (with device) statement, you can change a device to a $device and the command part stays there, unlike with If statements.

So if you have a custom command for your device, you can still do it with $device by changing the actual device to $device after, and the custom Do command will stay. That is probably what I was initially thinking about with the If statements.

You need the brackets around the expression for it to work, so it knows you are referencing a device in the expression.

I'm really bad at this ...is this right ?

Also I cannot figure out how to do a Do (with device) ..I don't see that in the allowed options

image

well I gave up and created a ton of if checks... would be nice to know some day if webcore is supposed to handle custom attributes in for loops : (

I forgot that is forum deletes the brackets characters, but the were in my post. Looks like you have curly brackets, instead of square ones.

In the expression box, just type a left square bracket "[" and a list of your devices comes up to select. It will also pop up the commands you can use after the colon.

But yes, you need the square brackets. In this case you do not choose a popped-up command, you just want to type it in after the ":"

I see what you mean by the "[" in the expresssion that is cool]
however in a twilight zone moment ..... the device variable worked the way i thought it should and I was able to make a for loop (not sure why it works now)...see below... Am I using the $index variable correctly ?
image

Yes, that will increment the index each time you use it, starting with 0.

Note, that these Webcore arrays are actually maps. You can fill in where you have $index with any string. So if you put $device where you have $index now, it will create a map with the key as the device name, and the value of null.

Then you can reference it as StartTime[device name], instead of using numbered indices, if you want it to be clear what vac had what start time.