Debugging really basic rule

Hi,

I’m struggling with what I guess are basics with rules…

I have created an item:

Number Temp_Target_Lounge "Lounge Target [%.1f °C]" <temperature>

and rule:

import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*

//======================================================================================

rule "Heating System Started Defaults"
when
  System started
then
  logInfo( "HTG", "System Start Actions" );
  
  var Number required_temp = 20

  logInfo( "HTG", "dbg-01" );

  postUpdate( Temp_Target_Lounge, required_temp )

  logInfo( "HTG", "dbg-02" );

  var msg = "System Started, Temp Defaulted to " + required_temp

  logInfo( "HTG", msg );

end

But based on the output in the openhab.log file (in debug mode):

10:20:07.391 [INFO ] [c.internal.ModelRepositoryImpl:98   ] - Refreshing model 'heating.rules'
10:20:07.404 [DEBUG] [m.r.internal.engine.RuleEngine:264  ] - Executing startup rule 'Heating System Started Defaults'
10:20:07.410 [INFO ] [org.openhab.model.script.HTG  :53   ] - System Start Actions

so only the first logItem ever appears in the log, and (I guess) the rule stops (presumably with an error). I have also tried just two logItem’s like this:

import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
//======================================================================================
    
rule "Heating System Started Defaults"
when
  System started
then
  logInfo( "HTG", "System Start Actions" );
  logInfo( "HTG", "dbg-01" );
end

But again only the first logItem is run.

What am I doing wrong in what seems such a simple test?

Thank you.

Your logging statement is pointing to a logback reference/appender entry “HTG” and sending the messages there. Do you have that configured ?

see logback.xml / logback_debug.xml

I have multiple loggers configured–see here How-to Article on MakeUseOf for details.

Bob, Thanks for the reply.

The logging was fine (I was getting the initial entry appearing in the log file).

Having walked away and returned, I found that the original script was saved in dos format (CrLf at the end of each line). When I switched to Unix format (Lf only) things started to work as expected.

No idea why this affects things, but the behaviour is not as simple as just ‘only works in Unix format’ because I have another rule file (again very simple) that is in CrLf format and does work. The key difference that I can see is that I only have a logInfo line (which is termindated by a semicolon unlike most lines) at the end of the rule rather than at the start and end.

It almost seems like when you hit a semicolon, rule processing will halt if using dos file format.

Thanks again for your reply.

This is happening on a Ubuntu 12.04 system running OpenHab 1.7.1