I do not understand "Type mismatch: cannot convert from State to String"

I have a rule:

rule therm_manual_auto
when
    Item Therm_Manual changed to AUTO
then
    logInfo("Therm_Manual", "Set Therm_Mode to " + Therm_Target.state)
    sendCommand(Therm_Mode, Therm_Target.state)
end

The last line is highlighted as an error in the designer.

I know how to work around this issue.

sendCommand(Therm_Mode, Therm_Target.state.toString)

But I would like to understand why this is happening.

Both Therm_Mode an Therm_Target are SwitchItems.

openhab> smarthome:items list | grep Therm
Therm_Target (Type=SwitchItem, State=ON, Label=Zielmodus, Category=thermostat)
Therm_Mode (Type=SwitchItem, State=OFF, Label=tatsächl. Modus, Category=thermostat)

The same goes for Therm_Mode.sendCommand(Therm_Target.state), which I thought would support direct commands.

I don’t know why and I honestly don’t know if it is just a Designer problem or if OH would actually have a problem with that line as well.

The root of the problem is that for what ever reason Designer can’t tell that OnOffType can be converted to a String like any other object.

Little errors like these is why I always recommend using the method on the Item rather than the sendCommand and postUpdate actions.

I fund that when you do use the actions, it is always best to call toString explicitly every time.

Now, the fact that you are seeing the same error when using the method is another thing entirely for which I have no explanation. I routinely make exactly that call with stitches with no errors.

Do you get an error in oh while it runs too?

What version of oh and designer are you using?

No, I see no error in the logs.
But I thought my rule did not work and the I saw the warning in the designer.

I am using openhan2 (stable; rasbian) and downloaded the designer a few days ago.

The root of the problem is that for what ever reason Designer can’t tell that OnOffType can be converted to a String like any other object.

But I am just glad it not me. :slight_smile: