Ambiguous feature call - Whats wrong? - Designer, User or Bug?


First Problem:
first off all, rule is working anyhow. But that “val - HeizungEco” inside the “sendCommand” are marked as wrong.

This is if they are set to VAL:

If i’am changing them to VAR i getting this:

Sekond Problem:
There is another rule using a VAL inside of the sendCommand. Worked finde with OH1. Rule also works perfekt with OH2. In this case it’s not markt as wrong by the eclipse designer.

But if the Group gKontakt changes even if the rule itself isn’t triggers because the if-arguments are false in this case, i have an error in log files.

13:10:36.783 [ERROR] [.script.engine.ScriptExecutionThread] - Error during the execution of rule ‘DACHFENSTER: Kontakt öffnet bei Abwesenheit’: The argument ‘command’ must not be null or empty.

Something wrong how i’am using this, or is this maybe an bug inside OH2?

I moved the VAL into the then-argument. So the VAL get called when the rules triggers. And the problem seemed to be gone. But than, if the VAL don’t works global for the hole rule-file, only within a specified rule, i don’t have any benefit using it right. Because then i can set “47,0,100” directly inside the sendCommand

The error is not about using val verses var but about the call to sendCommand. The problem is there are two different sendCommands actions that could both be valid, one that takes a Number and the other that takes a Command. This is because DecimalType is both a Number and a Command. So Designer doesn’t know which one you really want. It works because either one will work. You just don’t know which one is actually being called.

There are a host of ways you can fix this.

  1. don’t cast HeizungEco
    val HeizungEco = setHeizungEcoTemperatur.state
  2. cast it to Number instead of DecimalType
    val HeizungEco = (setHeizungEcoTemperatur.state as Number)
  3. use a String and let sendCommand convert it back
    val HeisungEco = setHeixungEcoTemperatur.state.toString
  4. use the sendCommand method on the Item instead of the actions

This one is weird. You should be able to define and use alarmAusgeloest as defined here. The only thing I can think of is that not all of the members of gLicht_Alle are able to handle that String as an input (often a Null error really means an invalid data error) but moving the val into the Rule wouldn’t fix that.

What happens if you have the val global and you log it in the rule?

1 Like


Did’t solve the problem. setHeizungEcoTemperatur is a Number-Item. I get “can not convert from state to string” but i sometimes use a Switch-Item to set the temperature via sitemap.

Switch item=setHeizungEcoTemperatur icon=“heating-20” mappings=[17.0=“17,0°C”, 17.5=“17,5°C”, 18.0=“18,0°C”]

So that does not set as Number to the item, rather than a String? I’am not a programmer
er :fearful:. Before OH1 i had noting to with linux or java. Did it that way because it worked :wink:.
Think that was wrong, as writing down this, i changed it. See? Added this' around the values.

Switch item=setHeizungEcoTemperatur icon=“heating-20” mappings=[‘17.0’=“17,0°C”, ‘17.5’=“17,5°C”, ‘18.0’=“18,0°C”]

And the designer is finde with it. No wrong syntax on the sitemap anymore.

Back to rule: First Problem:

This solved the problem! But to casting a Number-Item as Number was something i didn’t think about before :joy:

Second Problem:
Will check this later. There are possibly members that can handle that string. The members are Philip Hue Color-Items and Dimmer-Items. But normally there was any problem before to send strings like that to the dimmer. They binding ignores everything, just using the brightness information in this case.

How an value is converted to a state depends on the Item type. Assuming setHeizungEcoTemperatur is a Number Item whatever you send to it openHAB will try its best to convert that to a Number. So sending it a String “17.1” will work because openHAB knows how to convert that String to a Number. But sending the String “Hello World” will not work because there is no way to convert that into a Number.

Tanks! That helped a lot!

Last question. What’s different between DecimalType and Number? Both are a Number or i’am wrong?

It is hard to fully explain without a lot of text. At a very high level openHAB is written in an Object Oriented (OO) language. One aspect of OO is that you have Objects which are a bundle of data and methods that operate on that data. When you use MyItem.sendCommand in a Rule you are calling the sendCommand method on the MyItem object.

Objects can have two relationships: “has a” and “is a”

The “has a” relationship means that one Object contains another object. I won’t go into details as it doesn’t address your question.

In an OO language one defines the data and methods by creating a Class. A Class is like the blueprint for building Objects and an Object is an instance of a Class.

When a programmer defines a Class they can use a concept called Inheritance. Inheritance lets you make a Class (and therefore Objects created from that Class) extend or change an already existing Class. This extension is an “is a” relationship. Because the new Class extends the old Class the rest of the program can treat the new one as if it were the old one.

Thus one creates a hierarchy of Classes that all inherit from each other and you can treat any Class at the bottom of the hierarchy as if it were one of its ancestors.

In this particular case the family tree would looks something like this:

                                     /    \
                                Number   Command
                                     \    /

I think there are some more steps between Number and DecimalType but lets pretend it looks like the above.

So at the root is Object. Almost everything in the Rules is an Object. Next we have Number and Command. Both inherit from Object but they are siblings so you cannot treat a Number like a Command. However, DecimalType inherits from both Number and Command so depending on the context and what you need you can treat a DecimalType as a Number or as a Command or as a DecimalType.

When I say “treat like” what I mean is DecimalType has the same data and the same methods that a Number has so your can cast a DecimalType to Number without problem and any method that Number has DecimalType also has (e.g. DecimalType has an intValue method because Number does). Likewise, DecimalType has the same data and methods as Command so you can cast it to Command as well.

You had that first error because there are two sendCommands, one that takes a Number and one that takes a Command. Because DecimalType is both it didn’t know which one you really meant it to be.


Wow that was exakt enough :smiley: … So cool! I’ll remember your name if i have any further questions about rules LOL

@rlkoshak I hope you remember the location of all your excellent posts when we have to compile the content for the openHAB 2 documentation :slight_smile:


:smile: I didn’t think of that until it was too late. But the postings export feature is going to be a lifesaver for that. I’ll probably write a quick script to just give me those that are over a certain length and go from there.

Holy cow! I just did an export. I’ve 2123 postings and counting!

Wow! Time to do the next posting here :wink:

I checkt this. Here are the results :D.
From OH1 to OH2 there must have changed something. As you mentioned there is a problem with items within the group that can’t handle the string. So one item in the rule triggers, “the rest crashes”.

I’ll separated all items wich can handle the string into there own group. Using that group now works perfectly. Don’t matters where the val-definition is. Works global and also within the rule.