sendCommand fails with "on instance: null"


I am running OH2 version 2.5 on OpenHabian.
I need to re-assign, every 30 minutes, the mode of a KNX Thermostat.
Any help is much appreciated. Details follows.
Greetings from Italy.

I have a number item:

Number  GeneraleClimaUffici  "Clima uffici [%d]"  <heating>   { channel="knx:device:bridge:generic:GeneraleClimaUffici" }  

I am trying the following rule

rule "ReassignHVACMode"
    Time cron "0 0/30 * 1/1 * ? *"
    logInfo("ReassignHVACMode", "GeneraleClimaUffici: " + GeneraleClimaUffici)

sendCommand fails with “on instance: null” indication.

07:42:14.696 [INFO ] [del.script.---ReassignHVACMode] - GeneraleClimaUffici: GeneraleClimaUffici (Type=NumberItem, State=3, Label=Clima uffici, Category=heating)
07:42:14.714 [ERROR] [untime.internal.engine.RuleEngineImpl] - Rule 'EditGenClimaUffici': An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.sendCommand(org.eclipse.smarthome.core.items.Item,java.lang.String) on instance: null

It seems to be having some problem with the DecimalType as a command. I think that should work but when all else fails, you can always call toString which will force OH to parse the number to a string and back again which is ineffecient but should bypass the problem.

Adding toString solved my problem. Thank you very much Rich!
However, I am unhappy I don’t understand the cause. I will keep this post open for another day.

I think the underlying cause is that a state is not a command.
Of course to us, 3.1417 looks the same whether we send it as a state update or a command.
But strictly, GeneraleClimaUffici.state is a state object and does not fall within the allowed commands to a Number type.
By supplying a string instead GeneraleClimaUffici.state.toString we force the core to parse the string into a suitable command type.
I think GeneraleClimaUffici.state as Number should work for the same reason.

You can break it in the same way with
because command ON is not the same as state ON etc.

1 Like