Is this a typing issue?

I hope someone can help me with an error that I have not managed to understand in spite of quite a bit of effort.

The error happens in a rule that is meant to start a sprinkler and then, using a timer, shut if off after a specified delay. The rule is automatically triggered when an item named “Demarrer_Zone_Avant” is turned to ON in the UI. The rule does manage to turn on the “Irrigation_Zone_3_Insteon” as an Insteon-based channel. The problem arises with the timed shut-off part of the code. Normally the shut-off delay (item “RachioZone3_RunTime”) would be managed otherwise, but for the sake of simplicity I am assigning it a value of 60 second in the very same rule:
“RachioZone3_RunTime.sendCommand(60)”. I then use the following timer, but generates an error message:

timer = createTimer(now.plusSeconds(RachioZone3_RunTime.state), [| sendCommand(Irrigation_Zone_3_Insteon, ‘OFF’) timer = null ])

The error message is:

2020-08-17 12:31:27.012 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Demarrer Zone 3 de OH': An error occurred during the script execution: Could not invoke method: org.joda.time.DateTime.plusSeconds(int) on instance: 2020-08-17T12:31:26.969-04:00

However, the following version of the timer where I use an integer for the number of seconds does not create an error:

timer = createTimer(now.plusSeconds(60), [| sendCommand(Irrigation_Zone_3_Insteon, 'OFF') timer = null ])

I was assuming that “RachioZone3_RunTime.state” and “60” were the same thing but apparently they are not. Is this a type issue and if so, how can I fix it?

MORE DETAILS

  • Platform information:

    • Intel I5
    • Windows 10
    • jre1.8.0_201
    • openHAB 2.5.0.M3
  • Issue of the topic: error in rule script

  • Items configuration related to the issue

    Number RachioZone3_RunTime “Zone Runtime”
    channel=“rachio:zone:5054e371:009D6BBDE9CA-3:runTime”}
    Switch Demarrer_Zone_Avant “Démarrer Zone Avant”
    Switch Irrigation_Zone_3_Insteon “Zone Avant” [ “Switchable” ]
    {insteonplm=“27.D9.86:F00.00.1D#switch”}

  • Sitemap configuration related to the issue

    Frame label= “Irrigation” {
    Switch item=Demarrer_Zone_Avant label=“Démarrer Zone Avant” icon=“faucet”
    }

  • Rules code related to the issue

var Timer timer = null

rule “Demarrer Zone 3 de OH”
when
Item Demarrer_Zone_Avant changed to ON
then
Irrigation_Zone_3_Insteon.sendCommand(‘ON’)
if (timer == null) {
RachioZone3_RunTime.sendCommand(60)
timer = createTimer(now.plusSeconds(RachioZone3_RunTime.state),
[| sendCommand(Irrigation_Zone_3_Insteon, ‘OFF’)
timer = null
])
}
end

  • error message in log:

    2020-08-17 12:31:26.964 [INFO ] [g.insteonplm.InsteonPLMActiveBinding] - Item: Irrigation_Zone_3_Insteon got command ON
    2020-08-17 12:31:26.969 [INFO ] [onplm.internal.device.CommandHandler] - LightOnOffCommandHandler: sent msg to switch 27.D9.86 to on
    2020-08-17 12:31:26.969 [INFO ] [onplm.internal.device.CommandHandler] - Sending message to 27.D9.86
    2020-08-17 12:31:26.974 [INFO ] [ing.rachio.handler.RachioZoneHandler] - RachioZone: Zone will start for 20 sec
    2020-08-17 12:31:27.012 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Demarrer Zone 3 de OH’: An error occurred during the script execution: Could not invoke method: org.joda.time.DateTime.plusSeconds(int) on instance: 2020-08-17T12:31:26.969-04:00

Please use code fences. Spacing is important. It also increases readability.

How to use code fences - Tutorials & Examples - openHAB Community

@Bruce_Osborne. Sorry for the missing fences: I was confusing backquotes and quotes. Fences should now be OK. It is not clear to me how to deal with the spacing: when I paste a correctly spaced code fragment, the spacing is not being preserved.

Item state is not the integer that plusSeconds() demands.