Smart Lighting Automation with Motion Sensors and Wall Switch Integration

I’ve been experimenting with smart lighting automation in my home, and I wanted to share my setup and a question I’m trying to solve. Currently, I’m using a Nodon in-wall module alongside my traditional wall switches to control my lights. This setup works seamlessly with openHAB, allowing me to toggle the lights manually via the wall switch or through the openHAB interface. I’ve even implemented a rule to turn the lights off after three minutes of inactivity, which has been a great energy-saving feature. Here’s the current rule I’m using:

plaintext
rule “Vorratsraum”
when Item Schalter_EG_Vorratsraum_Licht changed
then
if (Schalter_EG_Vorratsraum_Licht.state == ON ) {
timer = createTimer(now.plusMinutes(3), [ | { Schalter_EG_Vorratsraum_Licht.sendCommand(OFF) } ] )
} else {
if (timer !== null) {
timer.cancel
timer = null
}
}
end

Now, I want to add a motion sensor to the mix. The goal is for the lights to turn on when motion is detected and off after a period of inactivity. However, I want to differentiate between manual activation (via the wall switch) and automated activation (via the motion sensor). Specifically, if the lights are turned on manually, they should remain on for at least three minutes, even if no motion is detected. But if the lights were turned on by the motion sensor, they should turn off immediately when motion stops.

The challenge is that the Nodon module doesn’t distinguish between a command sent by the wall switch and one sent by the motion sensor. I’ve considered using the Item received command event, but it doesn’t provide the necessary differentiation. Does anyone have a solution or workaround for this? I’m open to suggestions or examples of similar setups. Thanks in advance for your help!

Best regards,
/KNEBB