How to create a group of disparate items

I’m not sure if this is possible. I have a front porch light and I want it to come on in response to the front door opening or the outside motion sensor being triggered.

The sensor items are defined like so;

Contact FrontDoorSensor "Front Door Sensor[%s]" <door> {channel="zwave:device:46feb3ec:node21:sensor_door"}
Switch FrontPorchMotionSensor "Front Porch Motion Sensor[%s]" <motiondetector> {channel="zwave:device:46feb3ec:node20:sensor_binary"}

The door sensor toggles between states of OPEN and CLOSED and the motion sensor toggles between states of ON and OFF. Is there a way of creating a group containing these with an OR aggregation function such that the group item returns ON or OPEN if either of the sensors becomes ON/OPEN?

I don’t think so. However, you might be able to use the SUM aggregation function and use the count to know if one or both are open.

Group:Number:Sum FrontSensors
rule "Front Sensors changed"
when
    Item FrontSensors changed
then
    val currCount = FrontSensors.state

    if(currCount > previousState) {
        // you know that one of the sensors changed to ON or OPEN
    }
    else{
        // one of the sensors changed to OFF or CLOSED
    }
end

I don’t know for sure this will work but think it should.

I have tested this today and can confirm that using SUM to aggregate the items does work. I can use FrontSensors.state > 0 to achieve an OR and FrontSensors.state == 2 to achieve an AND.

Thanks very much (again).