[SOLVED] Set item DateTimeType minus mintues

Hello,
How can I set item data as DateTimeType - 10 minutes?
I’m using now the item.postUpdate(new DateTimeType) but I need to set the time -10 mintues (I’m using it to know when I’m living home - no ping for 10 minutes, I want to update the item to -10 minutes)

Thanks?

MyItem.postUpdate(now.minusMinutes(10))
1 Like

But it is not DateTimeType and it is not recommended to use it as far as I remember, am I wrong?

Oh, sorry. I didn’t note that the types are differen. The following article shows some possibilities to convert Joda DateTime to DateTimeType. Maybe it helps:

Thank look like it is not updated.
The constructor DateTimeType(Calendar) is deprecated

@Ahiel

So the right way to do it is:
MyItem.postUpdate(now.minusMinutes(10))
Or
MyItem.postUpdate(now.minusMinutes(10).toString)
?

First one

MyItem.postUpdate(now.minusMinutes(10))

I’m getting:

[ERROR] [.model.rule.runtime.internal.engine.RuleEngineImpl] - Error during the execution of startup rule ‘Initialize variables’: 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

How did you create you item?

DateTime MyItem “leave home at [%1$tm/%1$td %1$tH:%1$tM]”

pretty old discussion, but currently I’m doing something similar with same error.
So what’s proper way how to store now plus xy minutes to an DateTime item?

DateTime    manualHeatingTime "[%1$tR]"

manualHeatingTime.postUpdate(now.plusMinutes(60))

resulting in

[ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'auto/manual override': 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

At the risk of contradicting myself with the posts above…
Did you try?

manualHeatingTime.postUpdate(now.plusMinutes(60).toString)

no I havent … I should tho, cos … it’s working :slight_smile:
but kind of trusted what you have said :smiley:

I must say, OH can be quite pain in the ass when you are doing something new here and there

Indeed, but it’s part of the fun