Closed mgr01 closed 7 months ago
Thanks for your contribution.
Do you might know if we maybe face a similar issue with other items / devices too?
The only other Number
-type item that's not passed through parseFloat()
is chargerCapacityRemaining
in functions/devices/charger.js
.
Maybe it would make sense to call item.numericState
everywhere instead of parseFloat(item.state)
for all numeric items? The former uses parseFloat on .state anyways.
Maybe it would make sense to call
item.numericState
everywhere instead ofparseFloat(item.state)
for all numeric items? The former uses parseFloat on .state anyways.
While this is available on the JS library... Is it also exposed through the REST API, where we are getting the state info from?
AFAIK, the API only returns state
.
Just saw we also have such values on e.g. temperatures.
I may just go through the rest of the code and also replace Number with parseFloat where it makes sense and add it to this PR
While this is available on the JS library... Is it also exposed through the REST API, where we are getting the state info from?
Right, makes sense. For some reason I thought that you're using JS library here.
Thanks.
Done. Ready to merge I would say.
Item.state returns number+unit for items with units of measurement, e.g. "10.5 %", "22 °C". When using units, humidity should be represented by a Number:Dimensionless item with a "%" unit set in its metadata[1]. For those: Number("10.5 %") is NaN, but parseFloat("10.5 %") returns 10.5.
[1] See https://www.openhab.org/docs/concepts/units-of-measurement.html#list-of-units