Mapping different rules with different cron jobs at the sitemap of OH

Hi,

i want to control the night storage heating via OH. The night storage heater have an additional heating element to produce additional heat if the heat reservoir is exhausted. To heat up the room, every heater has a fan inside.

Now i want to create a mapping element in OH sitemap to select different time scheme. For example:

Mode Normal:
set up the temperature at 21 °C between 5 am and 10 pm and between 10 pm and 5 am 18 °C

Away Mode
set up the temperature at 10 °C only between 10 pm and 5 am.

In my point of view, i have to map different cron-rules with a switch. How could this be done?

Thanks!

BW Maximilian

Look into the TimeLinePicker

Hi,

i know TimeLinePicker already. But it is a little bit overkill for my usecase. Could this not be done, creating different rules?

BW

Sure, something like:
Trigger on two cron statements (5 am and 1pm) combi ed with OR

In the when part check if it 05am then set the 21°, else check if in Normal mode ( set 18°) else set 10°.
IMHO no mapping necessary.

Hello,

do you checked this timer setup? Sitemap configurable Timer and Astrotimer (Timeclock, Astrotimeclock)

For example you can modify the “Timeclock_evaluation” rule in this way, that you can not only switch the items ON or OFF but also assign a predefined temperature to the items which are related to your heater. This temperaturevalue you can make selectable in your sitemap too.

Another question to TimeLinePicker: In my point of view, it would not work with myopenhab.org?

That is correct.

Could you give me a short example how you would do this?

Why don’t you try to write the code yourself. I have given you the main flowing pseudo code already.
If you stumble I/we will help! Just post your code and the error you get.

This is what i currently have:

rule "React on heating mode switch, send target temperatures"

when 
	Item Heating_Mode received update or
	Time cron "0 */1 * * * ?" 
then
    var CurrentHour = now.getHourOfDay
    logInfo("heating_mode.rules", "Heating Mode: " + Heating_Mode.state)
    switch Heating_Mode.state {
        case "FROSTSCHUTZ": {
            TemperaturSOLL.sendCommand(10.0)
	    if((CurrentHour > 23 || CurrentHour < 5) && ThermostatTemp.state < TemperaturSoll.state) {
		Automatik.sendCommand(ON)
	    }
        }
        case "NORMAL": {
            TemperaturSOLL.sendCommand(23.0)
        }
	default : { logError("heating_mode.rules", "Heating Mode unknown: " + Heating_Mode.state) }
    }
end

The rule sets the correct target Temperature, but is not switching on the Automatik-switch…

I’m absolutly not shure, if this is the right way…

BW

Perhaps your Item states are not what you think. Why not logInfo() them out to see? (I’m suspecting they may not all be the same type)

As @rossko57 said, use more logInfo lines, especially when using if or switch statements in order to see what the actual values/states are and you see where in rule the code is performed. My guess one of your Temperature items is not a sole number, but a number: temperature.

Some comments on your rule:
You trigger on updates of the Heating_Mode, are there only “Frostschutz” and “Normal” possible?
In case of “Frostschutz” you have an if statement that will set Automatik to ON. In mode “Normal” setting isn’t needed?
When shall the Automatik be set to OFF?
Did your requirements change, since that rule doesn’t match the initially posted requirements. You had stated that in case of “Normal” the temperature should be reduced during the night.

Hi, thanks for your answer!

i think, i should have to be a little more detailed: In Normal mode, i want to use only the storaged heat in oven. The switch Thermostat powers only the internal fan in oven.

The Away Mode (Frostschutz) should only use the additional heating element in oven. I want to use this only in the night when the energy is cheap without heating up the entire oven.

My main problem is, that i didn’t know how to realize this in a optimal way. This is what actually my sitemap looks like:

In the past days, i’ve added the temperature controlling to the rule:

rule "React on heating mode switch, send target temperatures"

when 
	Item Heating_Mode received update or
	Item ThermostatTemp changed or
	Item TemperaturNormal changed or
	Item TemperaturFrostschutz changed
then
    var CurrentHour = now.getHourOfDay
    logInfo("heating_mode.rules", "Heating Mode: " + Heating_Mode.state)
    switch Heating_Mode.state {
        case "FROSTSCHUTZ": {
	    if(CurrentHour > 23 && CurrentHour < 5)  {
		Automatik.sendCommand(ON)
		ZusatzheizungAutomatik.sendCommand(ON)
		if(ThermostatTemp.state<TemperaturFrostschutz.state) {
			Thermostat.sendCommand(ON)
			Zusatzheizung.sendCommand(ON)
			logInfo("heating_mode.rules", "Frostschutz ein")
		}
		else {
			Thermostat.sendCommand(OFF)
			Zusatzheizung.sendCommand(OFF)
		}
	    }
 	    else {
		Automatik.sendCommand(OFF)
		ZusatzheizungAutomatik.sendCommand(OFF)
	    }
        }
        case "NORMAL": {
	    if(CurrentHour > 5 && CurrentHour < 22)  {
		Automatik.sendCommand(ON)
		logInfo("heating_mode.rules", "Heizung ein")
		if(ThermostatTemp.state<TemperaturNormal.state) {
			Thermostat.sendCommand(ON)
			logInfo("heating_mode.rules", "Frostschutz ein")
		}
		else  {
			Thermostat.sendCommand(OFF)
		}
	    }
 	    else {
		Automatik.sendCommand(OFF)
		ZusatzheizungAutomatik.sendCommand(OFF)
	    }
	}
	default : { logError("heating_mode.rules", "Heating Mode unknown: " + Heating_Mode.state) }
    }
