OH3 Design Pattern timeofday issue

After upgrade i had massiv issues with this snap:

var Number weekEnd = now.getDayOfWeek

var preMorning = now.withTimeAtStartOfDay.plusDays(1).minusHours(19)
var morning = now.withTimeAtStartOfDay.plusDays(1).minusHours(18)
var day = now.withTimeAtStartOfDay.plusDays(1).minusHours(16)
var preNight = now.withTimeAtStartOfDay.plusDays(1).minusHours(4)
var night = now.withTimeAtStartOfDay.plusDays(1).minusHours(2)
var nightAqua = now.withTimeAtStartOfDay.plusDays(1).minusHours(3)
var dayTime = new DateTime(SonnenaufgangStart.state.toString).millis
var nightTime = new DateTime(SonnenuntergangStart.state.toString).millis

I get this issues:

I’m total unfamiliar with java and need assist. Thanks

Per the many release notes posted in multiple locations, Joda DateTime was changed to ZonedDateTime. You’ll need to potentially adjust any use of DateTimes in your rules.

In this case replace the calls on now with


Replace the new DateTime lines with


Or consider using a version that doesn’t require you to change code in order to add/remove time of day periods and lets you define a different set of times of day for different types of day (weekend, weekday, etc).

1 Like

Just in this Seconds… i found this solution after hard reading forum. Its not easy if you dont know what are you looking for and what searching find.

var weekEnd = now.getDayOfWeek

var preMorning = now.withHour(5).withMinute(0).withSecond(0)
var morning = now.withHour(6).withMinute(0).withSecond(0)
var day = now.withHour(8).withMinute(0).withSecond(0)
var preNight = now.withHour(20).withMinute(0).withSecond(0)
var night = now.withHour(22).withMinute(0).withSecond(0)
var nightAqua = now.plusDays(1).minusHours(3).withMinute(0).withSecond(0)
var dayTime = (SonnenaufgangStart.state as DateTimeType).getZonedDateTime()
var nightTime = (SonnenuntergangStart.state as DateTimeType).getZonedDateTime()

I must test now if this work.

Thanks for help.

1 Like