Members.filter openHAB 3

Hi,

I’m finally migrating to openHAB 3, thanks to the authors!

When I try to use the same rules I was using with openhab2.5 I have an issue with:

Group                           BateriaSensors                          "Batteries Group" <batterylevel>
rule "Low Batteries Sensors"

when

        Member of BateriaSensors changed 

then

        BateriaSensors.members.filter[item | item.state < 16].forEach[items|

        val mailActions = getActions("mail","mail:smtp:domovilasmtp")

        val telegramAction1 = getActions("telegram","telegram:telegramBot:telegramdomobot")

        var MessageBatSensors = ("Change " + item.label)

        telegramAction1.sendTelegram(MessageBatSensors)

        mailActions.sendMail("xxxxx@gmail.com",MessageBatSensors,MessageBatSensors.toString)

        ]

end
[ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'alarm-11' failed: The name 'item' cannot be resolved to an item or type; line 183, column 47, length 4 in alarm

where the column 47+4 is “item” in (var MessageBatSensors = ("Change " + item.label))

Could you help me with that please? What should I change with my filter rules since openHAB 3?

Thanks,

Travix

Solved by a friend with:

rule "Low Batteries Sensors"

when

        Member of BateriaSensors received update 

then

        if (triggeringItem.state<16)

        {

            val mailActions = getActions("mail","mail:smtp:domovilasmtp")

            val telegramAction1 = getActions("telegram","telegram:telegramBot:telegramdomobot")

            var MessageBatSensors = ("Change " + triggeringItem.label)

            mailActions.sendMail("xxxxx@gmail.com", "Batteria Sensor", "Battery level of: " + triggeringItem.name + " = " + triggeringItem.state.toString)

            telegramAction1.sendTelegram(MessageBatSensors)

        }        

end
1 Like