I have been reading over the Javascript documentation to learn about openHAB’s Javascript language. It’s been challenging for me as I am not a programmer and I first had to figure out how to interpret the documentation . I am slowly accomplishing this and have a decent understanding of putting together items statements.
I also read over the Semantics actions section. There I found the following statement:
Semantics.getLocation(Item item)
I have been experimenting with this action in a test script. Through a lot of trial and error I have the following script:
var Semantics = Java.type("org.openhab.core.model.script.actions.Semantics");
const myitem = items.getItem('BedroomSensor_Luminance');
console.info('Script test', 'Item: ' + myitem.name + ' location: ' + actions.Semantics.getLocation(myitem))
Unfortunately the script fails because of the actions.Semantics.getLocation statement. I’ve tried replacing (myitem) with (‘BedroomSensor_Luminance’), (BedroomSensor_Luminance), (item, ‘BedroomSensor_Luminance’) but nothing works. The script always fails.
What is the proper way to enter the item in that method?
The error returned for actions.Semantics.getLocation(myitem) is:
Unsupported operation identifier 'getTags' and object '[object Object]'(language: JavaScript, type: Item). Identifier is not executable or instantiable
And when I try actions.Semantics.getLocation(‘BedroomSensor_Luminance’):
TypeError: invokeMember (getLocation) on org.openhab.core.model.script.actions.Semantics failed due to: Cannot convert 'BedroomSensor_Luminance'(language: Java, type: java.lang.String) to Java type 'org.openhab.core.items.Item': Unsupported target type
when I remove the quotes and use (BedroomSensor_Luminance):
ReferenceError: "BedroomSensor_Luminance" is not defined
Thanks for any clues.