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 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.
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!