Using .members.filter

In my sitemap I’m using selection, after the item bound to it gets a value I would like to use its value as an Item name, how can I do this?
Propably the answer is about the .members.filter function, but I can’t use it.
In the .Rules file I’m simply trying to find out how to use the .members.filter, it is suppose to find the sensor2 item among the Sensor members and then post update the temperature item. Even this simple rule doesn’t work
More precisely:
Item file
Group Sensor
String sensor2 “[%s]” (Sensor)
String devicet
Sitemap file
Selection item=devicet label=“Device to use” mappings=[“sensor2”=“sensor2”]
Rules file
rule "devicet"
when
Item devicet received command
then
var String mm=devicet.state.toString()
if(Sensor.members.filter(s|s.name == mm)){
postUpdate(temperature,5)
}

end

Thanks for your help, I hope I was able to describe my problem.

It really helps if you post your code using code fences so the forum property formats it:

```
your code here
```

Two things with filter.

  1. I think you have to use square brackets, not parens
  2. Filter returns a List object containing all the Items that match the filter

So the line should be:

if(Sensor.members.filter[s|s.name == mm].size > 0) // there is at least one Item named mm