end

For the moment yes.

As i post this, the rule was in a early state and not completed yet. What i want in Normal mode is, only to switch the fan off and on depending on the current temperature and time.

I think reducing is for ne moment no necessary. I also think, that this would make much sense, because the ofen is heated up only in morning hours. If i didn’t switch of the fan automatic from 22 to 5, this could lead in a useless running of the fan, because there is no more heat in oven storaged.

Thanks a lot for your help, i know, my coding is not very well…

BW Maximilian

PS: Merry christmas to all :slight_smile:

:+1:
Merry Christmas!

If your question is solved please mark one of the answers as the solution by the checkmark icon.

Hi,

this is my current working solution:

rule "React on heating mode switch, send target temperatures"

when 
	Item Heating_Mode received update or
	Item ThermostatTemp changed or
	Item TemperaturNormal changed or
	Item TemperaturFrostschutz changed
then
var CurrentHour = now.getHourOfDay
var TemperaturNormal = TemperaturNormal.state as Number
var TemperaturFrostschutz = TemperaturFrostschutz.state as Number
var ThermostatTemp = ThermostatTemp.state as Number
val Number hysteresis = 0.1    
logInfo("Heizmodus.rules", "Heizmodus: " + Heating_Mode.state)
logInfo("Heizmodus.rules", "Tagesstunde: " + CurrentHour)
switch Heating_Mode.state {
    case "NORMAL": {
	    if(CurrentHour >= 5 && CurrentHour <=19)  {
		if (Automatik.state != ON) {
		        Automatik.sendCommand(ON)
	    		logInfo("Heizmodus.rules", "Heizmodus: " + Heating_Mode.state)
		}
		if(ThermostatTemp < (TemperaturNormal - hysteresis)) {
	                if (Thermostat.state != ON) {
			Thermostat.sendCommand(ON)
			logInfo("Heizmodus.rules", "Heizgebläse ein")
			}
		}
		else if (ThermostatTemp > (TemperaturNormal + hysteresis)){
	                if (Thermostat.state != OFF) {
			Thermostat.sendCommand(OFF)
			logInfo("Heizmodus.rules", "Heizgebläse aus")
			}
			}
	    }
 	    else if (Automatik.state != OFF || ZusatzheizungAutomatik != OFF || Thermostat.state != OFF) {
	            Automatik.sendCommand(OFF)
	            ZusatzheizungAutomatik.sendCommand(OFF)
	            Thermostat.sendCommand
	    }
	}
    case "FROSTSCHUTZ": {
	    if(CurrentHour >= 23 || CurrentHour <= 5)  {
		if (Automatik.state != ON || ZusatzheizungAutomatik.state != ON) {
	            Automatik.sendCommand(ON)
	            ZusatzheizungAutomatik.sendCommand(ON)
		    logInfo("Heizmodus.rules", "Heizmodus: " + Heating_Mode.state)
		}
		if(ThermostatTemp < (TemperaturFrostschutz - hysteresis)) {
			if (Thermostat.state != ON || Zusatzheizung.state != ON) {
		                Thermostat.sendCommand(ON)
		                Zusatzheizung.sendCommand(ON)
		                logInfo("Heizmodus.rules", "Gebläse und Zusatzheizung ein")
			}
		}
		else if (ThermostatTemp > (TemperaturFrostschutz + hysteresis)) {
	            if (Thermostat.state != OFF || Zusatzheizung.state != OFF) {
	                Thermostat.sendCommand(OFF)
	                Zusatzheizung.sendCommand(OFF)
	                logInfo("Heízungsmodus.rules", "Gebläse und Zusatzheizung aus")
   		    }
		}
	    }
 	    else if (Automatik.state != OFF || ZusatzheizungAutomatik.state != OFF || Thermostat.state != OFF || Zusatzheizung.state != OFF) {
	            Automatik.sendCommand(OFF)
	            ZusatzheizungAutomatik.sendCommand(OFF)
	            Thermostat.sendCommand(OFF)
	            Zusatzheizung.sendCommand(OFF)
	    }
    }
    case "PARTY": {
		if (Automatik.state != ON) {
		        Automatik.sendCommand(ON)
	    		logInfo("Heizmodus.rules", "Heizmodus: " + Heating_Mode.state)
		}
		if(ThermostatTemp < (TemperaturNormal - hysteresis)) {
	                if (Thermostat.state != ON) {
			Thermostat.sendCommand(ON)
			logInfo("Heizmodus.rules", "Heizgebläse ein")
			}
		}
		else if (ThermostatTemp > (TemperaturNormal + hysteresis)){
	                if (Thermostat.state != OFF) {
			Thermostat.sendCommand(OFF)
			logInfo("Heizmodus.rules", "Heizgebläse aus")
			}
			}
	}
	case "MANUELL": {
	logInfo("Heizmodus.rules", "Heizmodus: " + Heating_Mode.state)
	}
	default : { logError("Heizmodus.rules", "Heating Mode unknown: " + Heating_Mode.state) }
}
end

There are some details which i should improve (e.g. persistence, clean up the code, …). I’ve also added a hysteresis of 0.2 °C.

Could someone tell me, if there are bad mistakes in my code writing?

BW Maximilian