I recently started using the Wunderground binding, which exposes things with the type of Number:Temperature. PaperUI and HABmin both filter the items to which I can link these things so that only items of the Number:Temperature type are available. That’s not a problem in itself, and the linking works just fine.
I can see the the Number:Temperature has the benefit of applying a specific format whenever it’s converted to string on the UI. That makes sense. The problem comes when I try to make comparisons within a rule. I don’t see a documented way to add a variable (or literal) to a rule which matches the state of the Number:Temperature, so I am trying to compare it with float types. I have tried various conversions, but none give the expected result. For example:
var float _maxOutsideTemp = 23.0
...
if ((Weather_MaxTemp_0.state as Number) < _maxOutsideTemp)
{
logInfo("my.rules", "max temp (" + (Weather_MaxTemp_0.state as Number) + ") < " + _maxOutsideTemp)
}
This gives the non-intuitive result:
max temp (20 ℃) >= 23.0
Nothing I’ve tried has ever caused an exception. The comparison just returns unexpected results without complaint. Maybe there something wrong with the type’s Comparitor implementation of maybe I’m just missing the point. Either way, some guidance would be appreciated.