I’ve a problem but I cannot solve alone.
I have some items in a group, called
I would like to know which is calling. I use this
val oggettochiamata = triggeringItem
val oggettoprincipale = oggettochiamata.name.split("_Timer")
but if Item1 is calling, I receive this error:
[ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘gestione_timer_stufa1’ failed: Index 1 out of bounds for length 1
How can I change the behavior and check if “_Timer” is into the name of calling item or not without having an error?
Thanks to all
I suppose you could use string method
.contains("xx") in an if() test.
EDIT - maybe its .
includes("xx") depending on Java version.
Thanks for your info. You give me the right way…
After many errors, I found the right way for my java is:
.indexOf("String") > 0
into if statement.
if (oggettochiamata.name.indexOf("Timer") > 0)
btw… other than triggeringItem, there is a way to extract the name of the group calling?
If I have
item1, item1_TimerOn, item1_TimerOff and
item2, item2_TimerOn and both group fire the rule, how can I find the right group assignment?
To find group(s) that an Item is a member of -