I have trouble finding the mistake in this script. I try to build a lighting control where the user can modify the light settings and then save them to one of many scenes (i.e. Night, TV, Game, Music …)
Every light fixture is within a specific group. Every fixture has one Item for every scene to store the Light (RGB) settings. Part of the SaveScene Function:
val org.eclipse.xtext.xbase.lib.Functions$Function2 SaveScene = [ String Group, int Scene| LightColors.allMembers.filter(i | i.groupNames.contains("LightC_"+Group)).forEach(i | logInfo("Light","Save Scene: "+Scene+" Color: " +i) var String ItemName = i.name ) true ]
This incomplete code loops through all Items inside the Group “LightC_X”, The log Info works as expected:
2016-05-07 10:03:35.058 [INFO ] [org.openhab.model.script.Light] - Save Scene: 2 Color: Light_1_1_C_0 (Type=ColorItem, State=103.799995,76.114639,43.000000) 2016-05-07 10:03:35.125 [INFO ] [org.openhab.model.script.Light] - Save Scene: 2 Color: Light_1_3_C_0 (Type=ColorItem, State=33.599998,82.006371,54.000004) 2016-05-07 10:03:35.139 [INFO ] [org.openhab.model.script.Light] - Save Scene: 2 Color: Light_1_2_C_0 (Type=ColorItem, State=142.800003,70.382164,65.333328)
But the next line give an error
2016-05-07 10:03:36.872 [ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule ‘Save scene’: The name ‘i’ cannot be resolved to an item or type.
The Designer do not like the line "logInfo(“Light”,“Save Scene: “+Scene+” Color: " +i)” = “incompatible types. Expected java.lang.String but was org.openhab.core.items.Item” but it work see log.
I Need the Name of the Item to find the coresponding ID, Group Number.
I always have trouble with type conversions … can somebody help, please?