@HestiaPi
Thanks for the help @gwmngilfen, so If I understand it correctly and based on @liamh items,sitemap and rules then this is what I have come up with.
Can you see any errors or problems that might arise before I make the edits to the HestiaPi’s.
default.items
String HeatingTimer "Heating Timer"
default.sitemap
Frame label="Heating" {
Switch item=HeatingMode mappings=[ "ON"="ON", "OFF"="OFF", "TIMER"="TIMER", "Boost"="BOOST"]
Text item=MyTempProxy
Setpoint item=HeatingBoostTime minValue=10 maxValue=1440 step=10 icon="clock"
/**CELSIUS*/ Setpoint item=TempSetpoint minValue=0 maxValue=40 step=0.5 icon="temperature"
//FAHRENHEIT Setpoint item=TempSetpoint minValue=32 maxValue=86 step=1 icon="temperature"
}
default.rules
rule "Initialisation"
when
System started
then
MainSwitch.sendCommand("OFF")
HeatingMode.sendCommand("OFF")
HotWaterMode.sendCommand("OFF")
HumiMode.sendCommand("OFF")
HeatingTimer.sendCommand("OFF")
/**CELSIUS*/ if(TempSetpoint.state == NULL) postUpdate(TempSetpoint, 18)
/**CELSIUS*/ if(TempSetpoint.state > 40) postUpdate(TempSetpoint, 18)
//FAHRENHEIT if(TempSetpoint.state == NULL) postUpdate(TempSetpoint, 70)
//FAHRENHEIT if(TempSetpoint.state < 32) postUpdate(TempSetpoint, 70)
if(HumiSetpoint.state == NULL) postUpdate(HumiSetpoint, 50)
if(HeatingBoostTime.state == NULL) postUpdate(HeatingBoostTime, 10)
if(HotWaterBoostTime.state == NULL) postUpdate(HotWaterBoostTime, 10)
if(HumiBoostTime.state == NULL) postUpdate(HumiBoostTime, 10)
TempSetpointChart.sendCommand(0);
HumiSetpointChart.sendCommand(0);
PreviousTempReading.sendCommand(0);
PreviousHumiReading.sendCommand(0);
chart_period.sendCommand(0);
end
rule "checkcurrtemp"
when
Item TempSetpoint changed or
Item PreviousTempReading changed
then
if (MyTempProxy.state > TempSetpoint.state){
HeatingPin23.sendCommand(OFF)
TempSetpointChart.sendCommand(0)
} else if ((MyTempProxy.state < TempSetpoint.state) &&
((HeatingMode.state=="ON") || (HeatingMode.state=="Boost"))) || (HeatingTimer.state=="ON"))) {
HeatingPin23.sendCommand(ON)
TempSetpointChart.sendCommand(TempSetpoint.state)
}
end
rule "Heating Mode"
when
Item HeatingMode changed
then
switch(HeatingMode.state) {
case "ON": {
if (MyTempProxy.state < TempSetpoint.state) {
HeatingPin23.sendCommand(ON)
TempSetpointChart.sendCommand(TempSetpoint.state)
}
HeatingTimer.sendCommand("OFF")
MainSwitch.sendCommand("ON")
HeatingPreviousMode="ON"
}
case "OFF": {
HeatingTimer.sendCommand("OFF")
HeatingPin23.sendCommand(OFF)
TempSetpointChart.sendCommand(0)
HeatingPreviousMode="OFF"
}
case "TIMER": {
HeatingPreviousMode="TIMER"
}
case "Boost": {
HeatingTimer.sendCommand("OFF")
MainSwitch.sendCommand("ON")
// See below more...
}
}
end
rule "Heating Timer"
TStartOne = new DateTime(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth(), 6, 0, 0)
TEndOne = new DateTime(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth(), 9, 0, 0)
TStartTwo = new DateTime(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth(), 17, 0, 0)
TEndTwo = new DateTime(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth(), 22, 0, 0)
when
Time cron "0 * * * * ?" or
Item HeatingMode changed
then
if((HeatingMode.state == "TIMER") && ((now.isBefore(TEndOne)) && (now.isAfter(TStartOne)) || (now.isBefore(TEndTwo)) && (now.isAfter(TStartTwo)))) {
postUpdate(TempSetpoint, 20)
HeatingTimer.sendCommand("ON")
}
if((HeatingMode.state == "TIMER") && ((now.isAfter(TEndOne)) && (now.isBefore(TStartTwo)) || (now.isAfter(TEndTwo)) && (now.isBefore(TStartOne)))) {
postUpdate(TempSetpoint, 16)
HeatingTimer.sendCommand("ON")
}
if (HeatingMode.state == "ON") {
HeatingTimer.sendCommand("OFF")
}
if (HeatingMode.state == "OFF") {
HeatingTimer.sendCommand("OFF")
}
if (HeatingMode.state == "Boost") {
HeatingTimer.sendCommand("OFF")
}
end
rule "MainSwitch"
when
Item MainSwitch changed
then
switch(MainSwitch.state) {
case ON:{
// Do nothing
}
case OFF:{
if (HeatingMode.state == "ON") {
HeatingPreviousMode = "ON"
HeatingMode.sendCommand("OFF")
} else if (HeatingMode.state == "TIMER") {
HeatingPreviousMode = "TIMER"
HeatingMode.sendCommand("OFF")
} else if (HeatingMode.state == "Boost") {
//This should never execute
HeatingPreviousMode="Boost"
HeatingMode.sendCommand("OFF")
}
if (HeatingTimer.state == "ON") {
HeatingTimer.sendCommand("OFF")
}
}
}
end
From my logic this should if Timer is “ON”, turn the heating ON and set the temp at 20°C between the hours of 06:00 - 09:00 and 17:00 -22:00 and then set the temp to 16°C at all other times is this correct?