How to subtract 1C from temperature value, measured by SCD41 with REGEX?

Hi all, I’m going to change my HTU21 to new SCD41 sensors at all my rooms. 3 months testing of one sensor revealed that temperature measured with SCD41 is exactly 1 degree higher than real temperature. I’m getting temperature value from SCD41 with a help of REGEX transform applied to raw I2C data: .temp:([±]?\d.\d\d).*
Is there a way to extract exactly 1C from temperature value without adding million of proxy items and rules?

Why do you thing that you need to add million of proxy items and rules ? Shouldn’t one be enough ?
Sorry I couldn’t resist …

Have a look at profiles.
There is one called offset:>

An offset can be specified via the parameter offset which has to be a QuantityType or DecimalType. The specified offset will be applied to the value from the device before it arrives at the Item.

1 Like

Cause I’m already using REGEX profile to get the data, raw data coming at thing level is CO2:567/temp:23.15/hum:41.55, then there are 3 items with REGEX transform decoding this string to 567 ppm, 23.15C, 41.55%

Try use Item JS transform:

    return t - 1;

I cannot, cause there is only one transform allowed to use with item, and I’m already using REGEX transform.

Yes you can):

    return t.split("/")[1].split(":")[1] - 1;

Regex not needed in this case

the exec transformation also should work.
Using the exec transformation you can do anything with the input: split, calculate, use expressions.
What I do not know is if resp. how to deal with units.

Chained transformation exists, but i never used it.

Transformations can be chained by separating them with the mathematical intersection character “∩”. Please note that the incoming value will be discarded if one transformation fails (e.g. REGEX did not match)


That’s for MQTT binding only. If I’ll going to deal with Javascript - then I’d better do it inside MegaD binding, was just hoping to avoid this and do a simple operation from UI.

Well, HTTP as well, but you kept the binding that you are using secret.

Did you see @Wolfgang_S note about profiles, and in particular the offset profile designed for exactly this job?

I’m using MegaD binding. And I can’t apply both REGEX and offset profile to one item.

Yes you can. The REGEX is on the binding like you have now. The Offset is added at the Link using a Profile. They are completely separate.

The Offset goes here:

No I can’t =) There is no REGEX on the binding, REGEX is applied to channel, 3 items to one channel with 3 different REGEX expressions, as SCD41 reports all his data (CO2, temperature, humidity) in one string, which should be parced then.

Meaning you are already using a profile?

If the regex is configured on the Channel/Thing, then you can additionally apply a profile transform on the Link between the Channel and the Item.

If you are already using a profile, then use the JS transform like @martiniman demonstrated. But note, this is completely outside the binding/Thing/Channel. It exists on the Link between the Channel and the Item.

Your imprecise use of terms that have specific meanings in OH are causing us confusion I think.

The above two statements are mutually exclusive.

No, they aren’t. There is no parsing in the binding, SCD41 channel is for raw i2c data, so I’ll have to edit binding’s code, do all my stuff there, parce there raw data into 3 separate channels and finally I will be able to apply offset transform to temperature channel.
Martiniman’s example isn’t processing “NULL” or “busy” values, so to get everything right, it’s better to do this inside binding.
I was just hoping, that there could be some flag like “/e”, which could allow me to do some arithmetic in REGEX substitute.

I guess it must be this binding

(Note you can contribute)

I cannot read Russian(?) but it does not appear to support any channel-based transformations (yet).

So yes, you are limited to just one profile action at a time.

javascript used with a transform profile is very flexible.
You may link one channel to several different Items. Each channel-Item link may have a different profile to extract different data to each Item.

I’d be inclined to do it in a rule though, at least to begin with; easier to develop and debug.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.