I am using Blockly to create a rule in openHAB 5.1.1
I am using a loop to go through a list of items retrieved by tags. Within the loop, I am trying to access the category of the item. While the item itself is found correctly, the category block (which translates to .category in the generated code) returns undefined even if the object before showed a content in the property.
Looking at the docs, there doesn’t appear to be a .category on the Item. I don’t know if it’s been removed for some reason or if it was never there and Blockly added this call in error.
In the mean time you should use either tags, or metadata, or the inline script @Tschetan posted below instead.
And file an issue. I’m not sure the best place to do so though. Probably on openhab-js to add the category to the Item.
I‘m not sure. If you take a look at the screenshot in the right side you see that there is marked in red that the item contains this attribute.
So there seems to be a different issue with it.
Finally, if you look at the code for the Item class, in particular the toString() method you’ll see that it returns the toString from the rawItem, meaning the original Java Item, and not the JS wrapped version of the Item. So what you see in the toString doesn’t reflect the members of the actual JS Item class.
toString () {
return this.rawItem.toString();
}
I’d have to go through the history of the code to see if it ever was there, but it’s definitely not there now.