- OH3 openHABian on rPi4 with 4GB
2023-07-30 10:26:41.167 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'weather-1' failed: Index 2 out of bounds for length 1 in weather
This is the weather-1 rule:
rule "Weather: Ambient light last reboot"
when
Item al_KDL_Notification received update
then
if (al_KDL_Notification.state.toString == "AmbientLight_01|INFO|has rebooted")
{
logInfo(LOG_PREFIX + "01.01", "--> Shed ambient light has rebooted :(")
al_KDL_LastReboot.postUpdate(new DateTimeType())
// logging controller reboots to file
val String ERROR_MESSAGE = LocalDateTime.now().toString + " " +
"Shed ambient light has rebooted"
val String CLI_RETURN_CODE = executeCommandLine(Duration.ofSeconds(3),
"/bin/sh", "-c", "echo " + ERROR_MESSAGE +
" >> /etc/openhab/html/AmbientLight_01.txt; echo -n $?")
logInfo(LOG_PREFIX + "01.02", "AmbientLight_01 error logged to file")
if (Integer::parseInt(CLI_RETURN_CODE) != 0)
{
logInfo(LOG_PREFIX + "01.03", "Return code: {}", CLI_RETURN_CODE)
}
}
else if (al_KDL_Notification.toString.contains("|INFO|"))
{
var STRING_TO_SPLIT = al_KDL_Notification.state.toString
var STRING_ARRAY = STRING_TO_SPLIT.split("\\|")
var NUM_ARRAY_ELEMENTS = STRING_ARRAY.length()
//logInfo(LOG_PREFIX + "01.04", "STRING_ARRAY............: {}", STRING_ARRAY)
//logInfo(LOG_PREFIX + "01.05", "NUM_ARRAY_ELEMENTS........: {}", NUM_ARRAY_ELEMENTS)
if (NUM_ARRAY_ELEMENTS == 3)
{
al_KDL_Notification.postUpdate(al_KDL_Notification.state.toString.split("\\|").get(2))
}
}
end
What maybe weird with this rule is that `al_KDL_Notification’ receives a MQTT string, which is then subsequently updated with a reduced version of said string… which mostly does not re-trigger the rule, but when it does causes the error.
Maybe I need to add a proxy item and updated that with the reduced string?!