I never worked with a procedure but to cleanup my code I was trying to create a procedure but get many errors and don’t know how to solve it. I also couldn’t find a description how to do this.
I tried to solve it in many ways based (2 are below) on what I found but without success so I hope someone can help.
//items file
//Color KantoorLampenKleur "Kleur" <colorpicker> (BG_Kantoor)
//Group: Dimmer :AVG Kantoorlampen "Alle lampen" <light>
val Procedures$Procedure2<String, String> setColorForGroup = [String colorItemName, String groupName |
val Iterable<GenericItem> groupItems = ScriptServiceUtil.getItemRegistry.getAll().filter[item | item.groupNames.contains(groupName)]
var hue = (getGroupItem(colorItemName).state as HSBType).getHue
var sat = (getGroupItem(colorItemName).state as HSBType).getSaturation
var brightness = (getGroupItem(colorItemName).state as HSBType).getBrightness
val HSBType newColor = new HSBType(hue, sat, brightness)
groupItems.forEach[item | sendCommand(item, newColor.toString)
]
]
val Lampkleuraanpassen = [gebruikkleur Color, gebruikgroep Group|
var hue = (gebruikkleur.state as HSBType).getHue
var sat = (gebruikkleur.state as HSBType).getSaturation
var brightness = (gebruikkleur.state as HSBType).getBrightness
val HSBType color = new HSBType(hue, sat, brightness)
gebruikgroep.members.forEach[ i | sendCommand(i, color.toString)]
]
rule "Kleur lampen aanpassenr"
when
Item KantoorLampenKleur received command
then
setColorForGroup.apply ("KamerLampenKleur", "Kantoorlampen")
Lampkleuraanpassen (KamerLampenKleur, Kantoorlampen )
end