[SOLVED] Splitting Strings in Rules

I would also like to split a string within a rule.

My Powermax binding gives a status from the ITEM here.

String Powermax_LCD “System LCD Display [%s]” (GPowerMax) {powermax=“partition_status”}

this returns a value like.

Disarmed, Ready, Violated (Motion) in Zone 2

Wanted to split this into 3 Items

String AlarmLCD1 “System LCD Line 1” (GPowerMax)
String AlarmLCD2 “System LCD Line 2” (GPowerMax)
String AlarmLCD3 “System LCD Line 3” (GPowerMax)

I have tried using the following within a rule.

val LCDLines = Powermax_LCD.state.split(",")
postUpdate(AlarmLCD1, LCDLines[0])

but this generates errors.
What is the correct way to split a string within a rule.

Thanks.

1 Like

Can this help you a little bit?

rule "send notification bei eingehendem Anruf"
	when
		Item Call_Incoming received update
	then
		if (Call_Incoming.state==ON) {
				val tel00 = Call_Incoming_No.state.toString.split(',').get(0)
				val tel01 = Call_Incoming_No.state.toString.split(',').get(1)
				if (tel00=="012345" && tel01=="0987654") {...
1 Like

The problem is the usage of the array-syntax in a rule, which isn’t possible.
Instead of “LCDLines[0]” use “LCDLines.get(0)”.
That has been written already in the other thread in which you have posted the same question.