What means: "Could not invoke method: ...sendCommand() on instance: null"?

The short question first: I get the error message

2016-01-19 17:00:17.501 [ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule ‘Update Group Roland based on Heizung’: Could not invoke method: org.openhab.model.script.actions.BusEvent.sendCommand(java.lang.String,java.lang.String) on instance: null

on every call of the rule
rule "Update Group Roland based on Heizung"
Item HZ_Roland_SollTemp changed
sendCommand(Gr_Roland_SollTemp, HZ_Roland_SollTemp.state)

The two items are defined as:
Number HZ_Roland_SollTemp “Soll-Temperatur Roland [%.1f °C]” { homematic=“address=LEQxxxxxxx, channel=4, parameter=SET_TEMPERATURE” }
Number Gr_Roland_SollTemp “Soll-Temperatur Roland [%.1f °C]” { homematic=“address=INT0000008, channel=1, parameter=SET_TEMPERATURE” }

Any idea, what’s going wrong here?

For a deeper view what I’m doing here:
I use a Homematic wall thermostat in combination with a radiator thermostat, both of them configured in group (this implies, that both devices are joined in the Homematic world and communicate directly with each other).
This group mechanism provides a virtual device, where all write access from OpenHAB has to go to, otherwise changes (for example the destination temperature) doesn’t reach both thermostats.
The problem here is, that the group value SET_TEMPERATURE seems to be only updated every 6 hours in OpenHAB, while the radiator SET_TEMPERATURE value is updated in real time.
But I want to use the group SET_TEMPERATURE in my sitemap to be able to see the current destination temperature and change it via OpenHAB, so the current value has to be correct, otherwise +0.5°C implies unwanted effects.
For this the above rule pushes the radiator value into the group…

This seems to work correct, except the above error message, since I see the following in the events log:

2016-01-19 17:00:17 - HZ_Roland_SollTemp state updated to 20.00
2016-01-19 17:00:17 - Gr_Roland_SollTemp state updated to 20.00
which has the same timestamp as the above error message.
So why do I see this error message?


Generally when you see a null exception in this context it is because the Item you are trying to send a command to either doesn’t exist, or what you are passing to it is something it can’t convert to a State that the Item can handle (e.g. passing a String that can’t be parsed into a Number for a Number type Item).

It could also be because you are using the sendCommand action which is not as smart about converting states as calling the sendCommand method on the Item itself. Try


Or if you need to use the action try:

sendCommand(Gr_Roland_SollTemp.name, HZ_Roland_SollTemp.state.toString)

It is odd that the Event bus is showing that the change happened though. I can’t answer why it works despite this error.

This throws the same error message as before.

This looks better in my tests. Let’s see what happens over night, when Homematic internally changes the values of both items.

That’s the biggest riddle to me…

I think you should try

Gr_Roland_SollTemp.sendCommand(HZ_Roland_SollTemp.state as DecimalType)