I think I’m starting to loose it as I can somehow not manage (for several hours now) to set a DateTime Item.
I got a scheduled script that executes on three o’clock that should set a DateTime Item.
All I want to do, is to set a JavaScript Date() object as value for a Item.
var StartTime = itemRegistry.getItem("StartTime");
StartTime.postUpdate(new Date().toISOString());
I managed to get it working seconds after posting here…
Is this a good solution? I don’t know but it works!
var StartTime = itemRegistry.getItem("StartTime");
var dateTimeType = Java.type('org.openhab.core.library.types.DateTimeType');
var currentDateTime = new dateTimeType((new Date).toISOString());
StartTime.postUpdate(currentDateTime.toString())