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

Thing.setX methods are not implemented correctly #270

Closed rkoshak closed 1 year ago

rkoshak commented 1 year ago

Expected Behavior

Calling setLabel() on a Thing should persist across OH reboots. The same goes for all the other set methods.

Current Behavior

Calling setLabel() changes the label but after a reboot the label reverts to the old value. I suspect the same goes for the other set methods.

Possible Solution

After calling setLabel() on the Java Thing Object, pass that updated Object to the ThingRegistry.update() method to update the value in the registry which will save the changes to the JSONDB.

Steps to Reproduce (for Bugs)

1.

things.getThing('MyThingID').setLabel('New Label')
  1. Restart OH.
  2. Look at the Thing page and see the label has been reverted.

Context

See https://github.com/openhab/openhab-core/issues/3648#issuecomment-1584279961

florian-h05 commented 1 year ago

Duplicates #269 but this has more detail, so I’ll close #269.

rkoshak commented 1 year ago

Sorry, I didn't even search to see if one was already created.

florian-h05 commented 1 year ago

No problem :+1: It was more a note for myself than for others ;-)

Anyway, I have fixed the problem, the update call to the ThingRegistry was missing.