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

08

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.
Thnks

Hi Thomas

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

Hope that helps.

Regards
Stefan

Iā€™ll give you a start, the rest is up to you :wink:

rule "TagabhƤnging"

when

Channel ā€˜astro:sun:local:set#eventā€™ triggered START

then

switch (now.getDayOfWeek){

case 1: Waschen.sendCommand(ON)

case 2:

case 3:

}

end

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?
Thanks

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
Thomas

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:

Cheers
Stefan