Cron Job Rules not working

I got a Raspberry Pi and my Cron Rules are not working.
Everything else is working fine. All riles are build the same way so here is two examples.

Is there something wrong with this Code:


//This is the rules file

//Variablen Heizung

var Number offen = 9.0
var Number eco = 16.0
var Number comfort = 22.0

//////////////////////////////////////////////////////////////////////
//Heizung Zeitsteuerung
//////////////////////////////////////////////////////////////////////

rule “Zeitgesteuerte Heizung Aufstehen Mo.”

when

Time cron “0 0 7 * 1 ?”

then

sendCommand(Bathroom_Heating, comfort)
sendCommand(LivingRoom_Heating, comfort)
sendCommand(Bedroom_Heating, comfort)
sendCommand(Hallway_Heating, comfort)
sendCommand(Kitchen_Heating, comfort)

end

rule “Zeitgesteuerte Heizung Aufstehen Di.-Fr.”

when

Time cron “0 15 6 * 2,3,4,5 ?”

then

sendCommand(Bathroom_Heating, comfort)
sendCommand(LivingRoom_Heating, comfort)
sendCommand(Bedroom_Heating, comfort)
sendCommand(Hallway_Heating, comfort)
sendCommand(Kitchen_Heating, comfort)

end

Use the method Hallway_Heating.sendCommand(comfort) instead of sendCommand(Hallway_Heating, comfort) action, likewise all others.
Enable debug logging and insert logDebug(…) statements as explained in the tutorial.

Use the codes fences when posting code please.

Your first cron statement 0 0 7 * 1 ? reads as: At 07:00:00am, every day, in January
Your second one: 0 15 6 * 2,3,4,5 ? reads as : At 06:15:00am, every day, in February, March, April and May

For 7am Monday you need: 0 0 7 ? * MON *
For 6:15 am TUE-FRI you need: 0 45 6 ? * TUE,WED,THU,FRI *

Please see:
https://www.freeformatter.com/cron-expression-generator-quartz.html

So you first rule would be:

rule “Zeitgesteuerte Heizung Aufstehen Mo.”
when
    Time cron "0 0 7 ? * MON *"
then
    Bathroom_Heating.sendCommand(comfort)
    LivingRoom_Heating.sendCommand(comfort)
    Bedroom_Heating.sendCommand(comfort)
    Hallway_Heating.sendCommand(comfort)
    Kitchen_Heating.sendCommand(comfort)
end

Even better, if you put these 5 items in a group (gHeating) then all you need to do is:

rule “Zeitgesteuerte Heizung Aufstehen Mo.”
when
    Time cron "0 0 7 ? * MON *"
then
    gHeating.sendCommand(comfort)
end

You can then combine the 2 rules:

rule “Zeitgesteuerte Heizung Aufstehen Mo-Fri”
when
    Time cron "0 0 7 ? * MON *" or
    Time cron "0 45 6 ? * TUE,WED,THU,FRI *"
then
    gHeating.sendCommand(comfort)
end

Going from 20 lines of code to 7 only!

worked fine. Thanks for your help

Did you understand the process?
Please tick the solution. Thanks

Now i know how the Cron is used correctly and my final Solution looks like this:

//This is the rules file

//Variablen Heizung

var Number offen = 9.0
var Number eco = 16.0
var Number comfort = 22.0

//////////////////////////////////////////////////////////////////////
//Heizung Zeitsteuerung
//////////////////////////////////////////////////////////////////////

rule "Zeitgesteuerte Heizung Aufstehen Mo."

when

   Time cron "0 0 7 ? * MON *"

then

   Bathroom_Heating.sendCommand(comfort)
   LivingRoom_Heating.sendCommand(comfort)
   Bedroom_Heating.sendCommand(comfort)
   Hallway_Heating.sendCommand(comfort)
   Kitchen_Heating.sendCommand(comfort)

end

The Group idea is good but this Way i can change every item individually.

I got a new idea but could not find if it works the way i think, maybe you can tell my. My idea looks like this:

when

   Time cron "0 0 7 ? * MON *"

then
  if (item.state == ON) {
        Bathroom_Heating.sendCommand(comfort)
        LivingRoom_Heating.sendCommand(comfort)
       Bedroom_Heating.sendCommand(comfort)
       Hallway_Heating.sendCommand(comfort)
       Kitchen_Heating.sendCommand(comfort)
       }

end

It doesn’t look like it works when i tested it.

What are you trying to test here?
What is item?

I would like to triger the “sendCommand” at that time only if also this switches state is ON (“item” is a placeholder)

Is this possible?

Yes

So my Code ist good and this should work The way i Plan?

Yes but please use the How to use code fences