openhab / openhab-js

openHAB JavaScript Library for JavaScript Scripting Automation
https://www.openhab.org/addons/automation/jsscripting/
Eclipse Public License 2.0
38 stars 31 forks source link

[items] Fix Item semantics `location` & `equipment` #261

Closed florian-h05 closed 1 year ago

florian-h05 commented 1 year ago

Reported in the community, see https://community.openhab.org/t/itemsemantics/146294.

Fixes an issue where the location and equipment properties were not available because getItem failed. This happened because items.js was imported from item-semantics.js and items.js imported item-semantics.js, which lead to a circular require and failed. This hacky fix passes the getItem method via the ItemSemantics constructor.

/cc @rkoshak

digitaldan commented 1 year ago

This hacky fix passes the getItem method via the ItemSemantics constructor.

Yeah, a little hacky ;-) but i get the alternative might be a larger refactoring, maybe keep a refactor it in mind if this comes up again ? I think its ok for now.

florian-h05 commented 1 year ago

maybe keep a refactor it in mind if this comes up again ? I think its ok for now.

Yeah, if this comes up once again I'd refactor it into the items file, this is the only other solution.