Friends,
I again need your help with a basic thing. I want to add up two values. I already spend 2 hours trying to find out myself but I could not figure it out.
I have:
var Number result = (soll_gEG1 as DecimalType) + (offset_gEG1 as DecimalType)
I get the error:
2017-04-02 12:08:10.188 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule Get Temp: org.eclipse.smarthome.core.library.types.DecimalType
I already tried this, but also did not work:
var Number result = (soll_gEG1.state as DecimalType) + (offset_gEG1.state as DecimalType)
The two value have been derive from a read:
var Number soll_gEG1 = transform("JSONPATH", "$.[0].raeume[0].solltemperatur", json)
var Number offset_gEG1 = transform("JSONPATH", "$.[0].raeume[0].total_offset", json)
Both values are not NULL. Can somebody please help me how to get it to work?
I tried to add the two numbers. When I do this I get an error:
2017-04-02 21:12:56.201 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule Get Temp: An error occured during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.lib.NumberExtensions.operator_plus(java.lang.Number,java.lang.Number) on instance: null
Oli,
again, thanks for your support. I spent another 6 hours adding two numbers: crazy! Its still not working.
I can clearly see that the veriable is not NULL before doing a calculation. But in the calculation I get error messages stating that the variable is NULL. As soon as I try to cast it to x as DecimalType or x.doubleValue I get an error message.
Here is the line I get the value from:
var Number temp_gEG1 = transform("JSONPATH", "$.[0].raeume[0].temperatur", json)
as soon as I write:
var Number temp_gEG1 = transform("JSONPATH", "$.[0].raeume[0].temperatur", json) as DecimalType
var Number temp_gEG1 = transform("JSONPATH", "$.[0].raeume[0].temperatur", json).doubleValue
I get error messages like
Error during the execution of rule Get Hum: An error occured during the script execution: The name ‘.doubleValue’ cannot be resolved to an item or type.
or Error during the execution of rule Get Hum: org.eclipse.smarthome.core.library.types.DecimalType
Any ideas from the group how I can solve this? All I want to do is to add two values from my heating system.