Need help with foreach

HELP PLEASE - ripping my hair out....
I have a bunch of CT's with attribute burstCounter and wanting to check every X minutes if the burst counter is too high....
I setup a timer and a foreach (bunch of devices)
there is a $device variable but for some reason webcore will NOT treat it as a single device from the foreach loop
In addition the burstCounter is a number but the comparisons dont allow for greater than x
I'm a novice so any help would be appreciated... I thought this was going to be a 20 min job but I've asked for help from Copilot and Chatgpt and got nowhere

It seems to not think burstCounter is a number. The options given are based on the type, so to get number comparisons, it has to be a number.

I like to put all my devices for a for each into a device variable at the top:

image

To make sure it is a number, you have to convert burstCount to a number first. The easiest way to do that is to make an int variable to assign in the loop.

Then in the loop, assign the variable by converting the current $device attribute, using an expression.

image

It would if you were accessing it directly, but in a for each loop the attribute type is ambiguous while you are writing the piston to get the correct options to come up. Looks like it treats any $device attribute in a for each loop as string by default for the comparison options it gives you, since it doesn't really know until runtime that it is actually a number.

So you do not really need to convert it to a number, you are just using the int variable to tell Webcore what to expect to get the right options to come up. Since it really is a number attribute, you probably do not need the number() method in the expression, just
[$device : burstCounter] should work.

i try and create that and get

it exists as i can do it if using a specific CT
image

Is foreach not the right approach? Is there other ways to test a lot of devices for a numerical comparison without a massive if else for all the devices... is there a better approach?

is there any chance of getting help from a webcore expert?
I wish there was a library of working examples to go look at... so I wouldn't have to bother people : (

well i got it going.....i just cant understand how it can apply average to a single device ( $device ) from the foreach ...