Rules with Models and Points

I seem to be lost with the points - which seem to be no items - and how to access those in rules.

Mainly, I am trying to throw away my scripted balboa with the binding.
So I have to rewrite the rules.

I have no clue on how to access the points in the rule.

They are Items. You reference them like any other Items, by their name (not the label). What makes them a Point is the tags applied to the Items. There isn’t anything else special about them.

Well, then there is a complete misunderstanding of anything I try to memorize for rules.
The engine confuses me altogether,
Meanwhile, I changed the complete comparison stuff into variables first and still failing the following code:

val temp = Whirlpool_TargetTemperature.state as Number;

  logInfo("balboa.HeatUpManually.Before", 'Whirlpool_TargetTemperature:     ' + temp);

  if (temp < 39)
  {
      logInfo("balboa.HeatUpManually", ">> Whirlpool_TargetTemperature needs Update");
  }
  else
  {
      logInfo("balboa.HeatUpManually", ">> Whirlpool_TargetTemperature is high enough");
  }

The output of these commands is:

2021-02-09 08:06:27.449 [INFO ] [.script.balboa.HeatUpManually.Before] - Whirlpool_TargetTemperature:     38.0 °C
2021-02-09 08:06:27.454 [INFO ] [e.model.script.balboa.HeatUpManually] - >> Whirlpool_TargetTemperature is high enough

So in the end, there are two questions left:

  • why is the content of “temp” now “38.0 °C”, rather than just “38” or “38.0”, it is supposed to be a number ?
  • Why does the comparison of “less” fail?

Since your temperature comes with a unit, you need to check against
if (temp < 39 | °C)

See also here:

What is the “AS Number” doing then?

This is absolutely and completely Contra-Intuitive.
A Number and it’s textual view have nothing to do with eachother.
I need a simple NUMBER (Decimal, to be more precise) I can use (as in all programming laguages I know) to do math and comparisons with.
What if the Unit is also not fixed as °C, but can be either - depending on another setting be °F as well?

A Number type variable can hold a Quantity type value (with units) - this is by design.

Practical guide -

To make a very looooong story short:
A number is not a number but something else and a number has another number as a property called doubleValue:

val TargetTemp = (Whirlpool_TargetTemperature.state as Number).doubleValue;

does the trick

That does not deal with your worry -

if ( Whirlpool_TargetTemperature.state < 39 | °C)

does deal with it gracefully and correctly, even if temp is in °F

If you really must have a numeric in °C but don’t know whether is in °C or °F, you can make it so -

val TargetTemp = (Whirlpool_TargetTemperature.state as QuantityType<Temperature>).toUnit("°C").toBigDecimal

Well that was just one of the examples, I am having the same issue now with all the numbers (energy, power, temperature) and so on.

And the question was to get the number in the number type item.

And it is not defined to be a temperature. it is defined as a number only.

Then there is some error that is causing it to be loaded with a Quantity value.
Most likely you have linked a Number type Item to a number:temperature type channel of a binding?
Or maybe the way you created the Item has produced a Number:Temperature type without you realizing?

It is,

but this means that the rules from 2.5 cannot be used with 3.0 anymore and need to be rewritten,
which is a pain in the a** as there is no support - no debugger - no intellisense.

And more problematic, no consistent information anywhere. Just bits and pieces somewhere.
Anyway - I will eventually get somewhere and I will not touch the system for 3 more years.

Yes, that happens with version changes. There are other rule breaking changes too - datetime handling, exec action, etc.
What you seem to be really grizzling about is changes in the binding(s), if they are now supplying different data. Quantity types existed in OH2, but fewer bindings took advantage of them.

You are not forced to change to 3.0 - OH 2.5 continues to do what it does. Unless you have need of some umm change it provides.
I’ve still got an OH1 instance pottering away.

Yet, here we are.

Sorry, that “missing support” was not meant to be from the community, was talking about the documentation.
I apologize. Your input is much appreciated.

1 Like