Can I use the case command in rules for actions depending on weekdays?

  • Platform information:
    • Hardware: Intel NUC
    • OS: Windows 10
    • Java Runtime Environment: jdk1.8.0 191
    • openHAB version: 2.3.0


I tried to program a rule using the case command but failed :frowning: plenty of errors. As I am not an experienced programmer I ask here for a hint.

Hi Thomas

switch - case logic is possible. But your used syntax looks wrong.
One example can be found here:

Hope that helps.


I’ll give you a start, the rest is up to you :wink:

rule "Tagabhänging"


Channel ‘astro:sun:local:set#event’ triggered START


switch (now.getDayOfWeek){

case 1: Waschen.sendCommand(ON)

case 2:

case 3:



More info about switch: switch expression

Good luck

Great, thanks, that’s it!

Hi Laurens
I have one additional question: Where can I find the possible values for the “get.” function?
e.g. are the get.DayOfWeek values from 1 to 7 and is 1 Monday?

Here you can find it

1 Like

Thanks Laurens. I am growing slowly into it. There are so many object, etc. to learn.

Best regards

Dear Thomas

Don’t worry about that. :slight_smile: I’m working now since more than 3 years with openHAB and I’m still a newbie so to say. It all depends what you would like to achieve and how. Some things are more easy than others.

So happy learning with openHAB :ok_hand: