Hi. I am trying to show a DateTime, some (variable) minutes from the current time. As this is my first OpenHAB project, I am struggling a bit.
My question: I would like to add 10 minutes to the current time, and display the clock with these added minutes . I have been trying with the following.
ITEMS
DateTime SystemTime "Current time [%1$tT %1$tA, %1$td.%1$tm.%1$tY]"DateTime PlusTime "Plus time [%1$tT %1$tA, %1$td.%1$tm.%1$tY]"
RULES
rule "Get System time, and add some minutes"whenTime cron "* * * * * ?"then
postUpdate(SystemTime, new DateTimeType())PlusTime = SystemTime.plusMinutes(10)postUpdate(PlusTime, new DateTimeType())endPlusTime.postUpdate(new DateTimeType("" + SystemTime.plusMinutes(10)))
import org.openhab.core.library.types.*import org.openhab.core.persistence.*import org.openhab.model.script.actions.*import org.joda.time.*import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
import org.openhab.library.tel.types.CallType
import org.openhab.core.transform.actions.Transformation
import org.joda.time.*
import java.lang.Double
import java.lang.Math.*
import java.util.Date
I guess the last could be crucial.
But since there is hardly any documentation, it is always an trial and error to get it working.
I finally got it working, using a mix of what Ben and Martin suggested, and a lot of "trial and error". The line that is working is:
postUpdate(PlusTime,new DateTimeType("" + now.plusMinutes(10)))
This gives me a clock 10 minutes ahead of time.
Wow, coming from arduino (and not being a programmer) this is more difficult than expected, as there is very little documentation, and no official example collection.
So thanks a lot for the help guys.Most appreciated.