There’s no errors in the log, it appears to load the item file OK.
The site map displays the same value as the raw JSON data does, with added “.00” formatting as stated in the item file, eg 2271.00 and 2271 respectively.
(it’s a temperature value, and i’m trying to move the decimal point to the right place for displaying)
The JS transform returns a string not a number.
So your item definition is almost correct
Just change the label formating:
Number Aqara_1_temp "Aqara 1 Temperature [JS(divideBy100.js):%s ]" <temperature> (gAqara) { http="<[http://192.168.1.104:8080/api/A8587BBD47/sensors/2:10000:JSONPATH($.state.temperature)]" }
Better still would be to use only one transform:
transform
(function(i) {
var data = JSON.parse(i);
return parseFloat(data.state.temperature) / 100;
})(input)
item
Number Aqara_1_temp "Aqara 1 Temperature [%.1f]" <temperature> (gAqara) { http="<[http://192.168.1.104:8080/api/A8587BBD47/sensors/2:10000:JS(divideBy100.js)]" }
In this case the transform will still return a String but the binding will parse it into a Number automatically and you don’t need an second transformation for the label
thanks, but the first of those has no effect (apart from removing the “.00”), and the 2nd causes basicUI to not display (I didn’t investigate further).
that was a very very good question at a very silly person! Thank you!
And no, it wasn’t. Now that it is, it’s working with my original version.
I might have missed “install the JS transform” in the tens of topics I read before starting this one… but I don’t think I did. I don’t think it was mentioned in any of them.
The answer is “yes but”. If the HTTP binding were a 2.x version binding then we could use profiles to solve this. Each of the transforms are supported as a Profile so the JS transform Vincent posted would work as a Profile. But Profiles are only supported with Channel Links. The HTTP binding doesn’t have Channels so Profiles are not available.
One other limitation of Profiles is it only processes incoming data. You can’t use a Profile to transform data you send out. For that, until there is a mechanism like Profiles for sending out messages to devices we will need to use Rules for that if the binding doesn’t natively support transforms.