Maybe this would work? Assuming Sensor1TempCAL is an item…
import org.openhab.core.library.types.DecimalType
rule "Calibration"
when
Item Sensor1Temp changed
then
Sensor1TempCAL.postUpdate((Sensor1Temp.state as DecimalType) - 2)
end
Where does the Sensor1Temp item get its value? If it’s a binding that supports transforms (like MQTT, for example), then you could replace the word default in the in-binding string with JS(calibrate.js) and make a file transform/calibrate.js:
(function(temp){
return temp - 2;
})(input)
So you item Sensor1Temp’s value would arrive already adjusted, with no need for a rule and second item. Just a thought – your way obviously works, too, and you may have good reason to do it your way!
Sensor1Tem is coming in from a zwave aeotec multisensor 6. I know there is a calibration method via habmin however when I tried that way it wouldn’t save for temperature or humidity (of course the two I can measure here). For some reason Lux and UV would accept calibration adjustments via habmin but not temp and humidity.
After a few hours of googling it does appear others are having similar challenges with the product. I logged a ticket with the manufacturer to see if they know of a fix.
Not to worry I thought I could just calibrate it within openhab instead.
No, so until the vendor can update the firmware to allow temperature calibration, the proxy item/rule approach you are using is the best alternative I’m aware of.
Hi, I am getting my bar indicators data via Mqtt. Normally, it shows a number like 0.50 high. What kind of js should I do for this? I have never done before. I would be glad if you explain in detail. Thank you…