[SOLVED] CRON Triggered Rules Not Starting

Hi everyone,

First of all my configuration:

Hardware: Raspberry Pi 3

  • OS: openhabianpi-raspbian-201712171718-git30faec3-crccc053823.img
  • Java Runtime Environment: not sure, I didn’t change anything from the installed OS
  • openHAB version: 2.2.0 release build

I have several rules stored in two .rules files that shall start based on cron expressions.
Unfortunately, only 4 out of the 6 rules fire over the day. The system already behaved like this with openHAB 2.1.0.
I added logInfo(“rule”, “… start log”) to every rule right in the beginning to check if the rule is running or not.
Interestingly, this 4 out of 6 subset changes when I edit (add further logInfo to the rule) the rules and upload them via FTP
I edit the code with Visual Studio Code on Windows 10 and the openHAB Addon.
Before uploading the rules, I make sure that the line endings are LF and not CRLF.
Currently, only the first rule of the “living room” file and all three rules of the “bed room” file are running.
Before that, rule 1 and 2 of the “living room” file and the second and third rule of the “bed room” file was running.

I hope you can tell me the issue here.

These are the rules for the living room:

rule "Kevin: Morning Cooling"
when
	Time cron "0 00 07 ? * MON-FRI *" or
	Time cron "0 00 09 ? * SAT-SUN *"
then
	logInfo("rule", "KLR Morning Cooling start log")
	if(KLR_Thermostat_plan.state as Number >= KLR_Thermostat_vault.state as Number)
	{
		KLR_Thermostat_plan.postUpdate(KLR_Thermostat_l.state as Number - 0.5)
		logInfo("rule", "KLR plan updated: morning cooling")
		Thread::sleep(1000)
		if(KLR_Thermostat_vault.state as Number > KLR_Thermostat_plan.state as Number && K_Vacation.state == OFF)
		{
			KLR_Thermostat_vault.sendCommand(KLR_Thermostat_plan.state as Number)
			logInfo("rule", "KLR vault commanded: morning cooling")
		}
		else
		{
			logInfo("rule", "KLR vault not commanded: manual temperature already lower than morning cooling or vacation mode active")
			logInfo("rule", "K_Vacation State: " + K_Vacation.state)
		}
	}
end

rule "Kevin: Evening Heating"
when
	Time cron "0 00 18 ? * MON-FRI *"
then
	logInfo("rule", "KLR Evening Heating start log")
	KLR_Thermostat_plan.postUpdate(KLR_Thermostat_h.state as Number)
	logInfo("rule", "KLR plan updated: evening heating")
	if(KLR_Thermostat_plan.state as Number > KLR_Thermostat_vault.state as Number && K_Vacation.state == OFF)
	{
		KLR_Thermostat_vault.sendCommand(KLR_Thermostat_plan.state as Number)
		logInfo("rule", "KLR vault commanded: evening heating")
	}
	else
	{
		logInfo("rule", "KLR vault not commanded: manual temperature already higher than evening heating or vacation mode active")
		logInfo("rule", "K_Vacation State: " + K_Vacation.state)
	}
end

rule "Kevin: Evening Heating Shutdown"
when
	Time cron "0 30 21 ? * SUN-THU *" or
	Time cron "0 00 22 ? * FRI-SAT *"
then
	logInfo("rule", "KLR Evening Heating Shutdown start log")
	KLR_Thermostat_plan.postUpdate(KLR_Thermostat_l.state as Number)
	logInfo("rule", "KLR plan updated: evening heating shutdown")
	if(KLR_Thermostat_vault.state as Number > KLR_Thermostat_plan.state as Number && K_Vacation.state == OFF)
	{
		KLR_Thermostat_vault.sendCommand(KLR_Thermostat_plan.state as Number)
		logInfo("rule", "KLR vault commanded: evening heating shutdown")
	}
	else
	{
		logInfo("rule", "KLR vault not commanded: manual temperature already lower than evening heating shutdown or vacation mode active")
		logInfo("rule", "K_Vacation State: " + K_Vacation.state)
	}
end

The rules for the bed room are:

rule "Kevin: Evening Heating"
when
	Time cron "0 05 19 ? * MON-SUN *"
then
	logInfo("rule", "KBR Evening Heating start log")
	KBR_Thermostat_plan.postUpdate(KBR_Thermostat_m.state as Number)
	logInfo("rule", "KBR plan updated: evening heating")
	if(KBR_Thermostat_plan.state as Number > KBR_Thermostat_vault.state as Number && K_Vacation.state == OFF)
	{
		KBR_Thermostat_vault.sendCommand(KBR_Thermostat_plan.state as Number)
		logInfo("rule", "KBR vault commanded: evening heating")
	}
	else
	{
		logInfo("rule", "KBR vault not commanded: manual temperature already higher than evening heating or vacation mode active")
		logInfo("rule", "K_Vacation State: " + K_Vacation.state)
	}
end

rule "Kevin: Evening Bed Room Boost"
when
	Time cron "0 05 21 ? * SUN-THU *" or
	Time cron "0 35 21 ? * FRI-SAT *"
then
	logInfo("rule", "KBR Evening Boost start log")
	KBR_Thermostat_plan.postUpdate(KBR_Thermostat_h.state as Number)
	logInfo("rule", "KBR plan updated: evening boost")
	if(KBR_Thermostat_plan.state as Number > KBR_Thermostat_vault.state as Number && K_Vacation.state == OFF)
	{
		KBR_Thermostat_vault.sendCommand(KBR_Thermostat_plan.state as Number)
		logInfo("rule", "KBR vault commanded: evening boost")
	}
	else
	{
		logInfo("rule", "KBR vault not commanded: manual temperature already higher than evening boost or vacation mode active")
		logInfo("rule", "K_Vacation State: " + K_Vacation.state)
	}
end

rule "Kevin: Evening Heating Shutdown"
when
	Time cron "0 35 21 ? * SUN-THU *" or
	Time cron "0 05 22 ? * FRI-SAT *"
then
	logInfo("rule", "KBR Evening Heating Shutdown start log")
	KBR_Thermostat_plan.postUpdate(KBR_Thermostat_l.state as Number)
	logInfo("rule", "KBR plan updated: evening heating shutdown")
	if(KBR_Thermostat_vault.state as Number > KBR_Thermostat_plan.state as Number && K_Vacation.state == OFF)
	{
		KBR_Thermostat_vault.sendCommand(KBR_Thermostat_plan.state as Number)
		logInfo("rule", "KBR vault commanded: evening heating shutdown")
	}
	else
	{
		logInfo("rule", "KBR vault not commanded: manual temperature already lower than evening heating shutdown or vacation mode active")
		logInfo("rule", "K_Vacation State: " + K_Vacation.state)
	}
end

Thank you very much for your help

Rule names need to be unique or else you end up with only one of the rules running.