NULL reference in script

I am using the OH 4.3.0 (windows) with following rule (only the first lines are shown at this point):

rule "AudioBad_DimmerDown"

when
    Item Audio__Bad_Audio_Bad_Taster_unten_links received command
then
    switch receivedCommand {
        case OFF : {
            logInfo("Squeezebox AudioBad_DimmerDown","Bad Audio Titel zurueck")
            // Get and log the current number
			**var currNumber = Integer::parseInt(SqueezeBox_Player_Play_a_Favorite.state.toString())**
			

About every second time I call this rule I get following strange error message:

[INFO ] [.script.Squeezebox AudioBad_DimmerUp] - Bad Audio Titel vor
[ERROR] [.handler.AbstractScriptModuleHandler] - Script execution of rule with UID 'AudioBad_DimmerUp-1' failed: For input string: "NULL" in AudioBad_DimmerUp

For me it looks that error is thrown when I try to read the “currNumber” which is the last favorite of my favoritelist of the squeezelite-X player. The favorite list is a mix of some local files and some online radio stations.

When i check in OH the favoritelist I can see the last played number, so that works. But what I am doing wrong here?

Thanks for the help

You are showing the wrong rule, the logged error is in AudioBad_DimmerUp.

As @laursen said, you’ve posted an excerpt from the wrong rule. But "NULL" means that the state of what ever Item you are trying to use in the rule is NULL. Assuming you are trying to parse that, obviously it’s going to fail because “NULL” isn’t a number. You need to test the state to make sure it’s not NULL or UNDEF before trying to use it in this way.

U are right but it is the same at the end because I use exactly the same rule for the button “AudioBad_DimmerUp”

rule "AudioBad_DimmerUp"

when
    Item Audio__Bad_Audio_Bad_Taster_unten_rechts received command
then
    switch receivedCommand {
        case OFF : {
            logInfo("Squeezebox AudioBad_DimmerUp","Bad Audio Titel vor")
            // Get and log the current number
			**var currNumber = Integer::parseInt(SqueezeBox_Player_Play_a_Favorite.state.toString())**