Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rule "Single ZAP Plug"
- when
- Member of FunksteckdosenZAP received command
- then
- logInfo("Power_Plug_ZAP", "Member " + triggeringItem.name + " to " + receivedCommand)
- try {
- // Lock transmitter so other executed rules dont't use it at the same time.
- // Concurrent calls of the rule will wait till the resource is free again.
- transmitter.lock()
- // Get the item which triggered the rule
- // Split the name and get the second part, the number to set as command.
- var num = (Integer.parseInt(triggeringItem.name.toString.split("PowerOutletZap_").get(1)) as Number)
- num = num - 1
- val codes_on = "123,234,345,456"
- val codes_off = "321,432,543,654"
- // Set the command which should be executed to the output channel
- // Auto trigger will then execute the Thing.
- if(receivedCommand == ON){
- Remote_CodeSend_Args.sendCommand(codes_on.split(",").get(num) + " 1 150")
- }else{
- Remote_CodeSend_Args.sendCommand(codes_off.split(",").get(num) + " 1 150")
- }
- // Wait for the command to complete
- while(Remote_CodeSend.state != OFF){
- Thread::sleep(200)
- }
- // Mulltiple trigger do not work if there is no break here
- // maybe external skript needs some time to properly free resources.
- Thread::sleep(400)
- logInfo("Power_Plug_ZAP", Remote_CodeSend_Out.state.toString.replaceAll("\r|\n"," ") )
- }catch(Throwable t) {}
- finally {
- // Free the resource for the next call.
- transmitter.unlock()
- }
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement