Variable errors in rule

Hi Forum,

I’m trying to populate a string and then send that as a command , but I keep getting this error. Even if i change the val to be the same name, i get another duplication error. Thoughts as to why? just trying to populate an item

08:45:20.546 [INFO ] [del.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model ‘linn.rules’, using it anyway:
The value of the local variable result is not used

My rule:

Item KDS_Power received command
val power = ‘Action Preamp/Product 2 SetStandby "’ + if (receivedCommand == ON) ‘0"’ else ‘1"’
logInfo(“Linn”, power)

val result = executeCommandLine("/etc/openhab2/scripts/" + power, 5000)
logInfo("Linn", "result: {}", power)



This warning is harmless, but true so far i can see. You don’t use the var result.

Isnt var result, what executes the command? It needs a name of some sort right?

No it don’t need to, unless you want to do something with the result.

So how would I run that execute commandline argument without it?

Yes indeed

:thinking: that was a question, not a comment.

Sorry read it wrong

Just run this in your rule:
executeCommandLine("/etc/openhab2/scripts/" + power, 5000)

More info:

1 Like

thanks, didnt realise I could just remove that val =

Thanks Laurens!

The warning is due to not using the variable. It looks like you may have meant to use this instead…

logInfo("Linn", "result: {}", result)

thanks, fixed it with the suggestion above :slight_smile:

1 Like