@mcqwerty In some cases, I think it’s better to just test the rules with openHAB than just rely on the errors generated in VSCode. Especially with new features, I have seen some unnecessary errors in VSCode that are interpreted just fine in openHAB.
This works from my testing. I just want to point out that you can’t increment a variable defined as final (val
). Also, I would recommend defining the QuantityType specific dimension over the overall Number one.
var temp = myNestAmbientTemperature.state as QuantityType<Temperature>
temp += 2|°C
As I mentioned above, QuantityType<Number>
covers all dimensions. So QuantityType<Temperature>
is derived from it.
Per my understanding, for QuantityType declaration using the value of a variable, you will need to use the declaration function. This works in my testing.
val double num = 2
val QuantityType<Temperature> qt = new QuantityType(num + "°C")