Rules or UI issue : page refresh

Dear all

i am a newbie with openhab (2.0) and encountered some issues with refreshing of the classic ui page (though not tested the others)
Let me explain : i have an arduino sending each 30secs through COM port the following message:
A;T0xx.x;T1xx.x;T2xx.x;H0xx.x where xx.X is the value of a temperature or humidity sensor. and A is a node name (for further extension)
i have added to the demo site configuration the followings items, rules and frame:
in items:

String Sonde1 "Jardin [%s]"  { serial="COM10" }

Group arduT
Number T1 "Temperature1 [%.1f °C]" <temperature> (arduT) 
Number T2 "Temperature2 [%.1f °C]" <temperature> (arduT)
Number T3 "Temperature3 [%.1f °C]" <temperature> (arduT)

Group arduH
Number H1 "Humidité1 [%.1f %%]" <humidity> (arduH)
Number H2 "Humidité2 [%.1f %%]" <humidity> (arduH)
 
DateTime arduT_LastUpdate     "Last Update [%1$ta %1$tR]"     <clock>
DateTime arduT_SinceUpdate     "Since [%1$ta %1$tR]"     <clock>


in rules:


import java.util.ArrayList

rule "ArduJardin"
	when 
    		Item Sonde1 received update
 	then
 		var String[] buffer = Sonde1.state.toString.trim.split(";")
		var i = 1
		var j = 0	
		var k = 0
		var l = 0
		val ArrayList<Double> tempera = new ArrayList()
		if (tempera.size == 0) {
			while(j<10) {
				tempera.add(0.0)
				j = j + 1
			}
		}
		j = 0
		val ArrayList<Double> humida = new ArrayList()
		if (humida.size == 0) {
			while(j<10) {
				humida.add(0.0)
				j = j + 1
			}
		}

	  	postUpdate(arduT_LastUpdate, new DateTimeType())
	  	postUpdate(arduT_SinceUpdate, now.minusHours(24).toString)
		switch (buffer.get(0)){
			case "A":{
				i = 1
				k = 0
				l = 0
				while(i<buffer.length-1){
					var String buffer2 = buffer.get(i)
					var String typeS = buffer2.substring(0,1)
					var int NumS = Integer::parseInt(buffer2.substring(1,2))
					switch (typeS){
						case "T":{
							tempera.set(k,new Double( buffer2.substring(2,buffer2.length)))
							i = i + 1
							k = k + 1 
						}
						case "H":{
							humida.set(l,new Double( buffer2.substring(2,buffer2.length)))
							i = i + 1
							l = l + 1 
						}
					}
				}
			}
//			case "B":{}

	}
				j = 0
				arduT.members.forEach[ite |
					postUpdate(ite, tempera.get(j))  
					j = j+1] 
				j = 0
				arduH.members.forEach[ite |
					postUpdate(ite, humida.get(j))  
					j = j+1] 
					
	end

and finally in sitemap

	Frame label="La maison" {
			Frame {
				Switch item=Weather_Chart_Period label="Chart Period" icon="chart" mappings=[0="Hour", 1="Day", 2="Week"]
				Chart item=arduT period=h refresh=6000 visibility=[Weather_Chart_Period==0, Weather_Chart_Period=="NULL"]
				Chart item=arduT period=d refresh=36000 visibility=[Weather_Chart_Period==1]
				Chart item=arduT period=W refresh=36000 visibility=[Weather_Chart_Period==2]
Text item=arduT_LastUpdate
Text item=arduT_SinceUpdate

}
		Text item=T1 valuecolor=[>25="orange",>15="green",>5="orange",<=5="blue"]
		Text item=T2 valuecolor=[>25="orange",>15="green",>5="orange",<=5="blue"]
		Text item=T3 valuecolor=[>25="orange",>15="green",>5="orange",<=5="blue"]

		Text item=H1 valuecolor=[>75="orange",>45="green",<=30="blue"]
	}



Everything is working almost fine, values are updated as required, the RRd4j graphs are logging the value ok.
However i have a “bug” in the page update. Indeed, when an update is triggered (arduino sending the string), if there is a change in one (or more) of the temperature or humidity values, the values in the UI page are mixed up (Temperature1 is showing for example the temperature2 value or Humidité is showing a temperature1 value). However the event log is showing the correct value update (as well as the rrd4 graph). If i do a manual refresh (reload page) of the UI page, everything get back fine (correct values at the correct item).
Is there something wrong in my configuration (eclipse designer is telling me that the var j can not be used in the foreach loop)or is this a bug of the UI?
Also, the strange thing is that if i use a simpler rule file (see below), the issue do not appear

rule "ArduJardin"
	when 
    		Item Sonde1 received update
 	then
 		var String[] buffer = Sonde1.state.toString.trim.split(";")
		var i = 1
		var j = 0	
		val ArrayList<Double> tempera = new ArrayList()
		if (tempera.size == 0) {
			while(j<10) {
				tempera.add(0.0)
				j = j + 1
			}
		}
	  	postUpdate(arduT_LastUpdate, new DateTimeType())
	  	postUpdate(arduT_SinceUpdate, now.minusHours(24).toString)
		switch (buffer.get(0)){
			case "A":{
				i = 1
				while(i<buffer.length-1){
					var String buffer2 = buffer.get(i)
					var String typeS = buffer2.substring(0,1)
					var int NumS = Integer::parseInt(buffer2.substring(1,2))
					tempera.set(i,new Double( buffer2.substring(2,buffer2.length)))
					i = i + 1
						}
					}
//			case "B":{}

		}
				j = 0
				arduT.members.forEach[ite |
					postUpdate(ite, tempera.get(j))  
					j = j+1]			
	end	

Hi all

OK, i think i found my errors…(though not tested)
first : val for tempera and humida is probably not the proper choice and i should probably use var instead.
second: this lambda expression stuff. i believe i shoud use something like

			arduT.members.forEach[ite, index |
					postUpdate(ite, tempera.get(index))  
					]			

Am i in the right direction?
HAve to test that this evening…when back home
However Still not understand why the second, simpler version was working…
Joël