[Solved] Rule does not update item

The following rule does not enter the first if, hence does not update the item:

String   OutsideShell_Firmware      "OutsideShell firmware [%s]"        <ram>           (gHouse_OutsideShell)

with the following rule:

rule "OutsideShell Notifications"
when
	Item OutsideShell_Message received update
then
	logInfo("house1", OutsideShell_Message.state.toString)
	logInfo("house2", OutsideShell_Message.state.toString.substring(0,8))
	logInfo("house3", OutsideShell_Message.state.toString.substring(9,OutsideShell_Message.state.toString.length))

    if (OutsideShell_Message.state.toString.substring(0,8) == "firmware=")
    {
		logInfo("house4", "in if")
        OutsideShell_Firmware.postUpdate(OutsideShell_Message.state.toString.substring(9,OutsideShell_Message.state.toString.length))
    }

	if (OutsideShell_Message.state.toString == "UNO_OutsideShellSensors|INFO|has rebooted")
	{
		logInfo("house5", "--> UNO_OutsideShellSensors has rebooted.")
		OutsideShell_LastReboot.postUpdate(new DateTimeType())
	}
end

However, the log entries show the correctly split substrings:

2020-09-23 20:43:14.528 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'house.rules'
2020-09-23 20:43:26.190 [INFO ] [clipse.smarthome.model.script.house1] - firmware=v0.2.2
2020-09-23 20:43:26.197 [INFO ] [clipse.smarthome.model.script.house2] - firmware
2020-09-23 20:43:26.202 [INFO ] [clipse.smarthome.model.script.house3] - v0.2.2

I can’t find the problem. Any hints appreciated.

The substring (0,8) of the state is firmware and you check it against firmware=.

2 Likes

Oh dear, it is so obvious. :sleeping:

You won’t find such an error by looking at your code, you’ll find it instantly after posting.

2 Likes

Exactly :smiley: