I see examples like this...I just cant figure out how to enter
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
ok, so not in the foreach but add both to the conditional ..if I do that I see what i want
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 : )
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.
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.
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 ?
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.