To make it short, I have a DateTime item and want to set it from inside a rule. This is working:
var DateTime deadline = now.plusSeconds(120)
toString() is needed as postUpdate only accepts
Number, State, String.
Seems obvious that a DateTime Item should accept a DateTime variable!?
Am I missing something?
I think you need to use the
DateTimeType in your rule.
I have a DateTime item and a rule that updates it:
postUpdate(Weather_LastUpdate, new DateTimeType())
Yes, and you can create a
DateTimeType set to the time in a
DateTime object like this:
postUpdate(Weather_LastUpdate, new DateTimeType(deadline.toCalendar(null)))
Both make sense. Thanks guys! That’s what I was looking for.
As I see it DateTimeType is a data type defined in openhab in DateTimeType.java. Don’t you think a publicly available javadoc (at gh-pages for example) would be wise and helpful for openhab apprentices?
This is depricated.
How can i do this in openhab 2.3 snapshot?
I have a var DateTime and want to get an item DateTime out of it.
Only problem is to change the var to the item.
Also i want to do some math with it like this:
val mins = (now.millis - my_datetime_var.millis) / 60000
To get the time since the last timestamp in the variable.
I got it working:
I think i got the answer by myself. This seems to work: rule: OH_dt_CurrentBuild.postUpdate(dtcurrentDate.toString) logInfo("OH Update - current date split", "datetime —> " + OH_dt_CurrentBuild) Logfile: 2018-01-04 11:15:45.550 [INFO ] [cript.OH Update - current date split] - datetime —> OH_dt_CurrentBuild (Type=DateTimeItem, State=2018-01-03T11:36:40.000+0100, Label=OH: letztes Update, Category=null)