Hi,
As I havent done much programming before I started off using the graphic rule creator in HABmin but I couldn’t get the rules to function correctly so with a bit of trial and error I came up with something that works. There probably are better ways to do it but here are the rules that I use.
For hot water: to switch on at 06:00 off at 08:00 and on at 18:00 off at 23:45
rule "HotWaterTimer2"
when
Time cron "0 * * * * ?" or
Item HotWaterMode changed
then
if (((HotWaterMode.state == "TIMER") && ((((new LocalTime().getLocalMillis()) >= (new LocalTime(6, 0, 0, 0).getLocalMillis())) && ((new LocalTime().getLocalMillis()) <= (new LocalTime(8, 0, 0, 0).getLocalMillis()))) || (((new LocalTime().getLocalMillis()) >= (new LocalTime(18, 0, 0, 0).getLocalMillis())) && ((new LocalTime().getLocalMillis()) <= (new LocalTime(23, 45, 0, 0).getLocalMillis())))))) {
Raspi12.sendCommand(ON)
}
if (((HotWaterMode.state == "TIMER") && ! ((((new LocalTime().getLocalMillis()) >= (new LocalTime(6, 0, 0, 0).getLocalMillis())) && ((new LocalTime().getLocalMillis()) <= (new LocalTime(8, 0, 0, 0).getLocalMillis()))) || (((new LocalTime().getLocalMillis()) >= (new LocalTime(18, 0, 0, 0).getLocalMillis())) && ((new LocalTime().getLocalMillis()) <= (new LocalTime(23, 45, 0, 0).getLocalMillis())))))) {
Raspi12.sendCommand(OFF)
}
end
For heating : (similar times)
rule "HeatingTimer"
when
Time cron "0 * * * * ?" or
Item HeatingMode changed
then
if (((HeatingMode.state == "TIMER") && ((((new LocalTime().getLocalMillis()) >= (new LocalTime(6, 0, 0, 0).getLocalMillis())) && ((new LocalTime().getLocalMillis()) <= (new LocalTime(8, 0, 0, 0).getLocalMillis()))) || (((new LocalTime().getLocalMillis()) >= (new LocalTime(18, 0, 0, 0).getLocalMillis())) && ((new LocalTime().getLocalMillis()) <= (new LocalTime(23, 55, 0, 0).getLocalMillis())))))) {
HeatingTimer.sendCommand("ON")
}
if (((HeatingMode.state == "TIMER") && ! ((((new LocalTime().getLocalMillis()) >= (new LocalTime(6, 0, 0, 0).getLocalMillis())) && ((new LocalTime().getLocalMillis()) <= (new LocalTime(8, 0, 0, 0).getLocalMillis()))) || (((new LocalTime().getLocalMillis()) >= (new LocalTime(18, 0, 0, 0).getLocalMillis())) && ((new LocalTime().getLocalMillis()) <= (new LocalTime(23, 55, 0, 0).getLocalMillis())))))) {
HeatingTimer.sendCommand("OFF")
}
if (HeatingMode.state == "ON") {
HeatingTimer.sendCommand("OFF")
}
if (HeatingMode.state == "OFF") {
HeatingTimer.sendCommand("OFF")
}
if (HeatingMode.state == "Boost") {
HeatingTimer.sendCommand("OFF")
}
end
rule "HeatingTimeronoff"
when
Item HeatingTimer changed or
Item HeatingMode changed or
Item TempSetpoint changed or
Item MyTempProxy changed
then
if ((MyTempProxy.state < TempSetpoint.state) && (HeatingTimer.state == "ON")){
Raspi23.sendCommand(ON)
}
if ((HeatingTimer.state == "OFF") && (HeatingMode.state == "TIMER")) {
Raspi23.sendCommand(OFF)
}
end
And I edited the HestiaPi default rules:
rule "checkcurrtemp"
when
Item TempSetpoint changed or
Item MyTempProxy changed
then
if (MyTempProxy.state > TempSetpoint.state){
Raspi23.sendCommand(OFF)
} else if ((MyTempProxy.state < TempSetpoint.state) &&
((HeatingMode.state=="ON") || (HeatingMode.state=="Boost") || (HeatingTimer.state=="ON"))) {
Raspi23.sendCommand(ON)
}
end
rule "Heating Mode"
when
Item HeatingMode changed
then
switch(HeatingMode.state) {
case "ON": {
if (MyTempProxy.state < TempSetpoint.state) {
Raspi23.sendCommand(ON)
}
HeatingTimer.sendCommand("OFF")
HeatingPreviousMode="ON"
}
case "OFF": {
HeatingTimer.sendCommand("OFF")
Raspi23.sendCommand(OFF)
HeatingPreviousMode="OFF"
}
case "TIMER": {
HeatingPreviousMode="TIMER"
}
case "Boost": {
HeatingTimer.sendCommand("OFF")
// See below more...
}
}
end
rule "Hot Water Mode"
when
Item HotWaterMode changed
then
switch(HotWaterMode.state) {
case "ON": {
Raspi12.sendCommand(ON)
HotWaterPreviousMode="ON"
}
case "OFF": {
Raspi12.sendCommand(OFF)
HotWaterPreviousMode="OFF"
}
case "TIMER": {
HotWaterPreviousMode="TIMER"
}
case "Boost": {
// See below more...
}
}
end
rule "MainSwitch"
when
Item MainSwitch changed
then
switch(MainSwitch.state) {
case ON:{
AUTOTEMP.sendCommand("ON")
HeatingMode.sendCommand("ON")
HotWaterMode.sendCommand("TIMER")
// 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 (HotWaterMode.state == "ON") {
HotWaterPreviousMode="ON"
HotWaterMode.sendCommand("OFF")
} else if (HotWaterMode.state == "TIMER") {
HotWaterPreviousMode="TIMER"
HotWaterMode.sendCommand("OFF")
} else if (HotWaterMode.state == "Boost") {
//This should never execute
HotWaterPreviousMode="Boost"
HotWaterMode.sendCommand("OFF")
}
if (HeatingTimer.state == "ON") {
HeatingTimer.sendCommand("OFF")
}
if (AUTOTEMP.state == "ON") {
AUTOTEMP.sendCommand("OFF")
}
}
}
end
And the site map:
sitemap default label="Main Menu"
{
Frame label="Power" {
Switch item=MainSwitch mappings=[ "ON"="ON", "OFF"="OFF"]
}
Frame label="Heating" {
Switch item=Raspi23
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"
Setpoint item=TempSetpoint minValue=0 maxValue=40 step=0.5 icon="temperature"
Switch item=AUTOTEMP mappings=[ "ON"="ON", "OFF"="OFF"]
}
Frame label="Hot Water" {
Switch item=Raspi12
Switch item=HotWaterMode mappings=[ "ON"="ON", "OFF"="OFF", "TIMER"="TIMER", "Boost"="BOOST"]
Setpoint item=HotWaterBoostTime minValue=10 maxValue=120 step=10 icon="clock"
}
Frame label="Humidity" {
Switch item=Raspi18
Text item=MyHumiProxy
}
}
You will also need to create an Item in PaperUI called HeatingTimer type, string.
Hope this helps.
Regards
Liam