String index out of range 11

Hello,

I have a rule in which I process a fixed length string (coming from an arduino mqqt gateway and representing humidity, temperature and RSSI [from RFM69W radio] in the form 58.35:20.12:29.00)
The rule splits the string into 3 parts with substring and are connected with Items. This seems to work well but I get an error in the log and don’t know why ?
Any hints greatly appreciated.

My rule (where can i find the tags for code insertion btw ?)

var String buffer
var String humid
var String temp
var String rfm69RSSI 


rule "weerstation rule"
when
    Item weerstation_hum received update
then 
    buffer=weerstation_hum.state.toString
    humid=buffer.substring(0,5)
    temp=buffer.substring(6,11)
    rfm69RSSI=buffer.substring(12,14)
    logInfo("weerstation",buffer)
    logInfo("humidity   ",humid)
    logInfo("temp       ",temp)
    logInfo("RSSI       ",rfm69RSSI)
    weerstation_hum.postUpdate(humid)
    weerstation_temp.postUpdate(temp)
    weerstation_rssi.postUpdate(rfm69RSSI)
end

Loginfo output

Your rule is triggered by an update to weerstation_hum, which you then update again within the rule.

The value in the new update is invalid for the second round of the rule.

1 Like

Hello namraccr

Thanks for the help, it works now.

Best wishes
Leo