openhab-scripters / openhab-helper-libraries

Scripts and modules for use with openHAB
Eclipse Public License 1.0
88 stars 70 forks source link

Update utils.js with getTriggeringItemStr #142

Closed HerzScheisse-zz closed 5 years ago

HerzScheisse-zz commented 5 years ago

Dont know if its used to be in this core utils.js file or should went to personal folder...

I added this function to my utils.js file because its very usefull for me...

If you think it should not be here... feel free to delete this PR :)

source of this code snippet: https://github.com/illnesse/openhab2_pub_001/blob/master/automation/jsr223/00_jslib/helper.js

5iver commented 5 years ago

Wouldn't you just use event.itemName? If so, then I do not think this would be useful in utils.js. But I could be wrong!

I have a documentation update PR that I hope to get out today, where I've pulled together all of the common information shared by each language. Like this doc, which is pertinent here... https://github.com/openhab-scripters/openhab-helper-libraries/blob/master/Docs/Python/Event-Object-Attributes.md#event-object-attributes.

And thank you for contributing! I have some more PRs coming to slowly get the JSHLs on par with the JythonHLs.

HerzScheisse-zz commented 5 years ago

Thank you for your comment. yeah i just need to get the triggered item name to split the last diget number of that item. i do it now with: var triggeringItem = getItem(getTriggeringItemStr(input));

but yeah you are right... i can achieve this without my modifications in this PR

var triggeringItem = input.event.itemName;

I'm just started working with the new rule engine...

thank you :)

5iver commented 5 years ago

Excellent! My understanding then is that this PR is not needed, so closing. If you have any other questions, feel free to @ me in the forum or just tag your post with jsr223.