My first rule (beginner) simple Cron Timeswitch on/off does not work

Having started with OH1 recently I have at least now one device that ist working fine for over a week now. So I started with a first rule, that should simply switch a wallsocket on/off depending on the time, but it does not work at all.

In my items file I have this Switch:
Switch EG_Esszimmer_Stern “Stern” (EG_Esszimmer) { zwave=“3:command=switch_binary” }

In a rule file I have the two following rules to switch the wallsocket on at 17:00 every day in January, February, November and December, and switch it off at 23:00 (this is the more complex version, I also tried it just “for every day” but it did not work either):

rule "Stern im Esszimmer am Abend anschalten"
when
Time cron “* 0 17 * 1,2,11,12 *”
then
sendCommand (EG_Esszimmer_Stern, ON)
end

rule "Stern im Esszimmer am späten Abend ausschalten"
when
Time cron “* 0 23 * 1,2,11,12 *”
then
sendCommand (EG_Esszimmer_Stern, OFF)
end

I read an other thread about cron timers that did not help as it just gave a lot (to much for a beginner) of information about complex logging models. I will try to Setup a propper logging, but that is another thing.

Hello Jörg,

your cron expression is wrong:

  • month is counting from 0-11. For November till february it is “10,11,0,1” or you can write in abbrevation of the month “NOV,DEC,JAN,FEB” (maybe “NOV-FEB” is working as well, but I don’t know it).
  • the first number is for the second. Your rule will Trigger from 17:00:00 every second until it is 17:01:00. You should use “0” for the first number, as you only want to trigger once at 17:00:00
  • You selected every day of month and every day of week. The problem with these two values is you cannot specify this way, because they rely on each other. The documentation says “?” is the right value for one of the values, the other is “*”.

Switch on rule:

Time cron "0 0 17 * NOV,DEC,JAN,FEB ?"

Switch off rule:

Time cron "0 0 23 * NOV,DEC,JAN,FEB ?"

If you want to specify diifferent times for weekday/weekend, just replace the “?” at the end with your weekday list. “MON-FRI” or “SAT,SUN”

List of parameters from the manual for quart-cron:
(http://www.quartz-scheduler.org/documentation/quartz-2.1.x/tutorials/tutorial-lesson-06)
1.Seconds
2.Minutes
3.Hours
4.Day-of-Month
5.Month
6.Day-of-Week
7.Year (optional field)

And another hint for not getting into Trouble: don’t use the Action:

sendCommand(item, ON)

It is more reliable to use the method of the item:

item.sendCommand(ON)

The difference is that the action is guessing the proper type of value for the item, but the method of the item knows the type.

Great! Now it works. And meanwhile I tested a bit with logging, and that works too (although I won’t need it for this question any longer :wink:

Thank you very much!