Rule error message only with Openhab 3

Hello,

I installed the latest Openhabian 3 64-bit onto a new micro SD card yesterday.
The setup worked great and I was able to access the folders via network access and insert my existing files from the working Openhab 2 version.

Unfortunately, I now get the following error messages in the rules for reading the stings of the USB serial connection to the Arduino:

items
String Arduino "Arduino [%s]" (arduino) {serial="/dev/ttyACM0@115200"} 

rules
rule "Arduino Lesen"
when 

Item Arduino received update or
Item Arduino changed 

then

var String ArduinoUpdate = Arduino.state.toString.trim

if (ArduinoUpdate.toString.contains("Buero")) {

var int LichtBueroStartetBei = ArduinoUpdate.indexOf("Licht_Buero,") + "Licht_Buero,".length

var String LichtBuero = ArduinoUpdate.mid(LichtBueroStartetBei, ArduinoUpdate.indexOf(';')- 
LichtBueroStartetBei)

 if (LichtBuero == "ON" || LichtBuero == "1") {
Buero_Licht_Allgemein_Schalter_HABPANEL.postUpdate(ON)

}else if (LichtBuero == "OFF" || LichtBuero == "0") {
Buero_Licht_Allgemein_Schalter_HABPANEL.postUpdate(OFF)
}  
}


=> /var/log/openhab/openhab.log <==

2020-12-31 04:15:08.230 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule    
with UID 'Arduino-1' failed: 'mid' is not a member of 'java.lang.String'; line 89, column 33, length 104 
in Arduino

2020-12-31 04:15:08.239 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule 
with UID 'Arduino-1' failed: 'mid' is not a member of 'java.lang.String'; line 89, column 33, length 104 
in Arduino

I have opened and read all kinds of links on the internet and I cannot find the error…
I have already used “Mid” or just “Mid”/“mid” etc.

### Syntax

Mid(string,start[,length])

  |Parameter|Description|

  string     Required. The string expression from which characters are returned|
  start      Required. Specifies the starting position. If set to greater than the number of 
             characters in string, it returns an empty string ("")|
  length     Optional. The number of characters to return|

Thank you very much in advance for your support!

Greetings
Tobi

Looking at the class string ( String (Java SE 11 & JDK 11 ) ) you need to use substring. Mid is not listed there.

Hello Wolfgang,

thank you very much for your quick answer!

I had already tried “SUBSTRING” tonight, but I think now with a new start and your really very good link to Oracle I will try it again in peace.

Thank you very much again and I will get back to you as soon as I have done it.

Greetings
Tobi

1 Like

There is no such thing as “openHABian 3”, it’s openHAB 3 on latest openHABian which has a different numbering scheme, v1.6.2 being the current version.
So please change the thread title.
And you read about the 64 bit image not being supported, didn’t you ?

1 Like

Hello mstromi,

you are absolutely right about Openhab 3 and not Openhabian 3.

But I hadn’t quite understood that it basically doesn’t work with the 64-bit version.
I also noticed earlier that although I have established a serial connection via /dev/ttyACM0 from the Arduino to the Raspberry, I can’t get the data into Openhabian. This might be one of your reasons why I should switch to 32-bit or?

I’ll set up the 32-bit image now and get back to you.
Forgive me for not having seen the trees for the forest or for being too dogged to read the texts more carefully…

Greetings
Tobi