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.MyItem.type no longer includes "Item" in the type #327

Closed rkoshak closed 2 months ago

rkoshak commented 2 months ago

Expected Behavior

Previous to now the type of the Item was a String version of the last part of the rawItem's classname. For example a String Item was "StringItem".

Current Behavior

The behavior changed and now the type no longer includes the "Item" portion of the type.

While I kind of like this change it is definitely a breaking change and the break was not clearly described in the 4.2 M2 announcements.

The change in behavior appears to have been introduced in PR #325 but it's not clear why the change was made from this.rawItem.getClass().getSimpleName(); to return this.rawItem.getType().toString(); and the description of the PR does not indicate this behavior changed.

Possible Solution

I really have no problem with the change itself but it has unexpectedly broken at least one of my rule templates, maybe more. As a breaking change it should at least be clearly described in the release notes.

Steps to Reproduce (for Bugs)

  1. console.log(items.SomeItem.type); and notice that the "Item" part of the result is omitted.

Context

Your Environment

florian-h05 commented 2 months ago

Seems like I overlooked this in the PR description and therefore it is also missing in the release notes.

I will adjust the CHANGELOG and add a warning.