My astro_sun_local_phase_name does not get initialized

Version:     2.5.0-SNAPSHOT (#1698)

User:        openhab (Active Process 489)
User Groups: openhab tty dialout audio bluetooth gpio

Directories: Folder Name      | Path                        | User:Group
             -----------      | ----                        | ----------
             OPENHAB_HOME     | /usr/share/openhab2         | openhab:openhab
             OPENHAB_RUNTIME  | /usr/share/openhab2/runtime | openhab:openhab
             OPENHAB_USERDATA | /var/lib/openhab2           | openhab:openhab
             OPENHAB_CONF     | /etc/openhab2               | openhab:openhab
             OPENHAB_LOGDIR   | /var/log/openhab2           | openhab:openhab

I get the following error:
2019-09-27 00:14:06.567 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Error during the execution of startup rule 'Lights on with start of Dusk': Could not invoke method: org.eclipse.smarthome.model.script.actions.LogAction.logInfo(java.lang.String,java.lang.String,java.lang.Object[]) on instance: null

With this script:

rule "Lights on with start of Dusk"
when
     Channel 'astro:sun:local:civilDusk#event' triggered START 
  or Item astro_sun_local_phase_name changed
  or Item vPresent changed 
  or System started 
then

  logInfo("lights.rules", astro_sun_local_phase_name) 

  if ((astro_sun_local_phase_name == "ASTRO_DUSK" || 
       astro_sun_local_phase_name == "NAUTIC_DUSK" || 
       astro_sun_local_phase_name == "CIVIL_DUSK" || 
       astro_sun_local_phase_name == "NIGHT") 
       
       && vPresent.state==ON) {
    logDebug("LIGHTS_RULES", "Lights on with start of Dusk or Night or Presence Changed at System Start ")
    // Set the luminosity of the kitchen lights

    gKitchenLights.sendCommand(25)
    // Let the LivingRoom Lights know they may turn on when presence is 
    gLightsAllowed.sendCommand(ON)
  } else {
    gLightsAllowed.sendCommand(OFF)
    gKitchenLights.sendCommand(OFF)
  }
end

logInfo() would like two strings.for arguments.
What is astro_sun_local_phase_name , an Item I guess.

You could log out several properties with

logInfo("lights.rules", astro_sun_local_phase_name.toString)

but often it’s the state that you’re really interested in

logInfo("lights.rules", "My state " + astro_sun_local_phase_name.state.toString)

You’ll probably want to be testing the .state in your if() as well.

1 Like

I’ll try this tomorrow. Thanks for the pointer.