[SOLVED] Error while updating a date item within a rule

Hi

When I try to update an item within a rule, I get an exception.

Item:

DateTime        Husqvarna_NextStartDate  		    "Nächste Startzeit [%1$td.%1$tm.%1$tY %1$tH:%1$tM]"     <time>              (gPersist)

Rule:

...
    logInfo("HUSQVARNA","nextStartTimestamp: " + nextStartTimestampString)
    Husqvarna_NextStartDate.postUpdate(nextStartTimestampString)
...

Output:

2019-09-12 20:45:00.267 [INFO ] [pse.smarthome.model.script.HUSQVARNA] - nextStartTimestamp: 2019-09-13T11:00:00.000+02:00
2019-09-12 20:45:00.270 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'Husqvarna Status': An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.postUpdate(org.eclipse.smarthome.core.items.Item,org.eclipse.smarthome.core.types.State) on instance: null

Can anyone help me ?

thx

Does this error occur every time or only during startup?

What is nextStartTimestampString? A variable? How is it populated?

Sorry, here is the complete rule, the error occurs in every interval.

// Husqvarna Status
rule "Husqvarna Status"
when 
    Time cron "0 /1 * * * ?"
then

    var String getHusqvarnaStatusResponse = sendHttpGetRequest("http://127.0.0.1:1234/status")
    val DateTimeType nextStartTimestamp = transform("JSONPATH", "$.nextStartTimestamp", getHusqvarnaStatusResponse)
    var DateTime nextStartTimestampString = new DateTime(Long.parseLong(nextStartTimestamp + "000"))

    // store values in items
    logInfo("HUSQVARNA","nextStartTimestamp: " + nextStartTimestampString)
    Husqvarna_NextStartDate.postUpdate(nextStartTimestampString)
end

You’re not feeding the postUpdate an Item state or a string. Try -

Husqvarna_NextStartDate.postUpdate(nextStartTimestampString.toString)

1 Like