Adding offset to Sensor

I have mounted a DCH Z110 Sensor on my Windows. Due to the cold window frame the measured temperature is with an offset to the room temperature.

How can i add an offset to the measured value so that only the right value will be stored in my influx db

Create a Proxy Item

When your sensor updates it triggers a rule that calculates the “correct” value and postUpdate this corrected value to the Proxy Item.

Only persist the Proxy Item.

1 Like

Sometimes you don’t see the easy solutions… Krank you :joy:

Old Topic, but i have the same Problem. @Mpower
How did you solve the problem?
I read the proxy item thread but i dont understand it.

You create an item without any binding - and update this one with the offset in a rule.

rule "temperature update"
when
    Item WindowTemperature changed
then
        // give the ProxWindowTemperature item the state of the measured temperature with the offset (+10 in this example)
        ProxyWindowTemperature.sendCommand(WindowTemperature.state + 10)
end
1 Like

Thanks for your reply.

Actual item (with wrong temp)

Number Outside "Draussen [%.lf°C]"(graphtemp){channel="zwave:device:9d2ecd6a:node23:sensor_temperature"}

Created new item

proxy.items

like:

Number Proxytmp
Number Proxytmp "Proxytmp [%.lf°C]"

New Rule:

rule "temperature update"
when
    Item Outside received changend
then
        // give the ProxWindowTemperature item the state of the measured temperature with the offset (+10 in this example)
        Proxytmp.sendCommand(Outside.state + 10)
end

Log Error:

2018-02-22 17:20:09.056 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'temperature update': An error occurred during the script execution: Could not invoke method: org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_plus(java.lang.Object,java.lang.String) on instance: null

Something went wrong.

I dont know if received changed in your rule is correct.
Try changed as written in previous post

Its correct spelled in the rules file (using Visual Studio). Same issue.

Solution:

Proxytmp.sendCommand((Outside.state as DecimalType) + 2)
rule "temperature update"
when
    Item Outside changed
then
        // give the ProxWindowTemperature item the state of the measured temperature with the offset (+2 in this example)
        Proxytmp.sendCommand((Outside.state as DecimalType) + 2)
end

I’m puzzled, that we need the casting as it’s already a number item, but I’m glad it works

Outside is a NumberItem but as far as the Rule is concerned it is an Item until you tell it otherwise. And Item returns the state as a State. You can’t do math with just a State.

Usually, the Rules Engine is smart enough to say “hey state, do you understand +?” and the state object will say “yes” or “no” (in which case an error is thrown). But sometimes the Rules Engine fails to ask the question or gets a “no” for an answer erroneously. I’ve not been able to determine a pattern for when it works and when it fails.

If you would rather avoid the times when it fails work right automatically, you can just always cast it though I would cast it to Number, not DecimalType because there are some cases where DecimalType itself can cause some Type problems, in particular when one tries to use it with the sendCommand or postUpdate methods on a Item.

1 Like