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)
...
DateTime_Item.postUpdate(deadline.toString())
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?
tracstarr
(trac starr)
February 19, 2016, 12:18am
#2
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())
1 Like
watou
(John Cocula)
February 19, 2016, 7:53am
#3
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)))
1 Like
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?
1 Like
halloween
(Hallo Ween)
January 4, 2018, 9:27am
#5
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.
This works.
halloween
(Hallo Ween)
January 4, 2018, 10:47am
#6
I got it working:
halloween:
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)