In a js ECMA 11 based script in a rule, I have been trying to check, whether the tags of an item, contain a certain String value. For some reason, the item.tags.includes("SomeTag")
returns
an ominous error message:
2022-12-03 15:42:30.687 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'motionON' failed: org.graalvm.polyglot.PolyglotException: TypeError: invokeMember (includes) on java.util.Collections$UnmodifiableSet@ee3872 failed due to: Unknown identifier: includes
when checking Array.isArray(p.tags) this returns indeed false
when doing the following:
var motionItem = items.getItem(event.itemName);
console.log('Motion Item ',motionItem.name);
var sensor = actions.Semantics.getEquipment(motionItem.rawItem);
console.log('Equipment',sensor.name);
sensor.members.forEach(p => {
console.log(p.name, p.tags, typeof p.tags, Array.isArray(p.tags));
})
as seen here:
2022-12-03 15:32:54.482 [INFO ] [penhab.automation.script.ui.motionON] - Motion Item OfficeDirk_Motion
2022-12-03 15:32:54.499 [INFO ] [penhab.automation.script.ui.motionON] - Equipment OfficeDirk_Sensor
2022-12-03 15:32:54.525 [INFO ] [penhab.automation.script.ui.motionON] - OfficeDirk_Motion [Point] object false
2022-12-03 15:32:54.541 [INFO ] [penhab.automation.script.ui.motionON] - OfficeDirk_Occupancy [Status, Occupancy] object false
2022-12-03 15:32:54.560 [INFO ] [penhab.automation.script.ui.motionON] - OfficeDirk_Luminance [Measurement, Light] object false
2022-12-03 15:32:54.571 [INFO ] [penhab.automation.script.ui.motionON] - OfficeDirk_LightAutomation [LightAutomation, Point] object false
2022-12-03 15:32:54.580 [INFO ] [penhab.automation.script.ui.motionON] - OfficeDirk_Automation [Automation, Point] object false
2022-12-03 15:32:54.589 [INFO ] [penhab.automation.script.ui.motionON] - OfficeDirk_Presence [Status, Presence] object false
However, I can iterate through p.tags.forEach({ do something }).....
I’m really puzzled.