Rule can't access item but item seems to be ok

Hi,

I’m fighting with a rule that throws errors that I don’t understand:

2017-09-09 19:09:09.028 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'Command_Desired_Temperature_GF_Bath': 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,org.eclipse.smarthome.core.types.Command) on instance: null

2017-09-09 19:10:00.045 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule Check_GF_Bath_Temperature_For_Consistency: 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,org.eclipse.smarthome.core.types.Command) on instance: null

And these are the rules:

rule Command_Desired_Temperature_GF_Bath
when
  Item Desired_Temperature_GF_Bath_Command received update
then
  Desired_Temperature_GF_Bath.sendCommand(Desired_Temperature_GF_Bath_Command.state)
end
rule Check_GF_Bath_Temperature_For_Consistency
when
  Time cron "0 /5 * * * ?"
then
  if (Desired_Temperature_GF_Bath_Command.state != Desired_Temperature_GF_Bath.state) {
    if (Contact_Window_GF_Bath.state == OFF) {
      logInfo("GF_Bath","Desired Temperature differes from Command Temperature")
      Desired_Temperature_GF_Bath.sendCommand(Desired_Temperature_GF_Bath_Command.state)
    }
  }
end

So as far as I can see, the rules say, that Desired_Temperature_GF_Bath is null.

But when using the console:

openhab> smarthome:status Desired_Temperature_GF_Bath
8

So how is it possible, that the Console say, that the item is 8 and the rules say, that it is null?

Bests
Pacsal

Try:

sendCommand(Desired_Temperature_GF_Bath,Desired_Temperature_GF_Bath_Command.state)

I think the problem is not with the method for the object, nor the action! I think it is linked with the string (AFAIK, the command has to be a string, or if not the underlayer transforms it). So, if you sendCommand (method, or action) I think the command should be:

mySetpointItem.sendCommad(myItem.state.toString)

Log out the states of both items in your bath rule to see if you can figure out if there is something wrong with one of the items.

Are both bath Items Number Items?

Sadly, the rules will throw a a null exception any time you pass it something it can’t figure out how to convert to a form it understands.

Normally what you are doing should work, but when you are dealing with Number items things often go wrong.

Try using .state as Number.

The toString idea will work as well but for the method call it will handle other compatible tires including primatives.