Rule for batch processing of input/outputs

it is case sensitive

the state is returned as NULL (you can see also in your logs)

you can simplify the rule by using only 1 forEach with:

rule "Initialize switch states"
when
	System started
then
	gLights?.members.forEach[lamp | 
		logInfo("LAMP", lamp.name + " " + lamp.state.toString)
		if (lamp.state != NULL) {
			lamp.sendCommand(lamp.state.toString)
		}
	]
end

it is not as sophisticated as using a filter for the forEach statement but it works :slight_smile:

Maybe your filter approach will work if you check for != NULL

Ps: did you have to use if (lamp.state.toString != NULL) or the if (lamp.state != NULL) worked? (without the .toString part)

Yep, changing null to NULL does the trick.

Confusing language though.

Why I put null is that anywhere in examples shown check against null not NULL.
Besides that nowhere was emphasized what type of check SHALL be used in this or that case.
Or maybe I badly read docs.

1 Like

…or it’s time for you to contribute also to their development :slight_smile:
(I don’t think that you badly read docs… sometimes they are badly written :stuck_out_tongue:)

by the way: I think that NULL in this case is the string that is returned (not the absence of a value)