Hi Folks,
I just changed to Openhab 3 Stable
Now after getting almost everithing working I run into conversion problems…
I’m using my timeofday pattern to switch daytimes but this isn’t functioning anymore
I read the threads about DateTime Conversion (openHAB 3.x) and Design Pattern: Time Of Day but I don’t get it.
I guess I’m trying to convert from JavaTime to DateTime but not sure if this is right…
There are many different guesses and I’m a little bit overwhelmed what to choose.
I tried some different approaches but all I get in the logs are warnings and errors.
If I try this:
val morning = ZonedDateTime.now().with(LocalTime.MIDNIGHT.plusDays(1).minusHours(16).minusMinutes(0))
log says:
[ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'timeofday-1' failed: 'plusDays' is not a member of 'java.time.LocalTime'
If I try this code instead:
val morning = now.withHour(8).withMinute(0).withSecond(0)
the logs are saying that this line is not working because valueOf is not a member of JavaTime:
Morning_Time.postUpdate(morning.valueOf(morning.toLocalDateTime().toString()))
see here:
[ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'timeofday-1' failed: 'valueOf' is not a member of 'java.time.ZonedDateTime'
and if I try this instead:
Morning_Time.postUpdate(morning.toString)
I get:
[WARN] [b.core.model.script.actions.BusEvent] - Cannot convert '2021-01-03T08:00:00.924228+01:00[Europe/Berlin]' to a state type which item 'Morning_Time' accepts: [DateTimeType, UnDefType].
So I’m stuck at trial & error - any hints appreciated
Do I have to change the ItemType to anything else?? Or is it a syntax error??
To prevent my head from exploding I’m writing this thread and hope for clearification and help…
thanks in advance
Dan