DayOfWeek intValue oh3 DSL rule failure


I am trying to get the intValue of now.getDayOfWeek inside a rule (in main UI):

var int day = now.getDayOfWeek

but I get the error:

Type mismatch: cannot convert from DayOfWeek to int; line 33, column 2536, length 16

an other way:

if (now.getDayOfWeek.intValue == 7) {

results in:

The method or field intValue is undefined for the type DayOfWeek; line 35, column 2603, length 8

Can somebody point me in the right direction to solve my problem? I need to know if it is sunday (dayofweek 7).

Thank You!


Please see the OH3 release notes in section “rules”:

Rules now use Java Time API instead of Jodatime so some expressions need to be adapted:

* `getHourOfDay → getHour, getMinuteOfHour → getMinute, getMonthOfYear → getMonthValue`
* Some simple `>`and `<` comparisons may no longer work and you may need to use `isAfter()/isBefore()` instead.

See also this thread: DateTime Conversion (openHAB 3.x)

And please use the search functionality of the forums next time.

Thank you, but there I could not find how to calculate the number of the day or is this not possible anymore?

It needs a bit of investigation but


is what you’re looking for


Thank you very much!!!

Does this work in widgets too? I cant seem to get this to work:

content: =items[props.item].state.format("%1$tA")

But this:

content: =items[props.item].state.toString()

gives: 2020-12-27T17:51:11.261-0800

How can I display the Day of Week from DateTimeType in a widget?


Did you try …state.getDayofWeek.toString?

Thanks @spy0r. I was building my own Date widget, but since there is now a default one, I’m using that one. Nonetheless, I’m pretty sure I tried that also and was unsuccessful. I’m assuming that I should include the () in the expression as in state.DayOfWeek().toString().

Thanks, we can close this now.