[SOLVED] DecimalType and StringType

Hi. I have OpenHab2.2. As a startup rule I try do define some Items:

	gInitZero.allMembers.filter( x | x.state == Uninitialized || x.state == NULL).forEach[ item |
		item.postUpdate(0 as DecimalType)
	]
	gInitString.allMembers.filter( x | x.state == Uninitialized || x.state == NULL).forEach[ item |
		item.postUpdate("" as StringType)
	]

Log file reports:
Cannot cast from int or Integer to DecimalType
Cannot cast from String to StringType

I tried declaring var DecimalType blabla = 0, but no luck. Also not found any solution up to now…
BTW In HAB1.x it worked great…

How to change?

what happens if you just deleted the statements ‘as DecimalType’ and ‘as StringType’

You don’t need “as DecimalType” and “as StringType”.
Check if use need “x.state == Uninitialized”.

Log reports error and does not run openahb… :frowning:

What kind of errors?

do you mean your rule does not finish? Or that OH2 stops working?

Well, thank you very much to all of you!!!
It seems the code below works. I tried it before and the OH2 reported error of rules file and did not start.
Now I did the same trick and restarted several times and it works. I must have been something else… I am sitting behind PC and migrating from OH1 to OH2. Now is my third day in a row…

gInitZero.allMembers.filter( x | x.state == Uninitialized || x.state == NULL).forEach[ item |
	item.postUpdate(0)
]
gInitString.allMembers.filter( x | x.state == Uninitialized || x.state == NULL).forEach[ item |
	item.postUpdate("")
]

The only error I have to solve is “arping” in Windows 10. I have copied the arping.exe in all directories of OH2 and it is still not discovered. I get error: Cannot run program “arping” (in directory " . ")… System cannot find the file…

Thank you all again!