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

`toString()` doesn‘t properly represent Items, Things #197

Closed florian-h05 closed 1 year ago

florian-h05 commented 1 year ago

Calling the toString() method on native Java openHAB Items returns a string that represents the Item with it‘s metadata etc. (e.g. F2_Office_Main_Light (Type=SwitchItem, State=OFF, Label=Deckenlampe AZ, Category=light, Tags=[Lightbulb], Groups=[LichterAZ])), but calling toString() on the JS version tries to stringify the object:

{
  "rawItem": {},

  "history": {

    "rawItem": {}

  },

  "semantics": {

    "rawItem": {}

  }

} 

ThingImpl doesn‘t provide a toString method, maybe one should be introduced?

FYI have a look at the toString method of GenericItem.

This issue is just a reminder for myself and to track this.

@stefan-hoehn Das hier ist das Problem wieso das Loggen eines Items von Blockly aus auf JS Scripting nicht mehr so funktioniert wie auf Nashorn.

stefan-hoehn commented 1 year ago

Thx, @florian-h05 , I appreciate if that would be done. Do you need support here?

florian-h05 commented 1 year ago

Thanks for asking, I’d need a review for my PR https://github.com/openhab/openhab-js/pull/198.

florian-h05 commented 1 year ago

Closing as #198 has been merged and I don't see the need in providing a Thing serialization from core.