Problem with OpenHab, Lirc, XBMC & repeats

Hi all,

Solved the problem, something wrong in the timer logic. Working rule below for those interested.

Joost

var Timer IR_timer // track that command is actually different from prev (200ms)
var String IR_prevCmd = ""

// rules for remote
// execute function based on pressed key on harmony remote
rule "Handle IR Keys via TCP"
    when
        Item IR_command received update
    then
        var kodiPar = ""
        //logInfo("IR_command:", IR_command.state.toString())
        // strip and get key
        var String[] buffer = IR_command.state.toString.split(" ")
        // check if we can extract something
        if (buffer.size()>=2) {
            var command = buffer.get(2)
            // check if new command, timer handles repeats
            if (IR_prevCmd != command) {
                IR_prevCmd = command
                logInfo("IR stripped command", "received: " + command +"\n");
                // set kodi param based on key
                switch command {
                    // top section
                    case "KEY_PREVIOUSSONG": { kodiPar="stepback" } // << or bigstepback or skipprevious
                    case "KEY_REWIND": { kodiPar="rewind" } // <
                    case "KEY_NEXTSONG": { kodiPar="stepforward" } // >> can also be bigstepfoward or skipnext
                    case "KEY_FASTFORWARD": { kodiPar="fastforward" } // >
                    case "KEY_PAUSE": { kodiPar="playpause" }
                    case "KEY_PLAY": { kodiPar="playpause" }
                    case "KEY_RECORD": { kodiPar="" }
                    case "KEY_STOPCD": { kodiPar="stop" }
                    // touch section
                    case "KEY_POWER": { kodiPar="" } // prevent shutdown!
                    // ...
                    // want to assign some custom keys here, e.g. spotify, games, based on keyb commands?
                    // e.g. pres touch-key "SPOTIFY" send KEY_ALT_Q -> calls Kodi run addon "Spotify" or something
                    // bottom section
                    case "KEY_ESC": { kodiPar="close" } // not sure if this is the right one
                    case "KEY_MENU": { kodiPar="contextmenu" } // UNASSIGNED IN REMOTE
                    case "KEY_UP": { kodiPar="up" }
                    case "KEY_DOWN": { kodiPar="down" }
                    case "KEY_LEFT": { kodiPar="left" }
                    case "KEY_RIGHT": { kodiPar="right" }
                    // special case: if playing, show OSD else enter
                    case "KEY_ENTER": { 
                        var player = xbmcPlayerState.state.toString()
                        switch player { 
                            case "Play": { kodiPar="enter" }
                            // default is select 
                            default: { kodiPar="select" } // must be select
                        }
                    }
                    case "KEY_VOLUMEUP": { kodiPar="volumeup" }
                    case "KEY_VOLUMEDOWN": { kodiPar="volumedown" }
                    case "KEY_CHANNELUP": { kodiPar="pageup" }
                    case "KEY_CHANNELDOWN": { kodiPar="pagedown" }
                    case "KEY_MUTE": { kodiPar="mute" }
                    case "KEY_BACK": { kodiPar="back" } // 
                    case "KEY_DVR": { kodiPar="" }
                    case "KEY_PROGRAM": { kodiPar="" } // guide
                    case "KEY_PROPS": { kodiPar="info" } // info
                    case "KEY_RED": { kodiPar="" }
                    case "KEY_GREEN": { kodiPar="" }
                    case "KEY_YELLOW": { kodiPar="" }
                    case "KEY_BLUE": { kodiPar="" }        
                }
                // if we have something, send it
                if (kodiPar != "") {
                    logInfo("Sending to Kodi:", kodiPar)
                    sendCommand(xbmcInputAction, kodiPar)
                }
                // set timer to rest the cmd
                IR_timer = createTimer(now.plusMillis(100)) [|
                    // reset
                    IR_prevCmd = "";
                    logInfo("IR","prevCmd reset")
                ]
            } else {
                // nothing
                logInfo("IR","ignoring, repeat")
            }
    }
end