What type of variable I should use for:

  • Platform information:

    • Hardware: PRI3 model b
    • OS: openhabian
  • Java Runtime Environment: which java platform is used and what version

    • openHAB version: openHAB 2.5.1-2
  • Issue of the topic:

    Please let me know what type should be the proxy variable that should display a calibrated value of temperature. You can find below my configuration and the error that I got:

proxy Item:

Number p_ESP8266_Antreu_TempValue “Temperatura actuala: [%.1f °C]”


rule “Heating system - Birouri”
Item SetPointBirouri changed or
Item ESP8266_Antreu_TempValue changed

var tempIn_Birouri = (ESP8266_Antreu_TempValue.state as QuantityType).doubleValue
var Number setpoint_Birouri = SetPointBirouri.state as DecimalType

var Number hysteresis = 0.2

p_ESP8266_Antreu_TempValue.postUpdate(((ESP8266_Antreu_TempValue.state as QuantityType).doubleValue)-3);

if (tempIn_Birouri < (setpoint_Birouri - hysteresis)) {
else if (tempIn_Birouri >= setpoint_Birouri) {

Log (error):

2020-03-08 23:40:40.540 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Heating system - Birouri’: Could not cast 22.00 to org.eclipse.smarthome.core.library.types.QuantityType; line 94, column 23, length 54
[org.eclipse.jetty.server.HttpChannel] - www.baidu.com:443

java.lang.StringIndexOutOfBoundsException: String index out of range: -1

at java.lang.String.substring(String.java:1967) ~[?:1.8.0_222]

at org.ops4j.pax.web.service.spi.model.ServerModel.matchPathToContext(ServerModel.java:365) ~[?:?]

at org.ops4j.pax.web.service.spi.model.ServerModel.matchPathToContext(ServerModel.java:305) ~[?:?]

at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:65) ~[?:?]

at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) ~[bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.server.Server.handle(Server.java:494) ~[bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:374) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:268) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:367) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:782) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:918) [bundleFile:9.4.20.v20190813]

at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]

Thank you in advance!

It’s probably right, you know.
What type of Item is ESP8266_Antreu_TempValue ?
Certainly, your Item p_ESP8266_Antreu_TempValue is a Number type, and cannot be cast as a QuantityType. To do that, you’d need to start with a Number:Temperature or similar Item type (with units of measurement).

This one is nothing to do with your rule - read this thread

Thank you for your prompt answer.
The type of ESP8266_Antreu_TempValue is Number : Temperature:
and the item type for proxy item is :
Please let me know in this case how I should define the variable in the rule in order to be able to manipulate the temperature and to use it in the sitemap file.
Maybe I should define like:
var Number tempIn_Birouri = ESP8266_Antreu_TempValue.state as DecimalType

Thank you !

That’s up to you; there is more than one way to do most things.

But as your source data ESP8266_Antreu_TempValue is in the form of a Number:Temperature, where the state is a QuantityType … I would have thought you would want to do the whole rule in QuantityType form.

This thread might help -

Thank you very much for your tips!

In the end I done something like this:
1: define both items as Number:Temperature
2. Modify the rule like:
var tempIn_Birouri = (ESP8266_Antreu_TempValue.state as QuantityType<Number> - 3 | °C).doubleValue

p_ESP8266_Antreu_TempValue.postUpdate(ESP8266_Antreu_TempValue.state  as QuantityType<Number> -  3 | °C);
1 Like