Strange iteration error

Hi,

I am using the following code in a rule to update the switches associated with my Harmony hub.

	HarmonyCtrl?.members.forEach(harmonyAction|
		postUpdate(harmonyAction, if(harmonyAction.name.removeStart("Harmony") == HarmonyActivity.state.toString) ON else OFF) 
		)

This worked previously very well, however (since an Openhab Update?) the following error occurs in my log:

2016-04-29 13:17:52.749 [ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule ‘HarmonyControl’: Could not invoke method: org.openhab.model.script.actions.BusEvent.postUpdate(org.openhab.core.items.Item,java.lang.Number) on instance: null

HarmonyCtrl is a group the is comprised of the following items:

Group HarmonyCtrl "Harmony Control"
Switch HarmonyAppleTVMusic “AppleTVMusic” (HarmonyGrp, HarmonyCtrl)
Switch HarmonyAppleTVMovie “AppleTVMovie” (HarmonyGrp, HarmonyCtrl, HarmonyBeamer)
Switch HarmonyDVDBluRay “DVDBluRay” (HarmonyGrp, HarmonyCtrl, HarmonyBeamer)
Switch HarmonyiMacMedia “iMacMedia” (HarmonyGrp, HarmonyCtrl)
Switch HarmonyiMacMovie “iMacMovie” (HarmonyGrp, HarmonyCtrl, HarmonyBeamer)

If I replace in the postUpdate command about HarmonyAction with e.g. HarmonyAppleTVMusic everything works (of course not iteration here then). Thus it seems the the HarmonyActions seems to be null.

Any ideas what went wrong here? Again, I could bet it worked before and iterating over a Group like above should really work.

BR,
wartel

Since the update the postUpdate and sendCommand actions have become less flexible when it comes to what sorts of data it will accept. First try switching to the equivalent methods on the Items:

harmonyAction.postUpdate(if(....))

One very frustrating thing about the OH Rules DSL is that almost every error is reported as a Null error. In this case what it means is it cannot convert the ON/OFF into a form that the Item can understand.

You also might try changing the ON else OFF part to "ON" else "OFF" as the actions seem to do better with Strings than other data types.