What are you hoping to accomplish? This might be an XY problem.
Beyond that @jimtng has the answer. items.existsItem() only supports checking to see if a single Item exists by name, but you are passing it an array. If you do in fact have more than one Group Item per key in your map, you’ll have to account for that when checking if the Items exist.
.every() will return true only if every member of the array exists. Once you are inside the if you need to treat each element of the array individually through a loop.
fffGroup_GF_Livingroom_SwitchLight
2025-02-07 21:57:17.088 [ERROR] [openhab.core.model.script.scene rule] - Some bad stuff happened in "scene rule": TypeError: lightSwitchGroupItem.every is not a function
What I try to accomplish is …depending on the trigger I want to select a group of light switches and than chek if the items existing than I want to send the command off to them.
The problem is that lightSwitchGroupItem is
string
I solved it by
const lightSwitchMap = {
Sensor_GF_Bedroom_NumberLightScene: "Group_GF_Bedroom_SwitchLight",
Sensor_GF_Livingroom_NumberLightScene: "Group_GF_Livingroom_SwitchLight"
};
let lightSwitchGroupItem = items.getItem(lightSwitchMap[event.ItemName
lightSwitchGroupItem.members.forEach(function(member) {
if (items.existsItem(member.name)) {
member.sendCommand("OFF");
}else{
actions.Log.logWarn("activate deConz Scene", "Item " + member + " does not exist");
}
});
);
There are two separate solutions presented above. @jimtng’ s solution stoves your original probably problem by eliminating the array. My solution keeps the array.
You’ve combined the two to create a broken version.
Which is @jimtng 's solution which eliminates the array.