Nice tutorial.
A few of comments, mostly quibbles.
I’m usually the first person to say that efficiency is not something we need to worry about in this context. But it is slightly more efficient to use the enum types instead of Strings in the comparisons.
if(receivedCommand == ON) {
else if(receivedCommand == OFF) {
For the Color command you can use:
else if(receivedCommand instanceOf HSBType) {
A switch statement might be a little cleaner and easier to read.
Finally, the Rule could be shortened a little using Design Pattern: How to Structure a Rule.
These would change the Rule to something like:
var cmd = "/Users/jakez/openhab/conf/shellscripts/nanoleaf.sh "
switch(receivedCommand) {
case receivedCommand instanceOf OnOffType: cmd = cmd + receivedCommand
case receivedCommand instanceOf PercentType: cmd = cmd + "DIM " + receivedCommand
case receivedCommand instanceOf HSBType: cmd = cmd + "COLOR " + receivedCommand.toString.replace(",", " ")
}
val results = executeCommandLine(cmd, 1000)
Obviously you can add logging as necessary and desired. Just add { } if you want more than one line to run as part of a given case.
Pay special attention to the HSBType because it will require you to slightly reorder the arguments expected by your script. It will print the values in hue, saturation, brightness order. but I figured needing to swap the $2 and $3 in that elif is worth the simplification in the Rule.
Note that I just typed this in and there may be errors.
There is nothing wrong with the original. Like I said, these are mere quibbles. But I like to post alternative shorter versions of code posted like this to show users ways to shorten or make their code a little clearer in some cases.