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

[Quantity] Support Item for Quantity construction & divide/multiply methods #275

Closed florian-h05 closed 1 year ago

florian-h05 commented 1 year ago

This adds support for passing a Quantity-compatible Item to the Quantity factory and all methods which accept a Quantity as argument (e.g. add, subtract) and also allows to pass Items holding number states to the divide and multiply methods. The library therefore detects the type of an Item's state and creates either a BigDecimal or a QuantityType from it.

Unit tests were also cleaned-up and the jest setup was moved to an extra file.