Trouble sending string over serial binding

I am trying to send a string containing a variable over the serial binding. Specifically, I want to send the following string over the serial port (the actual string to send is between the quotation marks:

“51 GAIN 1 O [value] A”

where [value] is a number derived from the position of a slider item (in this case, the variable KitVol - I do not want to send the brackets).

For example:

51 GAIN 1 O 11 A

would be the string that goes out on the port.

To do this, I have defined a dimmer item called KitchenVolume. Because the dimmer returns a value from 0 to 99, and I need to convert that to a value between -80 and 20, I have written the following rule:

var Number KitVol = 0
var Number OffVol = 0
var Number SunVol = 0
var Number PoolVol = 0
var Number value = 0


rule KitchenVolumeChange
        when
        item KitchenVolume received update
        then
        value = KitchenVolume.state as DecimalType
        KitVol = value - 80
        sendCommand(ClearOne, "51 GAIN 1 O " + KitVol + " A \n")
        sendCommand(ClearOne, "51 GAIN 2 O " + KitVol + " A \n")
end

Nothing happens when I do this, and I see no errors in the log.

The relevant section of my items is:

String ClearOne “ClearOne Mixer” (AudioVis) { serial="/dev/ttyUSB0" }
Dimmer KitchenVolume “Kitchen Volume [%d %%]” (AudioVis)

The ClearOne device is responding to other serial commands sent by Openhab2, so I know that item is working properly. I am sure my problem is a syntax error in the rule, and I do not know what it is.

Many thanks,

-Mark

As a first check I would print the desired output to the log like:.

var String MyOutput="51 GAIN 1 O " + KitVol + " A \n"
LogInfo (“MyLog”, “MyOutput={}”,MyOutput)

Jurgen-

Thank you for your reply. I am not seeing anything in my logs (openhab.log) regarding the string.

My event log records (as it always has):

2016-12-09 08:17:04.077 [ItemStateChangedEvent     ] - cpuCombined changed from 4.1772796739684157074634640594013035297393798828125 to 19.867211440245146292$
2016-12-09 08:17:04.301 [ItemCommandEvent          ] - Item 'KitchenVolume' received command 88
2016-12-09 08:17:04.305 [ItemStateChangedEvent     ] - KitchenVolume changed from 49 to 88
2016-12-09 08:17:04.500 [ItemCommandEvent          ] - Item 'KitchenVolume' received command 88
2016-12-09 08:17:04.698 [ItemCommandEvent          ] - Item 'KitchenVolume' received command 39
2016-12-09 08:17:04.701 [ItemStateChangedEvent     ] - KitchenVolume changed from 88 to 39
2016-12-09 08:17:04.900 [ItemCommandEvent          ] - Item 'KitchenVolume' received command 39

My new rule is:

rule KitchenVolumeChange
        when
        item KitchenVolume received update
        then
        value = KitchenVolume.state as DecimalType
        KitVol = value - 80
        var String MyOutput="51 GAIN 1 O " + KitVol + " A \n"
        LogInfo ("MyLog", "MyOutput={}",MyOutput)
        sendCommand(ClearOne, "#51 GAIN 1 O " + KitVol + " A \n")
        sendCommand(ClearOne, "#51 GAIN 2 O " + KitVol + " A \n")


indent preformatted text by 4 spaces


                  __  _____    ____
  ____  ____  ___  ____  / / / /   |  / __ )
 / __ \/ __ \/ _ \/ __ \/ /_/ / /| | / __  |
/ /_/ / /_/ /  __/ / / / __  / ___ |/ /_/ /
\____/ .___/\___/_/ /_/_/ /_/_/  |_/_____/
/_/                        2.0.0.b4
                       Build #477

Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown openHAB.

openhab> log:list
Logger                                                      | Level
-------------------------------------------------------------------
MyLog                                                       | INFO
ROOT                                                        | ERROR
javax.jmdns                                                 | ERROR
org.eclipse.smarthome                                       | INFO
org.jupnp                                                   | ERROR
org.openhab                                                 | INFO
org.openhab.action.ecobee                                   | ERROR
org.openhab.binding.ecobee                                  | ERROR
org.openhab.binding.serial                                  | ERROR
org.openhab.binding.yamahareceiver                          | ERROR
org.ops4j.pax.web.service.jetty.internal.JettyServerWrapper | ERROR
smarthome.event                                             | INFO
smarthome.event.InboxUpdatedEvent                           | ERROR
smarthome.event.ItemStateEvent                              | ERROR
smarthome.event.ThingStatusInfoEvent                        | ERROR

What am I doing wrong?

Many thanks,

-Mark

when
    Item KitchenVolume received update
then

Case matters. “Item” needs to start with an uppercase ‘I’.

Rich-

As usual, my hasty typing and proofreading caught me again. I had two such case errors - fixing them has solved the problem. Thank you Rich and Jurgen for your help!

Many thanks,

-Mark

Designer would have caught this error as you typed it. As clunky and full of faults as many claim it to be, using Designer is a huge time saver.