Add offset profile to a temperature item from MSQTT

  • Platform information:
    • Hardware: Raspberry Pi 4B
    • OS: Raspberry Pi OS Bullseye
    • Java Runtime Environment: OpenJDK 17.0.9
    • openHAB version: 4.0.4
  • Issue of the topic: I’m fetching MSQTT reports from an Aqara motion sensor, and extracting temperature value using JSONPATH:$.device_temperature value transformation. I want to apply an offset to calibrate the temperature, but when I go into the item, Offset is not available - see pic. The item is set as Point>Measurement. Been all over the documentation but can’t figure out what I’m missing, any help appreciated.

I can’t say why the offset profile is not listed. But it would be simpler to keep it all in the MQTT Channel config.

You could chain the JSONPATH to an inline JS transform:

JSONPATH:$.device_temperature∩JS: | parseFloat(input)/10

Obviously you’ll need to use the operation you need from offset.

Or just use the JS transform from the start.

(function(input) {
  const parsed = JSON.parse(input);
  const temp = parsed.device_temperature; // I'm assuming this is a number
  return temp / 10;

Or as an inline script

JS: | JSON.parse(input).device_temperature / 10;
1 Like

Thank you so much for that - sorry for the slow response, been a crazy week! Will try that out shortly.