Instant null error: Rule OH 3.1

Hi All,

Trying to line my AC zone and Power, but it keeps throwing an error despite the items having a valid state. I’m not sure what I’m doing wrong here, any tips? Thanks!


rule "Turn on Daikin Power when Zone Changes to ON"
when
  Member of gDaikinZones changed
then
  val zone = triggeringItem.name
  if(HouseAir_MasterSwitch.state == OFF && triggeringItem.state == ON){
    zone.sendCommand(ON)
    HouseAir_MasterSwitch.SendCommand(ON)
   } else if (HouseAir_MasterSwitch.state == ON && triggeringItem.state == ON){
       HouseAir_MasterSwitch.sendCommand(OFF)
       zone.sendCommand(OFF)
   }
end

Console shows:

Script execution of rule with UID 'climate-3' failed: An error occurred during the script execution: Could not invoke method: org.openhab.core.model.script.actions.BusEvent.sendCommand(java.lang.String,java.lang.String) on instance: null in climate
  • add the error message to your post as this will help to get answers
  • add debug logging to check/show the state of your items

That’s just a string of characters, the name of some Item.

You can’t send commands to strings of characters.
You’ll be wanting to command the Item proper, in the same way as you got the state of the Item and not the state of its name.
... && triggeringItem.state == ON){

Items don’t have a .SendCommand() method, character case is always important.

1 Like

Thanks! Working now :slight_smile: