How does this rule get triggered? It seems odd to test the state of the motion sensor if it was the motion sensor that triggered the rule in the first place. You can make it so the rule only triggers when the sensor goes to ON which would be a pretty standard motion sensor timer kind of approach. With this kind of trigger, you’ll already know that the motion sensor is ON and there’s no need to test for it in the script action.
I would recommend using more meaningful Item names. “BasementHallMotionSensor” is a lot more meaningful to you the human (who is the one who needs to read and understand your OH rules and other configs in the future) than “ZWaveNode002ZWA005Motionlightandtemperaturesensor_Motion”. Especially if you have a bunch of these devices in your system. By the time it gets to be represented by Items, the fact that it’s ZWave and specifics like that do not and should not matter.
I wouldn’t go and change your existing Item names now, particularly if you’ve a lot of them and they are used by name in a bunch of places (rules, widgets, etc). But in the future, think about Item names more from the perspective of telling other members of the household what it is. You wouldn’t say to your kids “go turn off ZWaveNode003FGS224FibaroDoubleSmartModule_Switch1”, you would say “go turn off the basement hallways light”. So name the Items that way. It will make your rules and configs much easier for you to understand and maintain in the long run.
Make this a rule condition.
Note, a rule includes a lot outside of the Script Action. So while it’s important to have a screen shot of the Blockly, it’s very helpful to see the rest of the rule too. So go to the “Code” tab and paste in everything you find there into your forum posts so we can all see a fuller picture of the rule. Use code fences:
code goes here
To diagnose what’s wrong we’ll need to see the full rule, snippets of the events log that should trigger the rule and see whether or not the switches go OFF 30 seconds later.
It would also be helpful to add some logging to show the rule gets triggered, and what parts of the rule get executed. Those will appear in openhab.log.