IndexOutOfBounds?

Hello,

I have a very simple energy.rules files and I receive errors at runtime

import org.openhab.core.library.types.*

val Number kWh_cost = 0.1206
val Number kWh_co2  = 0.09


rule "General switch off"
when
  Presence changed from ON to OFF
then
  logInfo("Shutting down elements")
  sendCommand(HueToggle1, OFF)
  sendCommand(HueToggle2, OFF)
  sendCommand(HueToggle3, OFF)
  sendCommand(PowerSwitch4, OFF)
  sendCommand(PowerSwitch5, OFF)
end


rule "Update energy type"
when
  Time cron "0 0 * * * ?"
then
  var hour = now.getHourOfDay
  if (((hour >= 2) && (hour < 7)) || ((hour >= 14) && (hour < 17))) {
    EnergyType.postUpdate("HCreuses")
  } else {
    EnergyType.postUpdate("HPleines")
  }
end


rule "Update meter costs"
when
  Item gKwh changed
then
  TotalEnergyEuro.postUpdate((gKwh.state as DecimalType) * kWh_cost)
  TotalEnergyCo2.postUpdate((gKwh.state as DecimalType) * kWh_co2)
end

And I get

2016-02-14 20:02:00.037 [ERROR] [.o.m.r.i.engine.ExecuteRuleJob] - Error during the execution of rule UpdateEnergyType
java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
    at java.util.ArrayList.rangeCheck(ArrayList.java:653) ~[na:1.8.0_73]
    at java.util.ArrayList.get(ArrayList.java:429) ~[na:1.8.0_73]
    at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.evaluateArgumentExpressions(XbaseInterpreter.java:750) ~[na:na]
    at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._featureCallOperation(XbaseInterpreter.java:712) ~[na:na]
    at sun.reflect.GeneratedMethodAccessor49.invoke(Unknown Source) ~[na:na]

Any idea where the list is ?

Thanks-

Keyword Item missing:

Item Presence changed from ON to OFF

Thanks, it’s a little better but…

2016-02-14 20:24:54.468 [ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule 'General switch off': Index: 1, Size: 1

Apparently it’s the error when you try to log("") instead of log("", “”)