Hello,
I’m having an weird issue for some hours now…
Having this part of my script:
val nextValveNum = 0
val nextValveName = ""
val nextValveSwitch = null
val activeValves = gIrrigationTime.members.filter[t|t.state > 0]
logInfo("Irrigation", "--------------------------------------------")
var boolean exitFlag = false
activeValves.forEach[i|
if(!exitFlag) {
logInfo("Irrigation", i.toString)
val valveTimeName = i.name.toString
val valveName = valveTimeName.split("_").get(0) + "_" + valveTimeName.split("_").get(1)
val valveNum = Integer::parseInt(valveName.split("_").get(1)) // Irrigation_1_Time
if(valveNum > currValveNum) {
logInfo("Irrigation", "Found new active valve: " + valveName.toString)
nextValveNum = valveNum
nextValveName = valveName
nextValveSwitch = gIrrigation.members.filter[i|i.name == valveName].head
logInfo("Irrigation", gIrrigation.members.filter[i|i.name == valveName].head.toString)
logInfo("Irrigation", nextValveNum.toString)
logInfo("Irrigation", nextValveName.toString)
logInfo("Irrigation", nextValveSwitch.toString)
exitFlag = true
}
} else {
logInfo("Irrigation", "Already found a next valve!")
}
]
logInfo("Irrigation", "Continuing")
I’m trying to fill nextValveSwitch with the valve from gIrrigation which has a runtime greater than 0. So far so good, I’m getting this error:
2017-04-17 22:14:06.298 [INFO ] [se.smarthome.model.script.Irrigation] - --------------------------------------------
2017-04-17 22:14:06.318 [INFO ] [se.smarthome.model.script.Irrigation] - Irrigation_1_Time (Type=NumberItem, State=2.0, Label=null, Category=null, Groups=[gIrrigationTime])
2017-04-17 22:14:06.364 [INFO ] [se.smarthome.model.script.Irrigation] - Irrigation_5_Time (Type=NumberItem, State=2.0, Label=null, Category=null, Groups=[gIrrigationTime])
2017-04-17 22:14:06.456 [INFO ] [se.smarthome.model.script.Irrigation] - Found new active valve: Irrigation_5
2017-04-17 22:14:06.579 [INFO ] [se.smarthome.model.script.Irrigation] - Irrigation_5 (Type=SwitchItem, State=OFF, Label=State, Category=Switch, Groups=[gIrrigation])
2017-04-17 22:14:06.589 [INFO ] [se.smarthome.model.script.Irrigation] - 5
2017-04-17 22:14:06.598 [INFO ] [se.smarthome.model.script.Irrigation] - Irrigation_5
2017-04-17 22:14:06.608 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'Irrigation switch cascade': The name '<XFeatureCallImplCustom>.toString' cannot be resolved to an item or type.
So it looks like it can’t fill the “nextValveSwitch” var.
How can I fix that?